feat: Created a mini nodeJS server with NewMan for testing without PostMan GUI.

This will mimic a run in a CD/CI environment or docker container.
This commit is contained in:
Simon Priet
2021-09-08 14:01:19 +02:00
parent 5fbd7c88fa
commit e69a613a37
5610 changed files with 740417 additions and 3 deletions

15
node_modules/teleport-javascript/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
ISC License
Copyright (c) 2019, Udit Vasu, @codenirvana
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.

71
node_modules/teleport-javascript/README.md generated vendored Normal file
View File

@@ -0,0 +1,71 @@
# teleport-javascript
[![Coverage Status](https://coveralls.io/repos/github/codenirvana/teleport-javascript/badge.svg?branch=master)](https://coveralls.io/github/codenirvana/teleport-javascript?branch=master) [![Build Status](https://travis-ci.org/codenirvana/teleport-javascript.svg?branch=master)](https://travis-ci.org/codenirvana/teleport-javascript) [![License: ISC](https://img.shields.io/badge/License-ISC-yellow.svg)](https://opensource.org/licenses/ISC) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
A super light and fast JavaScript object (de)serialization that includes Date, BigInt, RegExp, etc.
### Installation
```console
$ npm -i teleport-javascript
```
### Usage
```js
const {parse, stringify} = require('teleport-javascript');
const obj = {
key: 'value',
undefined: undefined,
regex: /a-z/gi,
set: new Set([-Infinity, NaN, Infinity]),
bigint: 900719925474099123n,
symbol: Symbol('key')
};
obj.circular = obj;
const stringified = stringify(obj);
// '[{"key":"1","undefined":"_0","regex":"_1","set":"_2","bigint":"_3","symbol":"_4","circular":"0"},"value",["u","R/a-z/gi","S[[\\"_0\\",\\"_1\\",\\"_2\\"],[\\"n-Infinity\\",\\"nNaN\\",\\"nInfinity\\"]]","b900719925474099123","skey"]]'
const parsed = parse(stringified);
// {
// key: 'value',
// undefined: undefined,
// regex: /a-z/gi,
// set: Set { -Infinity, NaN, Infinity },
// bigint: 900719925474099123n,
// symbol: Symbol(key),
// circular: [Circular]
// }
```
### Supported Data Types
* String
* Number _(including NaN, Infinity, -Infinity)_
* BigInt
* Boolean
* Symbol
* Null
* Undefined
* Array
- Int8Array
- Uint8Array
- Uint8ClampedArray
- Int16Array
- Uint16Array
- Int32Array
- Uint32Array
- Float32Array
- Float64Array
* Object _(including circular reference)_
- Date
- Buffer
- RegExp
- Map
- Set
### Benchmarks
[Benchmark Results](test/bench.txt)
## License
ISC

94
node_modules/teleport-javascript/SPECS.md generated vendored Normal file
View File

@@ -0,0 +1,94 @@
# Flatted Specifications
This document describes operations performed to produce, or parse, the flatted output.
## stringify(any) => flattedString
The output is always an `Array` that contains at index `0` the given value.
If the value is an `Array` or an `Object`, per each property value passed through the callback, return the value as is if it's not an `Array`, an `Object`, or a `string`.
In case it's an `Array`, an `Object`, or a `string`, return the index as `string`, associated through a `Map`.
Giving the following example:
```js
flatted.stringify('a'); // ["a"]
flatted.stringify(['a']); // [["1"],"a"]
flatted.stringify(['a', 1, 'b']); // [["1",1,"2"],"a","b"]
```
There is an `input` containing `[array, "a", "b"]`, where the `array` has indexes `"1"` and `"2"` as strings, indexes that point respectively at `"a"` and `"b"` within the input `[array, "a", "b"]`.
The exact same happens for objects.
```js
flatted.stringify('a'); // ["a"]
flatted.stringify({a: 'a'}); // [{"a":"1"},"a"]
flatted.stringify({a: 'a', n: 1, b: 'b'}); // [{"a":"1","n":1,"b":"2"},"a","b"]
```
Every object, string, or array, encountered during serialization will be stored once as stringified index.
```js
// per each property/value of the object/array
if (any == null || !/object|string/.test(typeof any))
return any;
if (!map.has(any)) {
const index = String(arr.length);
arr.push(any);
map.set(any, index);
}
return map.get(any);
```
This, performed before going through all properties, grants unique indexes per reference.
The stringified indexes ensure there won't be conflicts with regularly stored numbers.
## parse(flattedString) => any
Everything that is a `string` is wrapped as `new String`, but strings in the array, from index `1` on, is kept as regular `string`.
```js
const input = JSON.parse('[{"a":"1"},"b"]', Strings).map(strings);
// convert strings primitives into String instances
function Strings(key, value) {
return typeof value === 'string' ? new String(value) : value;
}
// converts String instances into strings primitives
function strings(value) {
return value instanceof String ? String(value) : value;
}
```
The `input` array will have a regular `string` at index `1`, but its object at index `0` will have an `instanceof String` as `.a` property.
That is the key to place back values from the rest of the array, so that per each property of the object at index `0`, if the value is an `instanceof` String, something not serializable via JSON, it means it can be used to retrieve the position of its value from the `input` array.
If such `value` is an object and it hasn't been parsed yet, add it as parsed and go through all its properties/values.
```js
// outside any loop ...
const parsed = new Set;
// ... per each property/value ...
if (value instanceof Primitive) {
const tmp = input[parseInt(value)];
if (typeof tmp === 'object' && !parsed.has(tmp)) {
parsed.add(tmp);
output[key] = tmp;
if (typeof tmp === 'object' && tmp != null) {
// perform this same logic per
// each nested property/value ...
}
} else {
output[key] = tmp;
}
} else
output[key] = tmp;
```
As summary, the whole logic is based on polluting the de-serialization with a kind of variable that is unexpected, hence secure to use as directive to retrieve an index with a value.
The usage of a `Map` and a `Set` to flag known references/strings as visited/stored makes **flatted** a rock solid, fast, and compact, solution.

293
node_modules/teleport-javascript/cjs/index.js generated vendored Normal file
View File

@@ -0,0 +1,293 @@
var TeleportJS = (function (Primitive, primitive) { // eslint-disable-line no-unused-vars
var REF_KEY_PREFIX = '_'
var SINGLE_REF = REF_KEY_PREFIX + '0'
var REF_PREFIX = {
undefined: 'u',
number: 'n',
bigint: 'b',
symbol: 's',
Map: 'M',
Set: 'S',
Date: 'D',
RegExp: 'R',
Buffer: 'B',
Int8Array: 'H',
Uint8Array: 'I',
Uint8ClampedArray: 'J',
Int16Array: 'P',
Uint16Array: 'Q',
Int32Array: 'F',
Uint32Array: 'G',
Float32Array: 'K',
Float64Array: 'L'
}
/*!
* ISC License
*
* Copyright (c) 2018, Andrea Giammarchi, @WebReflection
*/
var TeleportJS = {
parse: function parse (text, reviver) {
var input = JSON.parse(text, Primitives).map(primitives)
var len = input.length
var refs = len > 1 ? input[len - 1] : []
var value = input[0]
var $ = reviver || noop
var tmp = typeof value === 'object' && value
? revive(input, refs, new Set(), value, $)
: (value === SINGLE_REF && refs.length ? reviveRefs(refs, 0) : value)
return $.call({ '': tmp }, '', tmp)
},
stringify: function stringify (value, replacer, space) {
for (var
firstRun,
known = new Map(),
knownRefs = new Map(),
refs = [],
input = [],
output = [],
$ = replacer && typeof replacer === typeof input
? function (k, v) {
if (k === '' || replacer.indexOf(k) > -1) return v
}
: (replacer || noop),
i = +set(known, input, $.call({ '': value }, '', value)),
replace = function (key, value) {
var after = $.call(this, key, value)
var refIndex = setRefs(knownRefs, refs, key, after, this)
// bail out if value set via ref
if (refIndex) {
return refIndex
}
if (firstRun) {
firstRun = !firstRun
return value
// this was invoking twice each root object
// return i < 1 ? value : $.call(this, key, value);
}
switch (typeof after) {
case 'object':
if (after === null) return after
// eslint-disable-next-line no-fallthrough
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)
}
refs.length && output.push(JSON.stringify(refs))
return '[' + output.join(',') + ']'
}
}
return TeleportJS
function noop (key, value) {
return value
}
function reviveRefs (refs, index) {
var value = refs[index].substring(1)
switch (refs[index].charAt(0)) {
case REF_PREFIX.undefined:
refs[index] = undefined
break
case REF_PREFIX.number:
refs[index] = Number(value)
break
case REF_PREFIX.bigint:
refs[index] = BigInt(value)
break
case REF_PREFIX.symbol:
refs[index] = Symbol.for(value)
break
case REF_PREFIX.RegExp:
var parts = /\/(.*)\/(.*)/.exec(value)
refs[index] = new RegExp(parts[1], parts[2])
break
case REF_PREFIX.Buffer:
refs[index] = Buffer.from(JSON.parse(value))
break
case REF_PREFIX.Date:
refs[index] = new Date(value)
break
case REF_PREFIX.Map:
refs[index] = new Map(TeleportJS.parse(value))
break
case REF_PREFIX.Set:
refs[index] = new Set(TeleportJS.parse(value))
break
case REF_PREFIX.Int8Array:
refs[index] = new Int8Array(JSON.parse(value))
break
case REF_PREFIX.Uint8Array:
refs[index] = new Uint8Array(JSON.parse(value))
break
case REF_PREFIX.Uint8ClampedArray:
refs[index] = new Uint8ClampedArray(JSON.parse(value))
break
case REF_PREFIX.Int16Array:
refs[index] = new Int16Array(JSON.parse(value))
break
case REF_PREFIX.Uint16Array:
refs[index] = new Uint16Array(JSON.parse(value))
break
case REF_PREFIX.Int32Array:
refs[index] = new Int32Array(JSON.parse(value))
break
case REF_PREFIX.Uint32Array:
refs[index] = new Uint32Array(JSON.parse(value))
break
case REF_PREFIX.Float32Array:
refs[index] = new Float32Array(JSON.parse(value))
break
case REF_PREFIX.Float64Array:
refs[index] = new Float64Array(JSON.parse(value))
break
}
return refs[index]
}
function revive (input, refs, parsed, output, $) {
return Object.keys(output).reduce(
function (output, key) {
var value = output[key]
if (value instanceof Primitive) {
if (value.startsWith(REF_KEY_PREFIX)) {
var index = value.substring(1)
if (refs[index] instanceof Primitive) {
reviveRefs(refs, index)
}
output[key] = refs[index]
return output
}
var tmp = input[value]
if (typeof tmp === 'object' && !parsed.has(tmp)) {
parsed.add(tmp)
output[key] = $.call(output, key, revive(input, refs, 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
}
function setRefs (known, refs, key, value, obj) {
var after
var i
switch (typeof value) {
// case 'boolean': break
// case 'function': break
case 'string':
if (obj[key] instanceof Date) {
after = REF_PREFIX.Date + value
}
break
case 'undefined':
after = REF_PREFIX.undefined
break
case 'number':
if (!Number.isFinite(value)) {
after = REF_PREFIX.number + Primitive(value)
}
break
case 'bigint':
after = REF_PREFIX.bigint + Primitive(value)
break
case 'symbol':
var description = Primitive(value)
after = REF_PREFIX.symbol + description.substring(7, description.length - 1)
break
case 'object':
if (value === null) {
break
} else if (value.type === 'Buffer' && value.data && Buffer.isBuffer(obj[key])) {
after = REF_PREFIX.Buffer + JSON.stringify(value.data)
} else if (value instanceof RegExp) {
after = REF_PREFIX.RegExp + Primitive(value)
} else if (value instanceof Map) {
var m = []
for (i of value.entries()) m.push(i)
after = REF_PREFIX.Map + TeleportJS.stringify(m)
} else if (value instanceof Set) {
var s = []
for (i of value.values()) s.push(i)
after = REF_PREFIX.Set + TeleportJS.stringify(s)
} else if (value instanceof Int8Array) {
after = REF_PREFIX.Int8Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint8Array) {
after = REF_PREFIX.Uint8Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint8ClampedArray) {
after = REF_PREFIX.Uint8ClampedArray + JSON.stringify(Array.apply([], value))
} else if (value instanceof Int16Array) {
after = REF_PREFIX.Int16Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint16Array) {
after = REF_PREFIX.Uint16Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Int32Array) {
after = REF_PREFIX.Int32Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint32Array) {
after = REF_PREFIX.Uint32Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Float32Array) {
after = REF_PREFIX.Float32Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Float64Array) {
after = REF_PREFIX.Float64Array + JSON.stringify(Array.apply([], value))
}
break
}
if (!after) {
return
}
var index = known.get(after)
if (index) {
return index
}
index = REF_KEY_PREFIX + Primitive(refs.push(after) - 1)
known.set(after, 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) {
// eslint-disable-next-line valid-typeof
return typeof value === primitive ? new Primitive(value) : value
}
}(String, 'string'))
module.exports = TeleportJS

295
node_modules/teleport-javascript/esm/index.js generated vendored Normal file
View File

@@ -0,0 +1,295 @@
var TeleportJS = (function (Primitive, primitive) { // eslint-disable-line no-unused-vars
var REF_KEY_PREFIX = '_'
var SINGLE_REF = REF_KEY_PREFIX + '0'
var REF_PREFIX = {
undefined: 'u',
number: 'n',
bigint: 'b',
symbol: 's',
Map: 'M',
Set: 'S',
Date: 'D',
RegExp: 'R',
Buffer: 'B',
Int8Array: 'H',
Uint8Array: 'I',
Uint8ClampedArray: 'J',
Int16Array: 'P',
Uint16Array: 'Q',
Int32Array: 'F',
Uint32Array: 'G',
Float32Array: 'K',
Float64Array: 'L'
}
/*!
* ISC License
*
* Copyright (c) 2018, Andrea Giammarchi, @WebReflection
*/
var TeleportJS = {
parse: function parse (text, reviver) {
var input = JSON.parse(text, Primitives).map(primitives)
var len = input.length
var refs = len > 1 ? input[len - 1] : []
var value = input[0]
var $ = reviver || noop
var tmp = typeof value === 'object' && value
? revive(input, refs, new Set(), value, $)
: (value === SINGLE_REF && refs.length ? reviveRefs(refs, 0) : value)
return $.call({ '': tmp }, '', tmp)
},
stringify: function stringify (value, replacer, space) {
for (var
firstRun,
known = new Map(),
knownRefs = new Map(),
refs = [],
input = [],
output = [],
$ = replacer && typeof replacer === typeof input
? function (k, v) {
if (k === '' || replacer.indexOf(k) > -1) return v
}
: (replacer || noop),
i = +set(known, input, $.call({ '': value }, '', value)),
replace = function (key, value) {
var after = $.call(this, key, value)
var refIndex = setRefs(knownRefs, refs, key, after, this)
// bail out if value set via ref
if (refIndex) {
return refIndex
}
if (firstRun) {
firstRun = !firstRun
return value
// this was invoking twice each root object
// return i < 1 ? value : $.call(this, key, value);
}
switch (typeof after) {
case 'object':
if (after === null) return after
// eslint-disable-next-line no-fallthrough
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)
}
refs.length && output.push(JSON.stringify(refs))
return '[' + output.join(',') + ']'
}
}
return TeleportJS
function noop (key, value) {
return value
}
function reviveRefs (refs, index) {
var value = refs[index].substring(1)
switch (refs[index].charAt(0)) {
case REF_PREFIX.undefined:
refs[index] = undefined
break
case REF_PREFIX.number:
refs[index] = Number(value)
break
case REF_PREFIX.bigint:
refs[index] = BigInt(value)
break
case REF_PREFIX.symbol:
refs[index] = Symbol.for(value)
break
case REF_PREFIX.RegExp:
var parts = /\/(.*)\/(.*)/.exec(value)
refs[index] = new RegExp(parts[1], parts[2])
break
case REF_PREFIX.Buffer:
refs[index] = Buffer.from(JSON.parse(value))
break
case REF_PREFIX.Date:
refs[index] = new Date(value)
break
case REF_PREFIX.Map:
refs[index] = new Map(TeleportJS.parse(value))
break
case REF_PREFIX.Set:
refs[index] = new Set(TeleportJS.parse(value))
break
case REF_PREFIX.Int8Array:
refs[index] = new Int8Array(JSON.parse(value))
break
case REF_PREFIX.Uint8Array:
refs[index] = new Uint8Array(JSON.parse(value))
break
case REF_PREFIX.Uint8ClampedArray:
refs[index] = new Uint8ClampedArray(JSON.parse(value))
break
case REF_PREFIX.Int16Array:
refs[index] = new Int16Array(JSON.parse(value))
break
case REF_PREFIX.Uint16Array:
refs[index] = new Uint16Array(JSON.parse(value))
break
case REF_PREFIX.Int32Array:
refs[index] = new Int32Array(JSON.parse(value))
break
case REF_PREFIX.Uint32Array:
refs[index] = new Uint32Array(JSON.parse(value))
break
case REF_PREFIX.Float32Array:
refs[index] = new Float32Array(JSON.parse(value))
break
case REF_PREFIX.Float64Array:
refs[index] = new Float64Array(JSON.parse(value))
break
}
return refs[index]
}
function revive (input, refs, parsed, output, $) {
return Object.keys(output).reduce(
function (output, key) {
var value = output[key]
if (value instanceof Primitive) {
if (value.startsWith(REF_KEY_PREFIX)) {
var index = value.substring(1)
if (refs[index] instanceof Primitive) {
reviveRefs(refs, index)
}
output[key] = refs[index]
return output
}
var tmp = input[value]
if (typeof tmp === 'object' && !parsed.has(tmp)) {
parsed.add(tmp)
output[key] = $.call(output, key, revive(input, refs, 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
}
function setRefs (known, refs, key, value, obj) {
var after
var i
switch (typeof value) {
// case 'boolean': break
// case 'function': break
case 'string':
if (obj[key] instanceof Date) {
after = REF_PREFIX.Date + value
}
break
case 'undefined':
after = REF_PREFIX.undefined
break
case 'number':
if (!Number.isFinite(value)) {
after = REF_PREFIX.number + Primitive(value)
}
break
case 'bigint':
after = REF_PREFIX.bigint + Primitive(value)
break
case 'symbol':
var description = Primitive(value)
after = REF_PREFIX.symbol + description.substring(7, description.length - 1)
break
case 'object':
if (value === null) {
break
} else if (value.type === 'Buffer' && value.data && Buffer.isBuffer(obj[key])) {
after = REF_PREFIX.Buffer + JSON.stringify(value.data)
} else if (value instanceof RegExp) {
after = REF_PREFIX.RegExp + Primitive(value)
} else if (value instanceof Map) {
var m = []
for (i of value.entries()) m.push(i)
after = REF_PREFIX.Map + TeleportJS.stringify(m)
} else if (value instanceof Set) {
var s = []
for (i of value.values()) s.push(i)
after = REF_PREFIX.Set + TeleportJS.stringify(s)
} else if (value instanceof Int8Array) {
after = REF_PREFIX.Int8Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint8Array) {
after = REF_PREFIX.Uint8Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint8ClampedArray) {
after = REF_PREFIX.Uint8ClampedArray + JSON.stringify(Array.apply([], value))
} else if (value instanceof Int16Array) {
after = REF_PREFIX.Int16Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint16Array) {
after = REF_PREFIX.Uint16Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Int32Array) {
after = REF_PREFIX.Int32Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint32Array) {
after = REF_PREFIX.Uint32Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Float32Array) {
after = REF_PREFIX.Float32Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Float64Array) {
after = REF_PREFIX.Float64Array + JSON.stringify(Array.apply([], value))
}
break
}
if (!after) {
return
}
var index = known.get(after)
if (index) {
return index
}
index = REF_KEY_PREFIX + Primitive(refs.push(after) - 1)
known.set(after, 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) {
// eslint-disable-next-line valid-typeof
return typeof value === primitive ? new Primitive(value) : value
}
}(String, 'string'))
export default TeleportJS
export var parse = TeleportJS.parse
export var stringify = TeleportJS.stringify

292
node_modules/teleport-javascript/index.js generated vendored Normal file
View File

@@ -0,0 +1,292 @@
var TeleportJS = (function (Primitive, primitive) { // eslint-disable-line no-unused-vars
var REF_KEY_PREFIX = '_'
var SINGLE_REF = REF_KEY_PREFIX + '0'
var REF_PREFIX = {
undefined: 'u',
number: 'n',
bigint: 'b',
symbol: 's',
Map: 'M',
Set: 'S',
Date: 'D',
RegExp: 'R',
Buffer: 'B',
Int8Array: 'H',
Uint8Array: 'I',
Uint8ClampedArray: 'J',
Int16Array: 'P',
Uint16Array: 'Q',
Int32Array: 'F',
Uint32Array: 'G',
Float32Array: 'K',
Float64Array: 'L'
}
/*!
* ISC License
*
* Copyright (c) 2018, Andrea Giammarchi, @WebReflection
*/
var TeleportJS = {
parse: function parse (text, reviver) {
var input = JSON.parse(text, Primitives).map(primitives)
var len = input.length
var refs = len > 1 ? input[len - 1] : []
var value = input[0]
var $ = reviver || noop
var tmp = typeof value === 'object' && value
? revive(input, refs, new Set(), value, $)
: (value === SINGLE_REF && refs.length ? reviveRefs(refs, 0) : value)
return $.call({ '': tmp }, '', tmp)
},
stringify: function stringify (value, replacer, space) {
for (var
firstRun,
known = new Map(),
knownRefs = new Map(),
refs = [],
input = [],
output = [],
$ = replacer && typeof replacer === typeof input
? function (k, v) {
if (k === '' || replacer.indexOf(k) > -1) return v
}
: (replacer || noop),
i = +set(known, input, $.call({ '': value }, '', value)),
replace = function (key, value) {
var after = $.call(this, key, value)
var refIndex = setRefs(knownRefs, refs, key, after, this)
// bail out if value set via ref
if (refIndex) {
return refIndex
}
if (firstRun) {
firstRun = !firstRun
return value
// this was invoking twice each root object
// return i < 1 ? value : $.call(this, key, value);
}
switch (typeof after) {
case 'object':
if (after === null) return after
// eslint-disable-next-line no-fallthrough
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)
}
refs.length && output.push(JSON.stringify(refs))
return '[' + output.join(',') + ']'
}
}
return TeleportJS
function noop (key, value) {
return value
}
function reviveRefs (refs, index) {
var value = refs[index].substring(1)
switch (refs[index].charAt(0)) {
case REF_PREFIX.undefined:
refs[index] = undefined
break
case REF_PREFIX.number:
refs[index] = Number(value)
break
case REF_PREFIX.bigint:
refs[index] = BigInt(value)
break
case REF_PREFIX.symbol:
refs[index] = Symbol.for(value)
break
case REF_PREFIX.RegExp:
var parts = /\/(.*)\/(.*)/.exec(value)
refs[index] = new RegExp(parts[1], parts[2])
break
case REF_PREFIX.Buffer:
refs[index] = Buffer.from(JSON.parse(value))
break
case REF_PREFIX.Date:
refs[index] = new Date(value)
break
case REF_PREFIX.Map:
refs[index] = new Map(TeleportJS.parse(value))
break
case REF_PREFIX.Set:
refs[index] = new Set(TeleportJS.parse(value))
break
case REF_PREFIX.Int8Array:
refs[index] = new Int8Array(JSON.parse(value))
break
case REF_PREFIX.Uint8Array:
refs[index] = new Uint8Array(JSON.parse(value))
break
case REF_PREFIX.Uint8ClampedArray:
refs[index] = new Uint8ClampedArray(JSON.parse(value))
break
case REF_PREFIX.Int16Array:
refs[index] = new Int16Array(JSON.parse(value))
break
case REF_PREFIX.Uint16Array:
refs[index] = new Uint16Array(JSON.parse(value))
break
case REF_PREFIX.Int32Array:
refs[index] = new Int32Array(JSON.parse(value))
break
case REF_PREFIX.Uint32Array:
refs[index] = new Uint32Array(JSON.parse(value))
break
case REF_PREFIX.Float32Array:
refs[index] = new Float32Array(JSON.parse(value))
break
case REF_PREFIX.Float64Array:
refs[index] = new Float64Array(JSON.parse(value))
break
}
return refs[index]
}
function revive (input, refs, parsed, output, $) {
return Object.keys(output).reduce(
function (output, key) {
var value = output[key]
if (value instanceof Primitive) {
if (value.startsWith(REF_KEY_PREFIX)) {
var index = value.substring(1)
if (refs[index] instanceof Primitive) {
reviveRefs(refs, index)
}
output[key] = refs[index]
return output
}
var tmp = input[value]
if (typeof tmp === 'object' && !parsed.has(tmp)) {
parsed.add(tmp)
output[key] = $.call(output, key, revive(input, refs, 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
}
function setRefs (known, refs, key, value, obj) {
var after
var i
switch (typeof value) {
// case 'boolean': break
// case 'function': break
case 'string':
if (obj[key] instanceof Date) {
after = REF_PREFIX.Date + value
}
break
case 'undefined':
after = REF_PREFIX.undefined
break
case 'number':
if (!Number.isFinite(value)) {
after = REF_PREFIX.number + Primitive(value)
}
break
case 'bigint':
after = REF_PREFIX.bigint + Primitive(value)
break
case 'symbol':
var description = Primitive(value)
after = REF_PREFIX.symbol + description.substring(7, description.length - 1)
break
case 'object':
if (value === null) {
break
} else if (value.type === 'Buffer' && value.data && Buffer.isBuffer(obj[key])) {
after = REF_PREFIX.Buffer + JSON.stringify(value.data)
} else if (value instanceof RegExp) {
after = REF_PREFIX.RegExp + Primitive(value)
} else if (value instanceof Map) {
var m = []
for (i of value.entries()) m.push(i)
after = REF_PREFIX.Map + TeleportJS.stringify(m)
} else if (value instanceof Set) {
var s = []
for (i of value.values()) s.push(i)
after = REF_PREFIX.Set + TeleportJS.stringify(s)
} else if (value instanceof Int8Array) {
after = REF_PREFIX.Int8Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint8Array) {
after = REF_PREFIX.Uint8Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint8ClampedArray) {
after = REF_PREFIX.Uint8ClampedArray + JSON.stringify(Array.apply([], value))
} else if (value instanceof Int16Array) {
after = REF_PREFIX.Int16Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint16Array) {
after = REF_PREFIX.Uint16Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Int32Array) {
after = REF_PREFIX.Int32Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Uint32Array) {
after = REF_PREFIX.Uint32Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Float32Array) {
after = REF_PREFIX.Float32Array + JSON.stringify(Array.apply([], value))
} else if (value instanceof Float64Array) {
after = REF_PREFIX.Float64Array + JSON.stringify(Array.apply([], value))
}
break
}
if (!after) {
return
}
var index = known.get(after)
if (index) {
return index
}
index = REF_KEY_PREFIX + Primitive(refs.push(after) - 1)
known.set(after, 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) {
// eslint-disable-next-line valid-typeof
return typeof value === primitive ? new Primitive(value) : value
}
}(String, 'string'))

1
node_modules/teleport-javascript/min.js generated vendored Normal file
View File

@@ -0,0 +1 @@
var TeleportJS=function(r,e){var a="_",n=a+"0",t={undefined:"u",number:"n",bigint:"b",symbol:"s",Map:"M",Set:"S",Date:"D",RegExp:"R",Buffer:"B",Int8Array:"H",Uint8Array:"I",Uint8ClampedArray:"J",Int16Array:"P",Uint16Array:"Q",Int32Array:"F",Uint32Array:"G",Float32Array:"K",Float64Array:"L"},i={parse:function(e,t){var i=JSON.parse(e,o).map(c),f=i.length,p=f>1?i[f-1]:[],u=i[0],l=t||s,A="object"==typeof u&&u?function e(n,t,i,s,f){return Object.keys(s).reduce((function(s,c){var o=s[c];if(o instanceof r){if(o.startsWith(a)){var p=o.substring(1);return t[p]instanceof r&&y(t,p),s[c]=t[p],s}var u=n[o];"object"!=typeof u||i.has(u)?s[c]=f.call(s,c,u):(i.add(u),s[c]=f.call(s,c,e(n,t,i,u,f)))}else s[c]=f.call(s,c,o);return s}),s)}(i,p,new Set,u,l):u===n&&p.length?y(p,0):u;return l.call({"":A},"",A)},stringify:function(n,y,c){for(var o,p=new Map,u=new Map,l=[],A=[],b=[],g=y&&typeof y==typeof A?function(r,e){if(""===r||y.indexOf(r)>-1)return e}:y||s,S=+f(p,A,g.call({"":n},"",n)),J=function(n,s){var y=g.call(this,n,s),c=function(e,n,s,y,f){var c,o;switch(typeof y){case"string":f[s]instanceof Date&&(c=t.Date+y);break;case"undefined":c=t.undefined;break;case"number":Number.isFinite(y)||(c=t.number+r(y));break;case"bigint":c=t.bigint+r(y);break;case"symbol":var p=r(y);c=t.symbol+p.substring(7,p.length-1);break;case"object":if(null===y)break;if("Buffer"===y.type&&y.data&&Buffer.isBuffer(f[s]))c=t.Buffer+JSON.stringify(y.data);else if(y instanceof RegExp)c=t.RegExp+r(y);else if(y instanceof Map){var u=[];for(o of y.entries())u.push(o);c=t.Map+i.stringify(u)}else if(y instanceof Set){var l=[];for(o of y.values())l.push(o);c=t.Set+i.stringify(l)}else y instanceof Int8Array?c=t.Int8Array+JSON.stringify(Array.apply([],y)):y instanceof Uint8Array?c=t.Uint8Array+JSON.stringify(Array.apply([],y)):y instanceof Uint8ClampedArray?c=t.Uint8ClampedArray+JSON.stringify(Array.apply([],y)):y instanceof Int16Array?c=t.Int16Array+JSON.stringify(Array.apply([],y)):y instanceof Uint16Array?c=t.Uint16Array+JSON.stringify(Array.apply([],y)):y instanceof Int32Array?c=t.Int32Array+JSON.stringify(Array.apply([],y)):y instanceof Uint32Array?c=t.Uint32Array+JSON.stringify(Array.apply([],y)):y instanceof Float32Array?c=t.Float32Array+JSON.stringify(Array.apply([],y)):y instanceof Float64Array&&(c=t.Float64Array+JSON.stringify(Array.apply([],y)))}if(!c)return;var A=e.get(c);if(A)return A;return A=a+r(n.push(c)-1),e.set(c,A),A}(u,l,n,y,this);if(c)return c;if(o)return o=!o,s;switch(typeof y){case"object":if(null===y)return y;case e:return p.get(y)||f(p,A,y)}return y};S<A.length;S++)o=!0,b[S]=JSON.stringify(A[S],J,c);return l.length&&b.push(JSON.stringify(l)),"["+b.join(",")+"]"}};return i;function s(r,e){return e}function y(r,e){var a=r[e].substring(1);switch(r[e].charAt(0)){case t.undefined:r[e]=void 0;break;case t.number:r[e]=Number(a);break;case t.bigint:r[e]=BigInt(a);break;case t.symbol:r[e]=Symbol.for(a);break;case t.RegExp:var n=/\/(.*)\/(.*)/.exec(a);r[e]=new RegExp(n[1],n[2]);break;case t.Buffer:r[e]=Buffer.from(JSON.parse(a));break;case t.Date:r[e]=new Date(a);break;case t.Map:r[e]=new Map(i.parse(a));break;case t.Set:r[e]=new Set(i.parse(a));break;case t.Int8Array:r[e]=new Int8Array(JSON.parse(a));break;case t.Uint8Array:r[e]=new Uint8Array(JSON.parse(a));break;case t.Uint8ClampedArray:r[e]=new Uint8ClampedArray(JSON.parse(a));break;case t.Int16Array:r[e]=new Int16Array(JSON.parse(a));break;case t.Uint16Array:r[e]=new Uint16Array(JSON.parse(a));break;case t.Int32Array:r[e]=new Int32Array(JSON.parse(a));break;case t.Uint32Array:r[e]=new Uint32Array(JSON.parse(a));break;case t.Float32Array:r[e]=new Float32Array(JSON.parse(a));break;case t.Float64Array:r[e]=new Float64Array(JSON.parse(a))}return r[e]}function f(e,a,n){var t=r(a.push(n)-1);return e.set(n,t),t}function c(e){return e instanceof r?r(e):e}function o(a,n){return typeof n===e?new r(n):n}}(String,"string");

59
node_modules/teleport-javascript/package.json generated vendored Normal file
View File

@@ -0,0 +1,59 @@
{
"name": "teleport-javascript",
"version": "1.0.0",
"description": "A super light and fast JavaScript object (de)serialization that includes date, bigint, regex, etc.",
"unpkg": "min.js",
"main": "cjs/index.js",
"module": "esm/index.js",
"types": "types.d.ts",
"scripts": {
"bench": "node test/bench.js",
"build": "npm run cjs && npm test && npm run esm && npm run lint && npm run min && npm run size",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"cjs": "cp index.js cjs/index.js; echo 'module.exports = TeleportJS' >> cjs/index.js",
"esm": "cp index.js esm/index.js; echo 'export default TeleportJS' >> esm/index.js; echo 'export var parse = TeleportJS.parse' >> esm/index.js; echo 'export var stringify = TeleportJS.stringify' >> esm/index.js",
"lint": "standard index.js",
"min": "terser index.js -c -m --comments '/^$/' > 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"
},
"repository": {
"type": "git",
"url": "git+https://github.com/codenirvana/teleport-javascript.git"
},
"keywords": [
"JSON",
"circular",
"cyclic",
"stringify",
"parse",
"serialization",
"date",
"bigint"
],
"author": "Udit Vasu",
"license": "ISC",
"bugs": {
"url": "https://github.com/codenirvana/teleport-javascript/issues"
},
"homepage": "https://github.com/codenirvana/teleport-javascript#readme",
"devDependencies": {
"circular-json": "latest",
"circular-json-es6": "latest",
"coveralls": "latest",
"flatted": "latest",
"istanbul": "latest",
"jsan": "latest",
"standard": "latest",
"terser": "latest"
},
"standard": {
"globals": [
"BigInt"
],
"ignore": [
"test",
"min.js"
]
}
}

19
node_modules/teleport-javascript/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/**
* Fast and minimal circular JSON parser.
* logic example
```js
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'
TeleportJS.stringify(a);
// [["1","2"],{"one":1,"a":"0"},{"two":"3"},"2"]
// a[one,two] {one: 1, a} {two: '2'} '2'
```
*/
declare const TeleportJS: typeof JSON;
export = TeleportJS;