mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-25 06:49:15 +01:00
composer and npm
This commit is contained in:
15
conf/site/node_modules/serialize-javascript/README.md
generated
vendored
15
conf/site/node_modules/serialize-javascript/README.md
generated
vendored
@@ -40,19 +40,20 @@ serialize({
|
||||
bool : true,
|
||||
nil : null,
|
||||
undef: undefined,
|
||||
date: new Date("Thu, 28 Apr 2016 22:02:17 GMT"),
|
||||
map: new Map([['hello', 'world']]),
|
||||
set: new Set([123, 456]),
|
||||
|
||||
fn: function echo(arg) { return arg; },
|
||||
re: /([^\s]+)/g
|
||||
inf : Infinity,
|
||||
date : new Date("Thu, 28 Apr 2016 22:02:17 GMT"),
|
||||
map : new Map([['hello', 'world']]),
|
||||
set : new Set([123, 456]),
|
||||
fn : function echo(arg) { return arg; },
|
||||
re : /([^\s]+)/g,
|
||||
big : BigInt(10),
|
||||
});
|
||||
```
|
||||
|
||||
The above will produce the following string output:
|
||||
|
||||
```js
|
||||
'{"str":"string","num":0,"obj":{"foo":"foo"},"arr":[1,2,3],"bool":true,"nil":null,"undef":undefined,"date":new Date("2016-04-28T22:02:17.000Z"),"map":new Map([["hello","world"]]),"set":new Set([123,456]),"fn":function echo(arg) { return arg; },"re":/([^\s]+)/g}'
|
||||
'{"str":"string","num":0,"obj":{"foo":"foo"},"arr":[1,2,3],"bool":true,"nil":null,"undef":undefined,"inf":Infinity,"date":new Date("2016-04-28T22:02:17.000Z"),"map":new Map([["hello","world"]]),"set":new Set([123,456]),"fn":function echo(arg) { return arg; },"re":new RegExp("([^\\\\s]+)", "g"),"big":BigInt("10")}'
|
||||
```
|
||||
|
||||
Note: to produced a beautified string, you can pass an optional second argument to `serialize()` to define the number of spaces to be used for the indentation.
|
||||
|
||||
45
conf/site/node_modules/serialize-javascript/index.js
generated
vendored
45
conf/site/node_modules/serialize-javascript/index.js
generated
vendored
@@ -6,9 +6,12 @@ See the accompanying LICENSE file for terms.
|
||||
|
||||
'use strict';
|
||||
|
||||
var randomBytes = require('randombytes');
|
||||
|
||||
// Generate an internal UID to make the regexp pattern harder to guess.
|
||||
var UID = Math.floor(Math.random() * 0x10000000000).toString(16);
|
||||
var PLACE_HOLDER_REGEXP = new RegExp('"@__(F|R|D|M|S|U)-' + UID + '-(\\d+)__@"', 'g');
|
||||
var UID_LENGTH = 16;
|
||||
var UID = generateUID();
|
||||
var PLACE_HOLDER_REGEXP = new RegExp('(\\\\)?"@__(F|R|D|M|S|U|I|B)-' + UID + '-(\\d+)__@"', 'g');
|
||||
|
||||
var IS_NATIVE_CODE_REGEXP = /\{\s*\[native code\]\s*\}/g;
|
||||
var IS_PURE_FUNCTION = /function.*?\(/;
|
||||
@@ -31,6 +34,15 @@ function escapeUnsafeChars(unsafeChar) {
|
||||
return ESCAPED_CHARS[unsafeChar];
|
||||
}
|
||||
|
||||
function generateUID() {
|
||||
var bytes = randomBytes(UID_LENGTH);
|
||||
var result = '';
|
||||
for(var i=0; i<UID_LENGTH; ++i) {
|
||||
result += bytes[i].toString(16);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function deleteFunctions(obj){
|
||||
var functionKeys = [];
|
||||
for (var key in obj) {
|
||||
@@ -57,6 +69,8 @@ module.exports = function serialize(obj, options) {
|
||||
var maps = [];
|
||||
var sets = [];
|
||||
var undefs = [];
|
||||
var infinities= [];
|
||||
var bigInts = [];
|
||||
|
||||
// Returns placeholders for functions and regexps (identified by index)
|
||||
// which are later replaced by their string representation.
|
||||
@@ -102,6 +116,14 @@ module.exports = function serialize(obj, options) {
|
||||
return '@__U-' + UID + '-' + (undefs.push(origValue) - 1) + '__@';
|
||||
}
|
||||
|
||||
if (type === 'number' && !isNaN(origValue) && !isFinite(origValue)) {
|
||||
return '@__I-' + UID + '-' + (infinities.push(origValue) - 1) + '__@';
|
||||
}
|
||||
|
||||
if (type === 'bigint') {
|
||||
return '@__B-' + UID + '-' + (bigInts.push(origValue) - 1) + '__@';
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -175,14 +197,21 @@ module.exports = function serialize(obj, options) {
|
||||
str = str.replace(UNSAFE_CHARS_REGEXP, escapeUnsafeChars);
|
||||
}
|
||||
|
||||
if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && undefs.length === 0) {
|
||||
if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && undefs.length === 0 && infinities.length === 0 && bigInts.length === 0) {
|
||||
return str;
|
||||
}
|
||||
|
||||
// Replaces all occurrences of function, regexp, date, map and set placeholders in the
|
||||
// JSON string with their string representations. If the original value can
|
||||
// not be found, then `undefined` is used.
|
||||
return str.replace(PLACE_HOLDER_REGEXP, function (match, type, valueIndex) {
|
||||
return str.replace(PLACE_HOLDER_REGEXP, function (match, backSlash, type, valueIndex) {
|
||||
// The placeholder may not be preceded by a backslash. This is to prevent
|
||||
// replacing things like `"a\"@__R-<UID>-0__@"` and thus outputting
|
||||
// invalid JS.
|
||||
if (backSlash) {
|
||||
return match;
|
||||
}
|
||||
|
||||
if (type === 'D') {
|
||||
return "new Date(\"" + dates[valueIndex].toISOString() + "\")";
|
||||
}
|
||||
@@ -203,6 +232,14 @@ module.exports = function serialize(obj, options) {
|
||||
return 'undefined'
|
||||
}
|
||||
|
||||
if (type === 'I') {
|
||||
return infinities[valueIndex];
|
||||
}
|
||||
|
||||
if (type === 'B') {
|
||||
return "BigInt(\"" + bigInts[valueIndex] + "\")";
|
||||
}
|
||||
|
||||
var fn = functions[valueIndex];
|
||||
|
||||
return serializeFunc(fn);
|
||||
|
||||
27
conf/site/node_modules/serialize-javascript/package.json
generated
vendored
27
conf/site/node_modules/serialize-javascript/package.json
generated
vendored
@@ -1,33 +1,33 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"serialize-javascript@2.1.2",
|
||||
"serialize-javascript@4.0.0",
|
||||
"/home/henry/Documents/git/Speedtest-tracker-docker/conf/site"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "serialize-javascript@2.1.2",
|
||||
"_id": "serialize-javascript@2.1.2",
|
||||
"_from": "serialize-javascript@4.0.0",
|
||||
"_id": "serialize-javascript@4.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==",
|
||||
"_integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
|
||||
"_location": "/serialize-javascript",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "serialize-javascript@2.1.2",
|
||||
"raw": "serialize-javascript@4.0.0",
|
||||
"name": "serialize-javascript",
|
||||
"escapedName": "serialize-javascript",
|
||||
"rawSpec": "2.1.2",
|
||||
"rawSpec": "4.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.1.2"
|
||||
"fetchSpec": "4.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/terser-webpack-plugin",
|
||||
"/webpack/terser-webpack-plugin"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz",
|
||||
"_spec": "2.1.2",
|
||||
"_resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz",
|
||||
"_spec": "4.0.0",
|
||||
"_where": "/home/henry/Documents/git/Speedtest-tracker-docker/conf/site",
|
||||
"author": {
|
||||
"name": "Eric Ferraiuolo",
|
||||
@@ -36,12 +36,15 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/yahoo/serialize-javascript/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"randombytes": "^2.1.0"
|
||||
},
|
||||
"description": "Serialize JavaScript to a superset of JSON that includes regular expressions and functions.",
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"chai": "^4.1.0",
|
||||
"mocha": "^6.2.0",
|
||||
"nyc": "^14.1.1"
|
||||
"mocha": "^7.0.0",
|
||||
"nyc": "^15.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/yahoo/serialize-javascript",
|
||||
"keywords": [
|
||||
@@ -62,5 +65,5 @@
|
||||
"benchmark": "node -v && node test/benchmark/serialize.js",
|
||||
"test": "nyc --reporter=lcov mocha test/unit"
|
||||
},
|
||||
"version": "2.1.2"
|
||||
"version": "4.0.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user