flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
20
BACK_BACK/node_modules/serialize-to-js/LICENSE
generated
vendored
Executable file
20
BACK_BACK/node_modules/serialize-to-js/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016-present commenthol
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
111
BACK_BACK/node_modules/serialize-to-js/README.md
generated
vendored
Executable file
111
BACK_BACK/node_modules/serialize-to-js/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,111 @@
|
|||
# serialize-to-js
|
||||
|
||||
> serialize objects to javascript
|
||||
|
||||
[](https://www.npmjs.com/package/serialize-to-js/)
|
||||
[](https://github.com/commenthol/serialize-to-js/actions/workflows/ci.yml?query=branch%3Amaster)
|
||||
|
||||
|
||||
Serialize objects into a string while checking circular structures and respecting references.
|
||||
|
||||
The following Objects are supported
|
||||
|
||||
- String
|
||||
- Number
|
||||
- Boolean
|
||||
- Object
|
||||
- Array
|
||||
- RegExp
|
||||
- Error
|
||||
- Date
|
||||
- Buffer
|
||||
- Int8Array, Uint8Array, Uint8ClampedArray
|
||||
- Int16Array, Uint16Array
|
||||
- Int32Array, Uint32Array, Float32Array
|
||||
- Float64Array
|
||||
- Set
|
||||
- Map
|
||||
|
||||
## Table of Contents
|
||||
|
||||
<!-- !toc (minlevel=2 omit="Table of Contents") -->
|
||||
|
||||
* [Methods](#methods)
|
||||
* [serialize](#serialize)
|
||||
* [Contribution and License Agreement](#contribution-and-license-agreement)
|
||||
* [License](#license)
|
||||
|
||||
<!-- toc! -->
|
||||
|
||||
## Methods
|
||||
|
||||
### serialize
|
||||
|
||||
`serialize(source, opts, opts.ignoreCircular, opts.reference)`
|
||||
|
||||
serializes an object to javascript
|
||||
|
||||
#### Example - serializing regex, date, buffer, ...
|
||||
|
||||
```js
|
||||
const serialize = require('serialize-to-js')
|
||||
const obj = {
|
||||
str: '<script>var a = 0 > 1</script>',
|
||||
num: 3.1415,
|
||||
bool: true,
|
||||
nil: null,
|
||||
undef: undefined,
|
||||
obj: { foo: 'bar' },
|
||||
arr: [1, '2'],
|
||||
regexp: /^test?$/,
|
||||
date: new Date(),
|
||||
buffer: new Buffer('data'),
|
||||
set: new Set([1, 2, 3]),
|
||||
map: new Map([['a': 1],['b': 2]])
|
||||
}
|
||||
console.log(serialize(obj))
|
||||
//> '{str: "\u003Cscript\u003Evar a = 0 \u003E 1\u003C\u002Fscript\u003E",
|
||||
//> num: 3.1415, bool: true, nil: null, undef: undefined,
|
||||
//> obj: {foo: "bar"}, arr: [1, "2"], regexp: new RegExp("^test?$", ""),
|
||||
//> date: new Date("2019-12-29T10:37:36.613Z"),
|
||||
//> buffer: Buffer.from("ZGF0YQ==", "base64"), set: new Set([1, 2, 3]),
|
||||
//> map: new Map([["a", 1], ["b", 2]])}'
|
||||
```
|
||||
|
||||
#### Example - serializing while respecting references
|
||||
|
||||
```js
|
||||
var serialize = require('serialize-to-js')
|
||||
var obj = { object: { regexp: /^test?$/ } };
|
||||
obj.reference = obj.object;
|
||||
var opts = { reference: true };
|
||||
console.log(serialize(obj, opts));
|
||||
//> {object: {regexp: /^test?$/}}
|
||||
console.log(opts.references);
|
||||
//> [ [ '.reference', '.object' ] ]
|
||||
```
|
||||
|
||||
**Parameters**
|
||||
|
||||
**source**: `Object | Array | function | Any`, source to serialize
|
||||
**opts**: `Object`, options
|
||||
**opts.ignoreCircular**: `Boolean`, ignore circular objects
|
||||
**opts.reference**: `Boolean`, reference instead of a copy (requires post-processing of opts.references)
|
||||
**opts.unsafe**: `Boolean`, do not escape chars `<>/`
|
||||
**Returns**: `String`, serialized representation of `source`
|
||||
|
||||
|
||||
## Contribution and License Agreement
|
||||
|
||||
If you contribute code to this project, you are implicitly allowing your
|
||||
code to be distributed under the MIT license. You are also implicitly
|
||||
verifying that all code is your original work or correctly attributed
|
||||
with the source of its origin and licence.
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2016- commenthol (MIT License)
|
||||
|
||||
See [LICENSE][] for more info.
|
||||
|
||||
[LICENSE]: ./LICENSE
|
||||
216
BACK_BACK/node_modules/serialize-to-js/lib/index.js
generated
vendored
Executable file
216
BACK_BACK/node_modules/serialize-to-js/lib/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
* @copyright 2016- commenthol
|
||||
* @license MIT
|
||||
*/
|
||||
'use strict'; // dependencies
|
||||
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
var utils = require('./internal/utils');
|
||||
|
||||
var Ref = require('./internal/reference');
|
||||
/**
|
||||
* serializes an object to javascript
|
||||
*
|
||||
* @example <caption>serializing regex, date, buffer, ...</caption>
|
||||
* const serialize = require('serialize-to-js')
|
||||
* const obj = {
|
||||
* str: '<script>var a = 0 > 1</script>',
|
||||
* num: 3.1415,
|
||||
* bool: true,
|
||||
* nil: null,
|
||||
* undef: undefined,
|
||||
* obj: { foo: 'bar' },
|
||||
* arr: [1, '2'],
|
||||
* regexp: /^test?$/,
|
||||
* date: new Date(),
|
||||
* buffer: new Buffer('data'),
|
||||
* set: new Set([1, 2, 3]),
|
||||
* map: new Map([['a': 1],['b': 2]])
|
||||
* }
|
||||
* console.log(serialize(obj))
|
||||
* //> '{str: "\u003Cscript\u003Evar a = 0 \u003E 1\u003C\u002Fscript\u003E",
|
||||
* //> num: 3.1415, bool: true, nil: null, undef: undefined,
|
||||
* //> obj: {foo: "bar"}, arr: [1, "2"], regexp: new RegExp("^test?$", ""),
|
||||
* //> date: new Date("2019-12-29T10:37:36.613Z"),
|
||||
* //> buffer: Buffer.from("ZGF0YQ==", "base64"), set: new Set([1, 2, 3]),
|
||||
* //> map: new Map([["a", 1], ["b", 2]])}'
|
||||
*
|
||||
* @example <caption>serializing while respecting references</caption>
|
||||
* const serialize = require('serialize-to-js')
|
||||
* const obj = { object: { regexp: /^test?$/ } };
|
||||
* obj.reference = obj.object;
|
||||
* const opts = { reference: true };
|
||||
* console.log(serialize(obj, opts));
|
||||
* //> {object: {regexp: /^test?$/}}
|
||||
* console.log(opts.references);
|
||||
* //> [ [ '.reference', '.object' ] ]
|
||||
*
|
||||
* @param {Object|Array|Function|Any} source - source to serialize
|
||||
* @param {Object} [opts] - options
|
||||
* @param {Boolean} opts.ignoreCircular - ignore circular objects
|
||||
* @param {Boolean} opts.reference - reference instead of a copy (requires post-processing of opts.references)
|
||||
* @param {Boolean} opts.unsafe - do not escape chars `<>/`
|
||||
* @return {String} serialized representation of `source`
|
||||
*/
|
||||
|
||||
|
||||
function serialize(source) {
|
||||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
opts = opts || {};
|
||||
var visited = new Set();
|
||||
opts.references = [];
|
||||
var refs = new Ref(opts.references, opts);
|
||||
|
||||
function stringify(source, opts) {
|
||||
var type = utils.toType(source);
|
||||
|
||||
if (visited.has(source)) {
|
||||
if (opts.ignoreCircular) {
|
||||
switch (type) {
|
||||
case 'Array':
|
||||
return '[/*[Circular]*/]';
|
||||
|
||||
case 'Object':
|
||||
return '{/*[Circular]*/}';
|
||||
|
||||
default:
|
||||
return 'undefined /*[Circular]*/';
|
||||
}
|
||||
} else {
|
||||
throw new Error('can not convert circular structures.');
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'Null':
|
||||
return 'null';
|
||||
|
||||
case 'String':
|
||||
return utils.quote(source, opts) || '""';
|
||||
|
||||
case 'Function':
|
||||
{
|
||||
var _tmp = source.toString();
|
||||
|
||||
var tmp = opts.unsafe ? _tmp : utils.saferFunctionString(_tmp, opts); // append function to es6 function within obj
|
||||
|
||||
return !/^\s*(function|\([^)]*?\)\s*=>)/m.test(tmp) ? 'function ' + tmp : tmp;
|
||||
}
|
||||
|
||||
case 'RegExp':
|
||||
return "new RegExp(".concat(utils.quote(source.source, opts), ", \"").concat(source.flags, "\")");
|
||||
|
||||
case 'Date':
|
||||
if (utils.isInvalidDate(source)) return 'new Date("Invalid Date")';
|
||||
return "new Date(".concat(utils.quote(source.toJSON(), opts), ")");
|
||||
|
||||
case 'Error':
|
||||
return "new Error(".concat(utils.quote(source.message, opts), ")");
|
||||
|
||||
case 'Buffer':
|
||||
return "Buffer.from(\"".concat(source.toString('base64'), "\", \"base64\")");
|
||||
|
||||
case 'Array':
|
||||
{
|
||||
visited.add(source);
|
||||
|
||||
var _tmp2 = source.map(function (item) {
|
||||
return stringify(item, opts);
|
||||
});
|
||||
|
||||
visited["delete"](source);
|
||||
return "[".concat(_tmp2.join(', '), "]");
|
||||
}
|
||||
|
||||
case 'Int8Array':
|
||||
case 'Uint8Array':
|
||||
case 'Uint8ClampedArray':
|
||||
case 'Int16Array':
|
||||
case 'Uint16Array':
|
||||
case 'Int32Array':
|
||||
case 'Uint32Array':
|
||||
case 'Float32Array':
|
||||
case 'Float64Array':
|
||||
{
|
||||
var _tmp3 = [];
|
||||
|
||||
for (var i = 0; i < source.length; i++) {
|
||||
_tmp3.push(source[i]);
|
||||
}
|
||||
|
||||
return "new ".concat(type, "([").concat(_tmp3.join(', '), "])");
|
||||
}
|
||||
|
||||
case 'Set':
|
||||
{
|
||||
visited.add(source);
|
||||
|
||||
var _tmp4 = Array.from(source).map(function (item) {
|
||||
return stringify(item, opts);
|
||||
});
|
||||
|
||||
visited["delete"](source);
|
||||
return "new ".concat(type, "([").concat(_tmp4.join(', '), "])");
|
||||
}
|
||||
|
||||
case 'Map':
|
||||
{
|
||||
visited.add(source);
|
||||
|
||||
var _tmp5 = Array.from(source).map(function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 2),
|
||||
key = _ref2[0],
|
||||
value = _ref2[1];
|
||||
|
||||
return "[".concat(stringify(key, opts), ", ").concat(stringify(value, opts), "]");
|
||||
});
|
||||
|
||||
visited["delete"](source);
|
||||
return "new ".concat(type, "([").concat(_tmp5.join(', '), "])");
|
||||
}
|
||||
|
||||
case 'Object':
|
||||
{
|
||||
visited.add(source);
|
||||
var _tmp6 = [];
|
||||
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
if (opts.reference && utils.isObject(source[key])) {
|
||||
refs.push(key);
|
||||
|
||||
if (!refs.hasReference(source[key])) {
|
||||
_tmp6.push(Ref.wrapkey(key, opts) + ': ' + stringify(source[key], opts));
|
||||
}
|
||||
|
||||
refs.pop();
|
||||
} else {
|
||||
_tmp6.push(Ref.wrapkey(key, opts) + ': ' + stringify(source[key], opts));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visited["delete"](source);
|
||||
return "{".concat(_tmp6.join(', '), "}");
|
||||
}
|
||||
|
||||
default:
|
||||
return '' + source;
|
||||
}
|
||||
}
|
||||
|
||||
return stringify(source, opts);
|
||||
}
|
||||
|
||||
module.exports = serialize;
|
||||
101
BACK_BACK/node_modules/serialize-to-js/lib/internal/reference.js
generated
vendored
Executable file
101
BACK_BACK/node_modules/serialize-to-js/lib/internal/reference.js
generated
vendored
Executable file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* @copyright 2015- commenthol
|
||||
* @license MIT
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
var KEY = /^[a-zA-Z$_][a-zA-Z$_0-9]*$/;
|
||||
/**
|
||||
* handle references
|
||||
* @constructor
|
||||
* @param {Object} references
|
||||
* @param {boolean} opts.unsafe
|
||||
*/
|
||||
|
||||
function Ref(references, opts) {
|
||||
this.keys = [];
|
||||
this.refs = [];
|
||||
this.key = [];
|
||||
this.references = references || [];
|
||||
this._opts = opts || {};
|
||||
}
|
||||
/**
|
||||
* wrap an object key
|
||||
* @api private
|
||||
* @param {String} key - objects key
|
||||
* @return {String} wrapped key in quotes if necessary
|
||||
*/
|
||||
|
||||
|
||||
Ref.wrapkey = function (key, opts) {
|
||||
return KEY.test(key) ? key : utils.quote(key, opts);
|
||||
};
|
||||
|
||||
Ref.prototype = {
|
||||
/**
|
||||
* push `key` to interal array
|
||||
* @param {String} key
|
||||
*/
|
||||
push: function push(key) {
|
||||
this.key.push(key);
|
||||
},
|
||||
|
||||
/**
|
||||
* remove the last key from internal array
|
||||
*/
|
||||
pop: function pop() {
|
||||
this.key.pop();
|
||||
},
|
||||
|
||||
/**
|
||||
* join the keys
|
||||
*/
|
||||
join: function join(key) {
|
||||
var _this = this;
|
||||
|
||||
var out = '';
|
||||
key = key || this.key;
|
||||
|
||||
if (typeof key === 'string') {
|
||||
key = [key];
|
||||
}
|
||||
|
||||
key.forEach(function (k) {
|
||||
if (KEY.test(k)) {
|
||||
out += '.' + k;
|
||||
} else {
|
||||
out += '[' + Ref.wrapkey(k, _this._opts) + ']';
|
||||
}
|
||||
});
|
||||
return out;
|
||||
},
|
||||
|
||||
/**
|
||||
* check if object `source` has an already known reference.
|
||||
* If so then origin and source are stored in `opts.reference`
|
||||
* @param {Object} source - object to compare
|
||||
* @return {Boolean}
|
||||
*/
|
||||
hasReference: function hasReference(source) {
|
||||
var idx;
|
||||
|
||||
if (~(idx = this.refs.indexOf(source))) {
|
||||
this.references.push([this.join(), this.keys[idx]]);
|
||||
return true;
|
||||
} else {
|
||||
this.refs.push(source);
|
||||
this.keys.push(this.join());
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* get the references array
|
||||
* @return {Array} references array
|
||||
*/
|
||||
getReferences: function getReferences() {
|
||||
return this.references;
|
||||
}
|
||||
};
|
||||
module.exports = Ref;
|
||||
74
BACK_BACK/node_modules/serialize-to-js/lib/internal/utils.js
generated
vendored
Executable file
74
BACK_BACK/node_modules/serialize-to-js/lib/internal/utils.js
generated
vendored
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
'use strict';
|
||||
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
||||
|
||||
var UNSAFE_CHARS_REGEXP = /[<>\u2028\u2029/\\\r\n\t"]/g;
|
||||
var CHARS_REGEXP = /[\\\r\n\t"]/g;
|
||||
var UNICODE_CHARS = {
|
||||
'"': '\\"',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\t': '\\t',
|
||||
'\\': "\\u005C",
|
||||
'<': "\\u003C",
|
||||
'>': "\\u003E",
|
||||
'/': "\\u002F",
|
||||
"\u2028": "\\u2028",
|
||||
"\u2029": "\\u2029"
|
||||
};
|
||||
|
||||
function safeString(str) {
|
||||
return str.replace(UNSAFE_CHARS_REGEXP, function (unsafeChar) {
|
||||
return UNICODE_CHARS[unsafeChar];
|
||||
});
|
||||
}
|
||||
|
||||
function unsafeString(str) {
|
||||
str = str.replace(CHARS_REGEXP, function (unsafeChar) {
|
||||
return UNICODE_CHARS[unsafeChar];
|
||||
});
|
||||
return str;
|
||||
}
|
||||
|
||||
function quote(str, opts) {
|
||||
var fn = opts.unsafe ? unsafeString : safeString;
|
||||
return str ? "\"".concat(fn(str), "\"") : '';
|
||||
}
|
||||
|
||||
function saferFunctionString(str, opts) {
|
||||
return opts.unsafe ? str : str.replace(/(<\/?)([a-z][^>]*?>)/ig, function (m, m1, m2) {
|
||||
return safeString(m1) + m2;
|
||||
});
|
||||
}
|
||||
|
||||
function isObject(arg) {
|
||||
return _typeof(arg) === 'object' && arg !== null;
|
||||
}
|
||||
|
||||
function isBuffer(arg) {
|
||||
return arg instanceof Buffer;
|
||||
}
|
||||
|
||||
function isInvalidDate(arg) {
|
||||
return isNaN(arg.getTime());
|
||||
}
|
||||
|
||||
function toType(o) {
|
||||
var _type = Object.prototype.toString.call(o);
|
||||
|
||||
var type = _type.substring(8, _type.length - 1);
|
||||
|
||||
if (type === 'Uint8Array' && isBuffer(o)) return 'Buffer';
|
||||
return type;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
safeString: safeString,
|
||||
unsafeString: unsafeString,
|
||||
quote: quote,
|
||||
saferFunctionString: saferFunctionString,
|
||||
isBuffer: isBuffer,
|
||||
isObject: isObject,
|
||||
isInvalidDate: isInvalidDate,
|
||||
toType: toType
|
||||
};
|
||||
80
BACK_BACK/node_modules/serialize-to-js/package.json
generated
vendored
Executable file
80
BACK_BACK/node_modules/serialize-to-js/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,80 @@
|
|||
{
|
||||
"name": "serialize-to-js",
|
||||
"version": "3.1.2",
|
||||
"description": "serialize objects to javascript",
|
||||
"keywords": [
|
||||
"javascript",
|
||||
"objects",
|
||||
"serialize"
|
||||
],
|
||||
"homepage": "https://github.com/commenthol/serialize-to-js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/commenthol/serialize-to-js/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/commenthol/serialize-to-js.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "commenthol <commenthol@gmail.com>",
|
||||
"maintainers": "commenthol <commenthol@gmail.com>",
|
||||
"main": "lib",
|
||||
"module": "src",
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "test"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "babel -d lib src",
|
||||
"ci": "npm run clean && npm run lint && npm run build && npm test",
|
||||
"clean": "rimraf lib doc coverage .nyc_output *.tgz",
|
||||
"coverage": "nyc -r text -r html npm test",
|
||||
"lint": "eslint src test",
|
||||
"prepublishOnly": "npm run ci",
|
||||
"readme": "markedpp --githubid -i README.md -o README.md",
|
||||
"test": "mocha"
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
"@babel/preset-env"
|
||||
]
|
||||
},
|
||||
"eslintConfig": {
|
||||
"env": {
|
||||
"mocha": true
|
||||
},
|
||||
"plugins": [
|
||||
"standard"
|
||||
],
|
||||
"extends": "standard",
|
||||
"rules": {
|
||||
"key-spacing": 0,
|
||||
"no-console": 1
|
||||
}
|
||||
},
|
||||
"mocha": {
|
||||
"check-leaks": true
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.17.6",
|
||||
"@babel/core": "^7.17.8",
|
||||
"@babel/preset-env": "^7.16.11",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-standard": "^14.1.1",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.3.1",
|
||||
"eslint-plugin-standard": "^4.1.0",
|
||||
"mocha": "^9.2.2",
|
||||
"nyc": "^15.1.0",
|
||||
"rimraf": "^3.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
}
|
||||
161
BACK_BACK/node_modules/serialize-to-js/src/index.js
generated
vendored
Executable file
161
BACK_BACK/node_modules/serialize-to-js/src/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,161 @@
|
|||
/*
|
||||
* @copyright 2016- commenthol
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
// dependencies
|
||||
const utils = require('./internal/utils')
|
||||
const Ref = require('./internal/reference')
|
||||
|
||||
/**
|
||||
* serializes an object to javascript
|
||||
*
|
||||
* @example <caption>serializing regex, date, buffer, ...</caption>
|
||||
* const serialize = require('serialize-to-js')
|
||||
* const obj = {
|
||||
* str: '<script>var a = 0 > 1</script>',
|
||||
* num: 3.1415,
|
||||
* bool: true,
|
||||
* nil: null,
|
||||
* undef: undefined,
|
||||
* obj: { foo: 'bar' },
|
||||
* arr: [1, '2'],
|
||||
* regexp: /^test?$/,
|
||||
* date: new Date(),
|
||||
* buffer: new Buffer('data'),
|
||||
* set: new Set([1, 2, 3]),
|
||||
* map: new Map([['a': 1],['b': 2]])
|
||||
* }
|
||||
* console.log(serialize(obj))
|
||||
* //> '{str: "\u003Cscript\u003Evar a = 0 \u003E 1\u003C\u002Fscript\u003E",
|
||||
* //> num: 3.1415, bool: true, nil: null, undef: undefined,
|
||||
* //> obj: {foo: "bar"}, arr: [1, "2"], regexp: new RegExp("^test?$", ""),
|
||||
* //> date: new Date("2019-12-29T10:37:36.613Z"),
|
||||
* //> buffer: Buffer.from("ZGF0YQ==", "base64"), set: new Set([1, 2, 3]),
|
||||
* //> map: new Map([["a", 1], ["b", 2]])}'
|
||||
*
|
||||
* @example <caption>serializing while respecting references</caption>
|
||||
* const serialize = require('serialize-to-js')
|
||||
* const obj = { object: { regexp: /^test?$/ } };
|
||||
* obj.reference = obj.object;
|
||||
* const opts = { reference: true };
|
||||
* console.log(serialize(obj, opts));
|
||||
* //> {object: {regexp: /^test?$/}}
|
||||
* console.log(opts.references);
|
||||
* //> [ [ '.reference', '.object' ] ]
|
||||
*
|
||||
* @param {Object|Array|Function|Any} source - source to serialize
|
||||
* @param {Object} [opts] - options
|
||||
* @param {Boolean} opts.ignoreCircular - ignore circular objects
|
||||
* @param {Boolean} opts.reference - reference instead of a copy (requires post-processing of opts.references)
|
||||
* @param {Boolean} opts.unsafe - do not escape chars `<>/`
|
||||
* @return {String} serialized representation of `source`
|
||||
*/
|
||||
function serialize (source, opts = {}) {
|
||||
opts = opts || {}
|
||||
|
||||
const visited = new Set()
|
||||
opts.references = []
|
||||
const refs = new Ref(opts.references, opts)
|
||||
|
||||
function stringify (source, opts) {
|
||||
const type = utils.toType(source)
|
||||
|
||||
if (visited.has(source)) {
|
||||
if (opts.ignoreCircular) {
|
||||
switch (type) {
|
||||
case 'Array':
|
||||
return '[/*[Circular]*/]'
|
||||
case 'Object':
|
||||
return '{/*[Circular]*/}'
|
||||
default:
|
||||
return 'undefined /*[Circular]*/'
|
||||
}
|
||||
} else {
|
||||
throw new Error('can not convert circular structures.')
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'Null':
|
||||
return 'null'
|
||||
case 'String':
|
||||
return utils.quote(source, opts) || '""'
|
||||
case 'Function': {
|
||||
const _tmp = source.toString()
|
||||
const tmp = opts.unsafe ? _tmp : utils.saferFunctionString(_tmp, opts)
|
||||
// append function to es6 function within obj
|
||||
return !/^\s*(function|\([^)]*?\)\s*=>)/m.test(tmp) ? 'function ' + tmp : tmp
|
||||
}
|
||||
case 'RegExp':
|
||||
return `new RegExp(${utils.quote(source.source, opts)}, "${source.flags}")`
|
||||
case 'Date':
|
||||
if (utils.isInvalidDate(source)) return 'new Date("Invalid Date")'
|
||||
return `new Date(${utils.quote(source.toJSON(), opts)})`
|
||||
case 'Error':
|
||||
return `new Error(${utils.quote(source.message, opts)})`
|
||||
case 'Buffer':
|
||||
return `Buffer.from("${source.toString('base64')}", "base64")`
|
||||
case 'Array': {
|
||||
visited.add(source)
|
||||
const tmp = source.map(item => stringify(item, opts))
|
||||
visited.delete(source)
|
||||
return `[${tmp.join(', ')}]`
|
||||
}
|
||||
case 'Int8Array':
|
||||
case 'Uint8Array':
|
||||
case 'Uint8ClampedArray':
|
||||
case 'Int16Array':
|
||||
case 'Uint16Array':
|
||||
case 'Int32Array':
|
||||
case 'Uint32Array':
|
||||
case 'Float32Array':
|
||||
case 'Float64Array': {
|
||||
const tmp = []
|
||||
for (let i = 0; i < source.length; i++) {
|
||||
tmp.push(source[i])
|
||||
}
|
||||
return `new ${type}([${tmp.join(', ')}])`
|
||||
}
|
||||
case 'Set': {
|
||||
visited.add(source)
|
||||
const tmp = Array.from(source).map(item => stringify(item, opts))
|
||||
visited.delete(source)
|
||||
return `new ${type}([${tmp.join(', ')}])`
|
||||
}
|
||||
case 'Map': {
|
||||
visited.add(source)
|
||||
const tmp = Array.from(source).map(([key, value]) => `[${stringify(key, opts)}, ${stringify(value, opts)}]`)
|
||||
visited.delete(source)
|
||||
return `new ${type}([${tmp.join(', ')}])`
|
||||
}
|
||||
case 'Object': {
|
||||
visited.add(source)
|
||||
const tmp = []
|
||||
for (const key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
if (opts.reference && utils.isObject(source[key])) {
|
||||
refs.push(key)
|
||||
if (!refs.hasReference(source[key])) {
|
||||
tmp.push(Ref.wrapkey(key, opts) + ': ' + stringify(source[key], opts))
|
||||
}
|
||||
refs.pop()
|
||||
} else {
|
||||
tmp.push(Ref.wrapkey(key, opts) + ': ' + stringify(source[key], opts))
|
||||
}
|
||||
}
|
||||
}
|
||||
visited.delete(source)
|
||||
return `{${tmp.join(', ')}}`
|
||||
}
|
||||
default:
|
||||
return '' + source
|
||||
}
|
||||
}
|
||||
|
||||
return stringify(source, opts)
|
||||
}
|
||||
|
||||
module.exports = serialize
|
||||
94
BACK_BACK/node_modules/serialize-to-js/src/internal/reference.js
generated
vendored
Executable file
94
BACK_BACK/node_modules/serialize-to-js/src/internal/reference.js
generated
vendored
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* @copyright 2015- commenthol
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const utils = require('./utils')
|
||||
|
||||
const KEY = /^[a-zA-Z$_][a-zA-Z$_0-9]*$/
|
||||
|
||||
/**
|
||||
* handle references
|
||||
* @constructor
|
||||
* @param {Object} references
|
||||
* @param {boolean} opts.unsafe
|
||||
*/
|
||||
function Ref (references, opts) {
|
||||
this.keys = []
|
||||
this.refs = []
|
||||
this.key = []
|
||||
this.references = references || []
|
||||
this._opts = opts || {}
|
||||
}
|
||||
|
||||
/**
|
||||
* wrap an object key
|
||||
* @api private
|
||||
* @param {String} key - objects key
|
||||
* @return {String} wrapped key in quotes if necessary
|
||||
*/
|
||||
Ref.wrapkey = function (key, opts) {
|
||||
return (KEY.test(key) ? key : utils.quote(key, opts))
|
||||
}
|
||||
|
||||
Ref.prototype = {
|
||||
/**
|
||||
* push `key` to interal array
|
||||
* @param {String} key
|
||||
*/
|
||||
push: function (key) {
|
||||
this.key.push(key)
|
||||
},
|
||||
/**
|
||||
* remove the last key from internal array
|
||||
*/
|
||||
pop: function () {
|
||||
this.key.pop()
|
||||
},
|
||||
/**
|
||||
* join the keys
|
||||
*/
|
||||
join: function (key) {
|
||||
let out = ''
|
||||
key = key || this.key
|
||||
if (typeof key === 'string') {
|
||||
key = [key]
|
||||
}
|
||||
|
||||
key.forEach(k => {
|
||||
if (KEY.test(k)) {
|
||||
out += '.' + k
|
||||
} else {
|
||||
out += '[' + Ref.wrapkey(k, this._opts) + ']'
|
||||
}
|
||||
})
|
||||
return out
|
||||
},
|
||||
/**
|
||||
* check if object `source` has an already known reference.
|
||||
* If so then origin and source are stored in `opts.reference`
|
||||
* @param {Object} source - object to compare
|
||||
* @return {Boolean}
|
||||
*/
|
||||
hasReference: function (source) {
|
||||
let idx
|
||||
if (~(idx = this.refs.indexOf(source))) {
|
||||
this.references.push([this.join(), this.keys[idx]])
|
||||
return true
|
||||
} else {
|
||||
this.refs.push(source)
|
||||
this.keys.push(this.join())
|
||||
}
|
||||
},
|
||||
/**
|
||||
* get the references array
|
||||
* @return {Array} references array
|
||||
*/
|
||||
getReferences: function () {
|
||||
return this.references
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Ref
|
||||
69
BACK_BACK/node_modules/serialize-to-js/src/internal/utils.js
generated
vendored
Executable file
69
BACK_BACK/node_modules/serialize-to-js/src/internal/utils.js
generated
vendored
Executable file
|
|
@ -0,0 +1,69 @@
|
|||
'use strict'
|
||||
|
||||
const UNSAFE_CHARS_REGEXP = /[<>\u2028\u2029/\\\r\n\t"]/g
|
||||
const CHARS_REGEXP = /[\\\r\n\t"]/g
|
||||
|
||||
const UNICODE_CHARS = {
|
||||
'"': '\\"',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\t': '\\t',
|
||||
'\\': '\\u005C',
|
||||
'<': '\\u003C',
|
||||
'>': '\\u003E',
|
||||
'/': '\\u002F',
|
||||
'\u2028': '\\u2028',
|
||||
'\u2029': '\\u2029'
|
||||
}
|
||||
|
||||
function safeString (str) {
|
||||
return str.replace(UNSAFE_CHARS_REGEXP, (unsafeChar) => {
|
||||
return UNICODE_CHARS[unsafeChar]
|
||||
})
|
||||
}
|
||||
|
||||
function unsafeString (str) {
|
||||
str = str.replace(CHARS_REGEXP, (unsafeChar) => UNICODE_CHARS[unsafeChar])
|
||||
return str
|
||||
}
|
||||
|
||||
function quote (str, opts) {
|
||||
const fn = opts.unsafe ? unsafeString : safeString
|
||||
return str ? `"${fn(str)}"` : ''
|
||||
}
|
||||
|
||||
function saferFunctionString (str, opts) {
|
||||
return opts.unsafe
|
||||
? str
|
||||
: str.replace(/(<\/?)([a-z][^>]*?>)/ig, (m, m1, m2) => safeString(m1) + m2)
|
||||
}
|
||||
|
||||
function isObject (arg) {
|
||||
return typeof arg === 'object' && arg !== null
|
||||
}
|
||||
|
||||
function isBuffer (arg) {
|
||||
return arg instanceof Buffer
|
||||
}
|
||||
|
||||
function isInvalidDate (arg) {
|
||||
return isNaN(arg.getTime())
|
||||
}
|
||||
|
||||
function toType (o) {
|
||||
const _type = Object.prototype.toString.call(o)
|
||||
const type = _type.substring(8, _type.length - 1)
|
||||
if (type === 'Uint8Array' && isBuffer(o)) return 'Buffer'
|
||||
return type
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
safeString,
|
||||
unsafeString,
|
||||
quote,
|
||||
saferFunctionString,
|
||||
isBuffer,
|
||||
isObject,
|
||||
isInvalidDate,
|
||||
toType
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue