diff options
Diffstat (limited to 'tools/node_modules/eslint/node_modules/flatted')
7 files changed, 466 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/flatted/LICENSE b/tools/node_modules/eslint/node_modules/flatted/LICENSE new file mode 100644 index 0000000000..c8508305bd --- /dev/null +++ b/tools/node_modules/eslint/node_modules/flatted/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2018, Andrea Giammarchi, @WebReflection + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/tools/node_modules/eslint/node_modules/flatted/README.md b/tools/node_modules/eslint/node_modules/flatted/README.md new file mode 100644 index 0000000000..990144117e --- /dev/null +++ b/tools/node_modules/eslint/node_modules/flatted/README.md @@ -0,0 +1,52 @@ +# flatted + +![Downloads](https://img.shields.io/npm/dm/flatted.svg) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/flatted/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/flatted?branch=master) [![Build Status](https://travis-ci.org/WebReflection/flatted.svg?branch=master)](https://travis-ci.org/WebReflection/flatted) [![License: ISC](https://img.shields.io/badge/License-ISC-yellow.svg)](https://opensource.org/licenses/ISC) ![WebReflection status](https://offline.report/status/webreflection.svg) + +A super light (0.5K) and fast circular JSON parser, directly from the creator of [CircularJSON](https://github.com/WebReflection/circular-json/#circularjson). + +Usable via [CDN](https://unpkg.com/flatted) or as regular module. + +```js +// ESM +import {parse, stringify} from 'flatted/esm'; + +// CJS +const {parse, stringify} = require('flatted/cjs'); + +const a = [{}]; +a[0].a = a; +a.push(a); + +stringify(a); // [["1","0"],{"a":"0"}] +``` + +### New in V1: Exact same JSON API + + * Added a [reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Syntax) parameter to `.parse(string, reviver)` and revive your own objects. + * Added a [replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Syntax) and a `space` parameter to `.stringify(object, replacer, space)` for feature parity with JSON signature. + + +### Compatibility +All ECMAScript engines compatible with `Map`, `Set`, `Object.keys`, and `Array.prototype.reduce` will work, even if polyfilled. + + +### How does it work ? +While stringifying, all Objects, including Arrays, and strings, are flattened out and replaced as unique index. `*` + +Once parsed, all indexes will be replaced through the flattened collection. + +<sup><sub>`*` represented as string to avoid conflicts with numbers</sub></sup> + +```js +// logic example +var a = [{one: 1}, {two: '2'}]; +a[0].a = a; +// a is the main object, will be at index '0' +// {one: 1} is the second object, index '1' +// {two: '2'} the third, in '2', and it has a string +// which will be found at index '3' + +Flatted.stringify(a); +// [["1","2"],{"one":1,"a":"0"},{"two":"3"},"2"] +// a[one,two] {one: 1, a} {two: '2'} '2' +``` diff --git a/tools/node_modules/eslint/node_modules/flatted/cjs/index.js b/tools/node_modules/eslint/node_modules/flatted/cjs/index.js new file mode 100644 index 0000000000..f312b06fb6 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/flatted/cjs/index.js @@ -0,0 +1,116 @@ +var Flatted = (function (Primitive, primitive) { + + /*! + * ISC License + * + * Copyright (c) 2018, Andrea Giammarchi, @WebReflection + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + var Flatted = { + + parse: function parse(text, reviver) { + var input = JSON.parse(text, Primitives).map(primitives); + var value = input[0]; + var $ = reviver || noop; + var tmp = typeof value === 'object' && value ? + revive(input, new Set, value, $) : + value; + return $.call({'': tmp}, '', tmp); + }, + + stringify: function stringify(value, replacer, space) { + for (var + firstRun, + known = new Map, + input = [], + output = [], + $ = replacer && typeof replacer === typeof input ? + function (k, v) { + if (k === '' || -1 < replacer.indexOf(k)) return v; + } : + (replacer || noop), + i = +set(known, input, $.call({'': value}, '', value)), + replace = function (key, value) { + if (firstRun) { + firstRun = !firstRun; + return value; + // this was invoking twice each root object + // return i < 1 ? value : $.call(this, key, value); + } + var after = $.call(this, key, value); + switch (typeof after) { + case 'object': + if (after === null) return after; + case primitive: + return known.get(after) || set(known, input, after); + } + return after; + }; + i < input.length; i++ + ) { + firstRun = true; + output[i] = JSON.stringify(input[i], replace, space); + } + return '[' + output.join(',') + ']'; + } + + }; + + return Flatted; + + function noop(key, value) { + return value; + } + + function revive(input, parsed, output, $) { + return Object.keys(output).reduce( + function (output, key) { + var value = output[key]; + if (value instanceof Primitive) { + var tmp = input[value]; + if (typeof tmp === 'object' && !parsed.has(tmp)) { + parsed.add(tmp); + output[key] = $.call(output, key, revive(input, parsed, tmp, $)); + } else { + output[key] = $.call(output, key, tmp); + } + } else + output[key] = $.call(output, key, value); + return output; + }, + output + ); + } + + function set(known, input, value) { + var index = Primitive(input.push(value) - 1); + known.set(value, index); + return index; + } + + // the two kinds of primitives + // 1. the real one + // 2. the wrapped one + + function primitives(value) { + return value instanceof Primitive ? Primitive(value) : value; + } + + function Primitives(key, value) { + return typeof value === primitive ? new Primitive(value) : value; + } + +}(String, 'string')); +module.exports = Flatted; diff --git a/tools/node_modules/eslint/node_modules/flatted/esm/index.js b/tools/node_modules/eslint/node_modules/flatted/esm/index.js new file mode 100644 index 0000000000..b17bd564d9 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/flatted/esm/index.js @@ -0,0 +1,118 @@ +var Flatted = (function (Primitive, primitive) { + + /*! + * ISC License + * + * Copyright (c) 2018, Andrea Giammarchi, @WebReflection + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + var Flatted = { + + parse: function parse(text, reviver) { + var input = JSON.parse(text, Primitives).map(primitives); + var value = input[0]; + var $ = reviver || noop; + var tmp = typeof value === 'object' && value ? + revive(input, new Set, value, $) : + value; + return $.call({'': tmp}, '', tmp); + }, + + stringify: function stringify(value, replacer, space) { + for (var + firstRun, + known = new Map, + input = [], + output = [], + $ = replacer && typeof replacer === typeof input ? + function (k, v) { + if (k === '' || -1 < replacer.indexOf(k)) return v; + } : + (replacer || noop), + i = +set(known, input, $.call({'': value}, '', value)), + replace = function (key, value) { + if (firstRun) { + firstRun = !firstRun; + return value; + // this was invoking twice each root object + // return i < 1 ? value : $.call(this, key, value); + } + var after = $.call(this, key, value); + switch (typeof after) { + case 'object': + if (after === null) return after; + case primitive: + return known.get(after) || set(known, input, after); + } + return after; + }; + i < input.length; i++ + ) { + firstRun = true; + output[i] = JSON.stringify(input[i], replace, space); + } + return '[' + output.join(',') + ']'; + } + + }; + + return Flatted; + + function noop(key, value) { + return value; + } + + function revive(input, parsed, output, $) { + return Object.keys(output).reduce( + function (output, key) { + var value = output[key]; + if (value instanceof Primitive) { + var tmp = input[value]; + if (typeof tmp === 'object' && !parsed.has(tmp)) { + parsed.add(tmp); + output[key] = $.call(output, key, revive(input, parsed, tmp, $)); + } else { + output[key] = $.call(output, key, tmp); + } + } else + output[key] = $.call(output, key, value); + return output; + }, + output + ); + } + + function set(known, input, value) { + var index = Primitive(input.push(value) - 1); + known.set(value, index); + return index; + } + + // the two kinds of primitives + // 1. the real one + // 2. the wrapped one + + function primitives(value) { + return value instanceof Primitive ? Primitive(value) : value; + } + + function Primitives(key, value) { + return typeof value === primitive ? new Primitive(value) : value; + } + +}(String, 'string')); +export default Flatted; +export const parse = Flatted.parse; +export const stringify = Flatted.stringify; diff --git a/tools/node_modules/eslint/node_modules/flatted/index.js b/tools/node_modules/eslint/node_modules/flatted/index.js new file mode 100644 index 0000000000..1df9db3084 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/flatted/index.js @@ -0,0 +1,115 @@ +var Flatted = (function (Primitive, primitive) { + + /*! + * ISC License + * + * Copyright (c) 2018, Andrea Giammarchi, @WebReflection + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + var Flatted = { + + parse: function parse(text, reviver) { + var input = JSON.parse(text, Primitives).map(primitives); + var value = input[0]; + var $ = reviver || noop; + var tmp = typeof value === 'object' && value ? + revive(input, new Set, value, $) : + value; + return $.call({'': tmp}, '', tmp); + }, + + stringify: function stringify(value, replacer, space) { + for (var + firstRun, + known = new Map, + input = [], + output = [], + $ = replacer && typeof replacer === typeof input ? + function (k, v) { + if (k === '' || -1 < replacer.indexOf(k)) return v; + } : + (replacer || noop), + i = +set(known, input, $.call({'': value}, '', value)), + replace = function (key, value) { + if (firstRun) { + firstRun = !firstRun; + return value; + // this was invoking twice each root object + // return i < 1 ? value : $.call(this, key, value); + } + var after = $.call(this, key, value); + switch (typeof after) { + case 'object': + if (after === null) return after; + case primitive: + return known.get(after) || set(known, input, after); + } + return after; + }; + i < input.length; i++ + ) { + firstRun = true; + output[i] = JSON.stringify(input[i], replace, space); + } + return '[' + output.join(',') + ']'; + } + + }; + + return Flatted; + + function noop(key, value) { + return value; + } + + function revive(input, parsed, output, $) { + return Object.keys(output).reduce( + function (output, key) { + var value = output[key]; + if (value instanceof Primitive) { + var tmp = input[value]; + if (typeof tmp === 'object' && !parsed.has(tmp)) { + parsed.add(tmp); + output[key] = $.call(output, key, revive(input, parsed, tmp, $)); + } else { + output[key] = $.call(output, key, tmp); + } + } else + output[key] = $.call(output, key, value); + return output; + }, + output + ); + } + + function set(known, input, value) { + var index = Primitive(input.push(value) - 1); + known.set(value, index); + return index; + } + + // the two kinds of primitives + // 1. the real one + // 2. the wrapped one + + function primitives(value) { + return value instanceof Primitive ? Primitive(value) : value; + } + + function Primitives(key, value) { + return typeof value === primitive ? new Primitive(value) : value; + } + +}(String, 'string')); diff --git a/tools/node_modules/eslint/node_modules/flatted/min.js b/tools/node_modules/eslint/node_modules/flatted/min.js new file mode 100644 index 0000000000..6d23e02e15 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/flatted/min.js @@ -0,0 +1,2 @@ +/*! (c) 2018, Andrea Giammarchi, (ISC) */ +var Flatted=function(a,l){return{parse:function(n,t){var e=JSON.parse(n,i).map(f),r=e[0],u=t||s,c="object"==typeof r&&r?function u(c,f,n,i){return Object.keys(n).reduce(function(n,t){var e=n[t];if(e instanceof a){var r=c[e];"object"!=typeof r||f.has(r)?n[t]=i.call(n,t,r):(f.add(r),n[t]=i.call(n,t,u(c,f,r,i)))}else n[t]=i.call(n,t,e);return n},n)}(e,new Set,r,u):r;return u.call({"":c},"",c)},stringify:function(n,e,t){for(var r,u=new Map,c=[],f=[],i=e&&typeof e==typeof c?function(n,t){if(""===n||-1<e.indexOf(n))return t}:e||s,a=+p(u,c,i.call({"":n},"",n)),o=function(n,t){if(r)return r=!r,t;var e=i.call(this,n,t);switch(typeof e){case"object":if(null===e)return e;case l:return u.get(e)||p(u,c,e)}return e};a<c.length;a++)r=!0,f[a]=JSON.stringify(c[a],o,t);return"["+f.join(",")+"]"}};function s(n,t){return t}function p(n,t,e){var r=a(t.push(e)-1);return n.set(e,r),r}function f(n){return n instanceof a?a(n):n}function i(n,t){return typeof t===l?new a(t):t}}(String,"string"); diff --git a/tools/node_modules/eslint/node_modules/flatted/package.json b/tools/node_modules/eslint/node_modules/flatted/package.json new file mode 100644 index 0000000000..2f93f37af7 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/flatted/package.json @@ -0,0 +1,48 @@ +{ + "author": { + "name": "Andrea Giammarchi" + }, + "bugs": { + "url": "https://github.com/WebReflection/flatted/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "A super light and fast circular JSON parser.", + "devDependencies": { + "circular-json": "latest", + "circular-json-es6": "latest", + "coveralls": "latest", + "istanbul": "latest", + "jsan": "latest", + "uglify-js": "latest" + }, + "homepage": "https://github.com/WebReflection/flatted#readme", + "keywords": [ + "circular", + "JSON", + "fast", + "parser", + "minimal" + ], + "license": "ISC", + "main": "cjs/index.js", + "module": "esm/index.js", + "name": "flatted", + "repository": { + "type": "git", + "url": "git+https://github.com/WebReflection/flatted.git" + }, + "scripts": { + "bench": "node test/bench.js", + "build": "npm run cjs && npm test && npm run esm && npm run min && npm run size", + "cjs": "cp index.js cjs/index.js; echo 'module.exports = Flatted;' >> cjs/index.js", + "coveralls": "cat ./coverage/lcov.info | coveralls", + "esm": "cp index.js esm/index.js; echo 'export default Flatted;' >> esm/index.js; echo 'export const parse = Flatted.parse;' >> esm/index.js; echo 'export const stringify = Flatted.stringify;' >> esm/index.js", + "min": "echo '/*! (c) 2018, Andrea Giammarchi, (ISC) */'>min.js && uglifyjs index.js --support-ie8 -c -m >> min.js", + "size": "cat index.js | wc -c;cat min.js | wc -c;gzip -c9 min.js | wc -c;cat min.js | brotli | wc -c", + "test": "istanbul cover test/index.js" + }, + "types": "types.d.ts", + "unpkg": "min.js", + "version": "2.0.0" +}
\ No newline at end of file |