node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

154
server/node_modules/stream-json/Assembler.js generated vendored Normal file
View File

@@ -0,0 +1,154 @@
'use strict';
const EventEmitter = require('events');
const startObject = Ctr =>
function () {
if (this.done) {
this.done = false;
} else {
this.stack.push(this.current, this.key);
}
this.current = new Ctr();
this.key = null;
};
class Assembler extends EventEmitter {
static connectTo(stream, options) {
return new Assembler(options).connectTo(stream);
}
constructor(options) {
super();
this.stack = [];
this.current = this.key = null;
this.done = true;
if (options) {
this.reviver = typeof options.reviver == 'function' && options.reviver;
if (this.reviver) {
this.stringValue = this._saveValue = this._saveValueWithReviver;
}
if (options.numberAsString) {
this.numberValue = this.stringValue;
}
}
}
connectTo(stream) {
stream.on('data', chunk => {
if (this[chunk.name]) {
this[chunk.name](chunk.value);
if (this.done) this.emit('done', this);
}
});
return this;
}
get depth() {
return (this.stack.length >> 1) + (this.done ? 0 : 1);
}
get path() {
const path = [];
for (let i = 0; i < this.stack.length; i += 2) {
const key = this.stack[i + 1];
path.push(key === null ? this.stack[i].length : key);
}
return path;
}
dropToLevel(level) {
if (level < this.depth) {
if (level) {
const index = (level - 1) << 1;
this.current = this.stack[index];
this.key = this.stack[index + 1];
this.stack.splice(index);
} else {
this.stack = [];
this.current = this.key = null;
this.done = true;
}
}
return this;
}
consume(chunk) {
this[chunk.name] && this[chunk.name](chunk.value);
return this;
}
keyValue(value) {
this.key = value;
}
//stringValue() - aliased below to _saveValue()
numberValue(value) {
this._saveValue(parseFloat(value));
}
nullValue() {
this._saveValue(null);
}
trueValue() {
this._saveValue(true);
}
falseValue() {
this._saveValue(false);
}
//startObject() - assigned below
endObject() {
if (this.stack.length) {
const value = this.current;
this.key = this.stack.pop();
this.current = this.stack.pop();
this._saveValue(value);
} else {
this.done = true;
}
}
//startArray() - assigned below
//endArray() - aliased below to endObject()
_saveValue(value) {
if (this.done) {
this.current = value;
} else {
if (this.current instanceof Array) {
this.current.push(value);
} else {
this.current[this.key] = value;
this.key = null;
}
}
}
_saveValueWithReviver(value) {
if (this.done) {
this.current = this.reviver('', value);
} else {
if (this.current instanceof Array) {
value = this.reviver('' + this.current.length, value);
this.current.push(value);
if (value === undefined) {
delete this.current[this.current.length - 1];
}
} else {
value = this.reviver(this.key, value);
if (value !== undefined) {
this.current[this.key] = value;
}
this.key = null;
}
}
}
}
Assembler.prototype.stringValue = Assembler.prototype._saveValue;
Assembler.prototype.startObject = startObject(Object);
Assembler.prototype.startArray = startObject(Array);
Assembler.prototype.endArray = Assembler.prototype.endObject;
module.exports = Assembler;

170
server/node_modules/stream-json/Disassembler.js generated vendored Normal file
View File

@@ -0,0 +1,170 @@
'use strict';
const {Transform} = require('stream');
class Emit {
constructor(tokenName) {
this.tokenName = tokenName;
}
}
class Disassembler extends Transform {
static make(options) {
return new Disassembler(options);
}
constructor(options) {
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: true}));
this._packKeys = this._packStrings = this._packNumbers = this._streamKeys = this._streamStrings = this._streamNumbers = true;
if (options) {
'packValues' in options && (this._packKeys = this._packStrings = this._packNumbers = options.packValues);
'packKeys' in options && (this._packKeys = options.packKeys);
'packStrings' in options && (this._packStrings = options.packStrings);
'packNumbers' in options && (this._packNumbers = options.packNumbers);
'streamValues' in options && (this._streamKeys = this._streamStrings = this._streamNumbers = options.streamValues);
'streamKeys' in options && (this._streamKeys = options.streamKeys);
'streamStrings' in options && (this._streamStrings = options.streamStrings);
'streamNumbers' in options && (this._streamNumbers = options.streamNumbers);
if (typeof options.replacer == 'function') {
this._replacer = options.replacer;
} else if (Array.isArray(options.replacer)) {
this._replacerDict = options.replacer.reduce((acc, k) => (acc[k] = 1, acc), {});
}
}
!this._packKeys && (this._streamKeys = true);
!this._packStrings && (this._streamStrings = true);
!this._packNumbers && (this._streamNumbers = true);
}
_transform(chunk, _, callback) {
const stack = [],
isArray = [];
if (chunk && typeof chunk == 'object' && typeof chunk.toJSON == 'function') {
chunk = chunk.toJSON('');
}
if (this._replacer) {
chunk = this._replacer('', chunk);
}
stack.push(chunk);
while (stack.length) {
const top = stack.pop();
main: switch (typeof top) {
case 'object':
if (top instanceof Emit) {
switch (top.tokenName) {
case 'keyValue':
const key = stack.pop();
if (this._streamKeys) {
this.push({name: 'startKey'});
this.push({name: 'stringChunk', value: key});
this.push({name: 'endKey'});
}
this._packKeys && this.push({name: 'keyValue', value: key});
break main;
case 'startArray':
isArray.push(true);
break;
case 'startObject':
isArray.push(false);
break;
case 'endArray':
case 'endObject':
isArray.pop();
break;
}
this.push({name: top.tokenName});
break;
}
if (Array.isArray(top)) {
stack.push(new Emit('endArray'));
for (let i = top.length - 1; i >= 0; --i) {
let value = top[i];
if (value && typeof value == 'object' && typeof value.toJSON == 'function') {
value = value.toJSON('' + i);
}
if (this._replacer) {
value = this._replacer('' + i, value);
}
switch (typeof value) {
case 'function':
case 'symbol':
case 'undefined':
value = null;
break;
}
stack.push(value);
}
stack.push(new Emit('startArray'));
break;
}
if (top === null) {
this.push({name: 'nullValue', value: null});
break;
}
// all other objects are just objects
const keys = Object.keys(top);
stack.push(new Emit('endObject'));
for (let i = keys.length - 1; i >= 0; --i) {
const key = keys[i];
if (this._replacerDict && this._replacerDict[key] !== 1) continue;
let value = top[key];
if (value && typeof value == 'object' && typeof value.toJSON == 'function') {
value = value.toJSON(key);
}
if (this._replacer) {
value = this._replacer(key, value);
}
switch (typeof value) {
case 'function':
case 'symbol':
case 'undefined':
continue;
}
stack.push(value, key, new Emit('keyValue'));
}
stack.push(new Emit('startObject'));
break;
case 'string':
if (this._streamStrings) {
this.push({name: 'startString'});
this.push({name: 'stringChunk', value: top});
this.push({name: 'endString'});
}
this._packStrings && this.push({name: 'stringValue', value: top});
break;
case 'number':
const number = top.toString();
if (isNaN(number) || !isFinite(number)) {
this.push({name: 'nullValue', value: null});
break;
}
if (this._streamNumbers) {
this.push({name: 'startNumber'});
this.push({name: 'numberChunk', value: number});
this.push({name: 'endNumber'});
}
this._packNumbers && this.push({name: 'numberValue', value: number});
break;
case 'function':
case 'symbol':
case 'undefined':
if (isArray.length && isArray[isArray.length - 1]) {
// replace with null inside arrays
this.push({name: 'nullValue', value: null});
}
break;
case 'boolean':
this.push(top ? {name: 'trueValue', value: true} : {name: 'falseValue', value: false});
break;
default:
// skip everything else
break;
}
}
callback(null);
}
}
Disassembler.disassembler = Disassembler.make;
Disassembler.make.Constructor = Disassembler;
module.exports = Disassembler;

22
server/node_modules/stream-json/Emitter.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
'use strict';
const {Writable} = require('stream');
class Emitter extends Writable {
static make(options) {
return new Emitter(options);
}
constructor(options) {
super(Object.assign({}, options, {objectMode: true}));
}
_write(chunk, encoding, callback) {
this.emit(chunk.name, chunk.value);
callback(null);
}
}
Emitter.emitter = Emitter.make;
Emitter.make.Constructor = Emitter;
module.exports = Emitter;

34
server/node_modules/stream-json/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,34 @@
This library is available under the terms of the modified BSD license. No external contributions
are allowed under licenses which are fundamentally incompatible with the BSD license that this library is distributed under.
The text of the BSD license is reproduced below.
-------------------------------------------------------------------------------
The "New" BSD License:
**********************
Copyright (c) 2005-2018, Eugene Lazutkin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Eugene Lazutkin nor the names of other contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

545
server/node_modules/stream-json/Parser.js generated vendored Normal file
View File

@@ -0,0 +1,545 @@
'use strict';
const Utf8Stream = require('./utils/Utf8Stream');
const patterns = {
value1: /^(?:[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256})/,
string: /^(?:[^\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\")/,
key1: /^(?:[\"\}]|\s{1,256})/,
colon: /^(?:\:|\s{1,256})/,
comma: /^(?:[\,\]\}]|\s{1,256})/,
ws: /^\s{1,256}/,
numberStart: /^\d/,
numberDigit: /^\d{0,256}/,
numberFraction: /^[\.eE]/,
numberExponent: /^[eE]/,
numberExpSign: /^[-+]/
};
const MAX_PATTERN_SIZE = 16;
let noSticky = true;
try {
new RegExp('.', 'y');
noSticky = false;
} catch (e) {
// suppress
}
!noSticky &&
Object.keys(patterns).forEach(key => {
let src = patterns[key].source.slice(1); // lop off ^
if (src.slice(0, 3) === '(?:' && src.slice(-1) === ')') {
src = src.slice(3, -1);
}
patterns[key] = new RegExp(src, 'y');
});
patterns.numberFracStart = patterns.numberExpStart = patterns.numberStart;
patterns.numberFracDigit = patterns.numberExpDigit = patterns.numberDigit;
const values = {true: true, false: false, null: null},
expected = {object: 'objectStop', array: 'arrayStop', '': 'done'};
// long hexadecimal codes: \uXXXX
const fromHex = s => String.fromCharCode(parseInt(s.slice(2), 16));
// short codes: \b \f \n \r \t \" \\ \/
const codes = {b: '\b', f: '\f', n: '\n', r: '\r', t: '\t', '"': '"', '\\': '\\', '/': '/'};
class Parser extends Utf8Stream {
static make(options) {
return new Parser(options);
}
constructor(options) {
super(Object.assign({}, options, {readableObjectMode: true}));
this._packKeys = this._packStrings = this._packNumbers = this._streamKeys = this._streamStrings = this._streamNumbers = true;
if (options) {
'packValues' in options && (this._packKeys = this._packStrings = this._packNumbers = options.packValues);
'packKeys' in options && (this._packKeys = options.packKeys);
'packStrings' in options && (this._packStrings = options.packStrings);
'packNumbers' in options && (this._packNumbers = options.packNumbers);
'streamValues' in options && (this._streamKeys = this._streamStrings = this._streamNumbers = options.streamValues);
'streamKeys' in options && (this._streamKeys = options.streamKeys);
'streamStrings' in options && (this._streamStrings = options.streamStrings);
'streamNumbers' in options && (this._streamNumbers = options.streamNumbers);
this._jsonStreaming = options.jsonStreaming;
}
!this._packKeys && (this._streamKeys = true);
!this._packStrings && (this._streamStrings = true);
!this._packNumbers && (this._streamNumbers = true);
this._done = false;
this._expect = this._jsonStreaming ? 'done' : 'value';
this._stack = [];
this._parent = '';
this._open_number = false;
this._accumulator = '';
}
_flush(callback) {
this._done = true;
super._flush(error => {
if (error) return callback(error);
if (this._open_number) {
if (this._streamNumbers) {
this.push({name: 'endNumber'});
}
this._open_number = false;
if (this._packNumbers) {
this.push({name: 'numberValue', value: this._accumulator});
this._accumulator = '';
}
}
callback(null);
});
}
_processBuffer(callback) {
let match,
value,
index = 0;
main: for (;;) {
switch (this._expect) {
case 'value1':
case 'value':
patterns.value1.lastIndex = index;
match = patterns.value1.exec(this._buffer);
if (!match) {
if (this._done || index + MAX_PATTERN_SIZE < this._buffer.length) {
if (index < this._buffer.length) return callback(new Error('Parser cannot parse input: expected a value'));
return callback(new Error('Parser has expected a value'));
}
break main; // wait for more input
}
value = match[0];
switch (value) {
case '"':
this._streamStrings && this.push({name: 'startString'});
this._expect = 'string';
break;
case '{':
this.push({name: 'startObject'});
this._stack.push(this._parent);
this._parent = 'object';
this._expect = 'key1';
break;
case '[':
this.push({name: 'startArray'});
this._stack.push(this._parent);
this._parent = 'array';
this._expect = 'value1';
break;
case ']':
if (this._expect !== 'value1') return callback(new Error("Parser cannot parse input: unexpected token ']'"));
if (this._open_number) {
this._streamNumbers && this.push({name: 'endNumber'});
this._open_number = false;
if (this._packNumbers) {
this.push({name: 'numberValue', value: this._accumulator});
this._accumulator = '';
}
}
this.push({name: 'endArray'});
this._parent = this._stack.pop();
this._expect = expected[this._parent];
break;
case '-':
this._open_number = true;
if (this._streamNumbers) {
this.push({name: 'startNumber'});
this.push({name: 'numberChunk', value: '-'});
}
this._packNumbers && (this._accumulator = '-');
this._expect = 'numberStart';
break;
case '0':
this._open_number = true;
if (this._streamNumbers) {
this.push({name: 'startNumber'});
this.push({name: 'numberChunk', value: '0'});
}
this._packNumbers && (this._accumulator = '0');
this._expect = 'numberFraction';
break;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
this._open_number = true;
if (this._streamNumbers) {
this.push({name: 'startNumber'});
this.push({name: 'numberChunk', value: value});
}
this._packNumbers && (this._accumulator = value);
this._expect = 'numberDigit';
break;
case 'true':
case 'false':
case 'null':
if (this._buffer.length - index === value.length && !this._done) break main; // wait for more input
this.push({name: value + 'Value', value: values[value]});
this._expect = expected[this._parent];
break;
// default: // ws
}
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'keyVal':
case 'string':
patterns.string.lastIndex = index;
match = patterns.string.exec(this._buffer);
if (!match) {
if (index < this._buffer.length && (this._done || this._buffer.length - index >= 6))
return callback(new Error('Parser cannot parse input: escaped characters'));
if (this._done) return callback(new Error('Parser has expected a string value'));
break main; // wait for more input
}
value = match[0];
if (value === '"') {
if (this._expect === 'keyVal') {
this._streamKeys && this.push({name: 'endKey'});
if (this._packKeys) {
this.push({name: 'keyValue', value: this._accumulator});
this._accumulator = '';
}
this._expect = 'colon';
} else {
this._streamStrings && this.push({name: 'endString'});
if (this._packStrings) {
this.push({name: 'stringValue', value: this._accumulator});
this._accumulator = '';
}
this._expect = expected[this._parent];
}
} else if (value.length > 1 && value.charAt(0) === '\\') {
const t = value.length == 2 ? codes[value.charAt(1)] : fromHex(value);
if (this._expect === 'keyVal' ? this._streamKeys : this._streamStrings) {
this.push({name: 'stringChunk', value: t});
}
if (this._expect === 'keyVal' ? this._packKeys : this._packStrings) {
this._accumulator += t;
}
} else {
if (this._expect === 'keyVal' ? this._streamKeys : this._streamStrings) {
this.push({name: 'stringChunk', value: value});
}
if (this._expect === 'keyVal' ? this._packKeys : this._packStrings) {
this._accumulator += value;
}
}
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'key1':
case 'key':
patterns.key1.lastIndex = index;
match = patterns.key1.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(new Error('Parser cannot parse input: expected an object key'));
break main; // wait for more input
}
value = match[0];
if (value === '"') {
this._streamKeys && this.push({name: 'startKey'});
this._expect = 'keyVal';
} else if (value === '}') {
if (this._expect !== 'key1') return callback(new Error("Parser cannot parse input: unexpected token '}'"));
this.push({name: 'endObject'});
this._parent = this._stack.pop();
this._expect = expected[this._parent];
}
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'colon':
patterns.colon.lastIndex = index;
match = patterns.colon.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(new Error("Parser cannot parse input: expected ':'"));
break main; // wait for more input
}
value = match[0];
value === ':' && (this._expect = 'value');
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'arrayStop':
case 'objectStop':
patterns.comma.lastIndex = index;
match = patterns.comma.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(new Error("Parser cannot parse input: expected ','"));
break main; // wait for more input
}
if (this._open_number) {
this._streamNumbers && this.push({name: 'endNumber'});
this._open_number = false;
if (this._packNumbers) {
this.push({name: 'numberValue', value: this._accumulator});
this._accumulator = '';
}
}
value = match[0];
if (value === ',') {
this._expect = this._expect === 'arrayStop' ? 'value' : 'key';
} else if (value === '}' || value === ']') {
if (value === '}' ? this._expect === 'arrayStop' : this._expect !== 'arrayStop') {
return callback(new Error("Parser cannot parse input: expected '" + (this._expect === 'arrayStop' ? ']' : '}') + "'"));
}
this.push({name: value === '}' ? 'endObject' : 'endArray'});
this._parent = this._stack.pop();
this._expect = expected[this._parent];
}
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
// number chunks
case 'numberStart': // [0-9]
patterns.numberStart.lastIndex = index;
match = patterns.numberStart.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(new Error('Parser cannot parse input: expected a starting digit'));
break main; // wait for more input
}
value = match[0];
this._streamNumbers && this.push({name: 'numberChunk', value: value});
this._packNumbers && (this._accumulator += value);
this._expect = value === '0' ? 'numberFraction' : 'numberDigit';
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberDigit': // [0-9]*
patterns.numberDigit.lastIndex = index;
match = patterns.numberDigit.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(new Error('Parser cannot parse input: expected a digit'));
break main; // wait for more input
}
value = match[0];
if (value) {
this._streamNumbers && this.push({name: 'numberChunk', value: value});
this._packNumbers && (this._accumulator += value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
} else {
if (index < this._buffer.length) {
this._expect = 'numberFraction';
break;
}
if (this._done) {
this._expect = expected[this._parent];
break;
}
break main; // wait for more input
}
break;
case 'numberFraction': // [\.eE]?
patterns.numberFraction.lastIndex = index;
match = patterns.numberFraction.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) {
this._expect = expected[this._parent];
break;
}
break main; // wait for more input
}
value = match[0];
this._streamNumbers && this.push({name: 'numberChunk', value: value});
this._packNumbers && (this._accumulator += value);
this._expect = value === '.' ? 'numberFracStart' : 'numberExpSign';
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberFracStart': // [0-9]
patterns.numberFracStart.lastIndex = index;
match = patterns.numberFracStart.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(new Error('Parser cannot parse input: expected a fractional part of a number'));
break main; // wait for more input
}
value = match[0];
this._streamNumbers && this.push({name: 'numberChunk', value: value});
this._packNumbers && (this._accumulator += value);
this._expect = 'numberFracDigit';
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberFracDigit': // [0-9]*
patterns.numberFracDigit.lastIndex = index;
match = patterns.numberFracDigit.exec(this._buffer);
value = match[0];
if (value) {
this._streamNumbers && this.push({name: 'numberChunk', value: value});
this._packNumbers && (this._accumulator += value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
} else {
if (index < this._buffer.length) {
this._expect = 'numberExponent';
break;
}
if (this._done) {
this._expect = expected[this._parent];
break;
}
break main; // wait for more input
}
break;
case 'numberExponent': // [eE]?
patterns.numberExponent.lastIndex = index;
match = patterns.numberExponent.exec(this._buffer);
if (!match) {
if (index < this._buffer.length) {
this._expect = expected[this._parent];
break;
}
if (this._done) {
this._expect = 'done';
break;
}
break main; // wait for more input
}
value = match[0];
this._streamNumbers && this.push({name: 'numberChunk', value: value});
this._packNumbers && (this._accumulator += value);
this._expect = 'numberExpSign';
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberExpSign': // [-+]?
patterns.numberExpSign.lastIndex = index;
match = patterns.numberExpSign.exec(this._buffer);
if (!match) {
if (index < this._buffer.length) {
this._expect = 'numberExpStart';
break;
}
if (this._done) return callback(new Error('Parser has expected an exponent value of a number'));
break main; // wait for more input
}
value = match[0];
this._streamNumbers && this.push({name: 'numberChunk', value: value});
this._packNumbers && (this._accumulator += value);
this._expect = 'numberExpStart';
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberExpStart': // [0-9]
patterns.numberExpStart.lastIndex = index;
match = patterns.numberExpStart.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(new Error('Parser cannot parse input: expected an exponent part of a number'));
break main; // wait for more input
}
value = match[0];
this._streamNumbers && this.push({name: 'numberChunk', value: value});
this._packNumbers && (this._accumulator += value);
this._expect = 'numberExpDigit';
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberExpDigit': // [0-9]*
patterns.numberExpDigit.lastIndex = index;
match = patterns.numberExpDigit.exec(this._buffer);
value = match[0];
if (value) {
this._streamNumbers && this.push({name: 'numberChunk', value: value});
this._packNumbers && (this._accumulator += value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
} else {
if (index < this._buffer.length || this._done) {
this._expect = expected[this._parent];
break;
}
break main; // wait for more input
}
break;
case 'done':
patterns.ws.lastIndex = index;
match = patterns.ws.exec(this._buffer);
if (!match) {
if (index < this._buffer.length) {
if (this._jsonStreaming) {
this._expect = 'value';
break;
}
return callback(new Error('Parser cannot parse input: unexpected characters'));
}
break main; // wait for more input
}
value = match[0];
if (this._open_number) {
this._streamNumbers && this.push({name: 'endNumber'});
this._open_number = false;
if (this._packNumbers) {
this.push({name: 'numberValue', value: this._accumulator});
this._accumulator = '';
}
}
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
}
}
!noSticky && (this._buffer = this._buffer.slice(index));
callback(null);
}
}
Parser.parser = Parser.make;
Parser.make.Constructor = Parser;
module.exports = Parser;

126
server/node_modules/stream-json/README.md generated vendored Normal file
View File

@@ -0,0 +1,126 @@
# stream-json [![NPM version][npm-image]][npm-url]
[npm-image]: https://img.shields.io/npm/v/stream-json.svg
[npm-url]: https://npmjs.org/package/stream-json
`stream-json` is a micro-library of node.js stream components with minimal dependencies for creating custom data processors oriented on processing huge JSON files while requiring a minimal memory footprint. It can parse JSON files far exceeding available memory. Even individual primitive data items (keys, strings, and numbers) can be streamed piece-wise. Streaming SAX-inspired event-based API is included as well.
Available components:
* Streaming JSON [Parser](https://github.com/uhop/stream-json/wiki/Parser).
* It produces a SAX-like token stream.
* Optionally it can pack keys, strings, and numbers (controlled separately).
* The [main module](https://github.com/uhop/stream-json/wiki/Main-module) provides helpers to create a parser.
* Filters to edit a token stream:
* [Pick](https://github.com/uhop/stream-json/wiki/Pick) selects desired objects.
* It can produces multiple top-level objects just like in [JSON Streaming](https://en.wikipedia.org/wiki/JSON_Streaming) protocol.
* Don't forget to use [StreamValues](https://github.com/uhop/stream-json/wiki/StreamValues) when picking several subobjects!
* [Replace](https://github.com/uhop/stream-json/wiki/Replace) substitutes objects with a replacement.
* [Ignore](https://github.com/uhop/stream-json/wiki/Ignore) removes objects.
* [Filter](https://github.com/uhop/stream-json/wiki/Filter) filters tokens maintaining stream's validity.
* Streamers to produce a stream of JavaScript objects.
* [StreamValues](https://github.com/uhop/stream-json/wiki/StreamValues) can handle a stream of JSON objects.
* Useful to stream objects selected by `Pick`, or generated by other means.
* It supports [JSON Streaming](https://en.wikipedia.org/wiki/JSON_Streaming) protocol, where individual values are separated semantically (like in `"{}[]"`), or with white spaces (like in `"true 1 null"`).
* [StreamArray](https://github.com/uhop/stream-json/wiki/StreamArray) takes an array of objects and produces a stream of its components.
* It streams array components individually taking care of assembling them automatically.
* Created initially to deal with JSON files similar to [Django](https://www.djangoproject.com/)-produced database dumps.
* Only one top-level array per stream is valid!
* [StreamObject](https://github.com/uhop/stream-json/wiki/StreamObject) takes an object and produces a stream of its top-level properties.
* Only one top-level object per stream is valid!
* Essentials:
* [Assembler](https://github.com/uhop/stream-json/wiki/Assembler) interprets a token stream creating JavaScript objects.
* [Disassembler](https://github.com/uhop/stream-json/wiki/Disassembler) produces a token stream from JavaScript objects.
* [Stringer](https://github.com/uhop/stream-json/wiki/Stringer) converts a token stream back into a JSON text stream.
* [Emitter](https://github.com/uhop/stream-json/wiki/Emitter) reads a token stream and emits each token as an event.
* It can greatly simplify data processing.
* Utilities:
* [emit()](https://github.com/uhop/stream-json/wiki/emit()) makes any stream component to emit tokens as events.
* [withParser()](https://github.com/uhop/stream-json/wiki/withParser()) helps to create stream components with a parser.
* [Batch](https://github.com/uhop/stream-json/wiki/Batch) batches items into arrays to simplify their processing.
* [Verifier](https://github.com/uhop/stream-json/wiki/Verifier) reads a stream and verifies that it is a valid JSON.
* [Utf8Stream](https://github.com/uhop/stream-json/wiki/Utf8Stream) sanitizes multibyte `utf8` text input.
* Special helpers:
* JSONL AKA [JSON Lines](http://jsonlines.org/) AKA [NDJSON](http://ndjson.org/):
* [jsonl/Parser](https://github.com/uhop/stream-json/wiki/jsonl-Parser) parses a JSONL file producing objects similar to `StreamValues`.
* Useful when we know that individual items can fit in memory.
* Generally it is faster than the equivalent combination of `Parser({jsonStreaming: true})` + `StreamValues`.
* [jsonl/Stringer](https://github.com/uhop/stream-json/wiki/jsonl-Stringer) produces a JSONL file from a stream of JavaScript objects.
* Generally it is faster than the equivalent combination of `Disassembler` + `Stringer`.
All components are meant to be building blocks to create flexible custom data processing pipelines. They can be extended and/or combined with custom code. They can be used together with [stream-chain](https://www.npmjs.com/package/stream-chain) to simplify data processing.
This toolkit is distributed under New BSD license.
## Introduction
```js
const {chain} = require('stream-chain');
const {parser} = require('stream-json');
const {pick} = require('stream-json/filters/Pick');
const {ignore} = require('stream-json/filters/Ignore');
const {streamValues} = require('stream-json/streamers/StreamValues');
const fs = require('fs');
const zlib = require('zlib');
const pipeline = chain([
fs.createReadStream('sample.json.gz'),
zlib.createGunzip(),
parser(),
pick({filter: 'data'}),
ignore({filter: /\b_meta\b/i}),
streamValues(),
data => {
const value = data.value;
// keep data only for the accounting department
return value && value.department === 'accounting' ? data : null;
}
]);
let counter = 0;
pipeline.on('data', () => ++counter);
pipeline.on('end', () =>
console.log(`The accounting department has ${counter} employees.`));
```
See the full documentation in [Wiki](https://github.com/uhop/stream-json/wiki).
Companion projects:
* [stream-csv-as-json](https://www.npmjs.com/package/stream-csv-as-json) streams huge CSV files in a format compatible with `stream-json`:
rows as arrays of string values. If a header row is used, it can stream rows as objects with named fields.
## Installation
```bash
npm install --save stream-json
# or: yarn add stream-json
```
## Use
The whole library is organized as a set of small components, which can be combined to produce the most effective pipeline. All components are based on node.js
[streams](http://nodejs.org/api/stream.html), and [events](http://nodejs.org/api/events.html). They implement all required standard APIs. It is easy to add your
own components to solve your unique tasks.
The code of all components is compact and simple. Please take a look at their source code to see how things are implemented, so you can produce your own components
in no time.
Obviously, if a bug is found, or a way to simplify existing components, or new generic components are created, which can be reused in a variety of projects,
don't hesitate to open a ticket, and/or create a pull request.
## Release History
- 1.8.0 *added an option to indicate/ignore JSONL errors. Thx, [AK](https://github.com/ak--47).*
- 1.7.5 *fixed a stringer bug with ASCII control symbols. Thx, [Kraicheck](https://github.com/Kraicheck).*
- 1.7.4 *updated dependency (`stream-chain`), bugfix: inconsistent object/array braces. Thx [Xiao Li](https://github.com/xli1000).*
- 1.7.3 *added an assembler option to treat numbers as strings.*
- 1.7.2 *added an error check for JSONL parsing. Thx [Marc-Andre Boily](https://github.com/maboily).*
- 1.7.1 *minor bugfix and improved error reporting.*
- 1.7.0 *added `utils/Utf8Stream` to sanitize `utf8` input, all parsers support it automatically. Thx [john30](https://github.com/john30) for the suggestion.*
- 1.6.1 *the technical release, no need to upgrade.*
- 1.6.0 *added `jsonl/Parser` and `jsonl/Stringer`.*
The rest can be consulted in the project's wiki [Release history](https://github.com/uhop/stream-json/wiki/Release-history).

153
server/node_modules/stream-json/Stringer.js generated vendored Normal file
View File

@@ -0,0 +1,153 @@
'use strict';
const {Transform} = require('stream');
const noCommaAfter = {startObject: 1, startArray: 1, endKey: 1, keyValue: 1},
noSpaceAfter = {endObject: 1, endArray: 1, '': 1},
noSpaceBefore = {startObject: 1, startArray: 1},
depthIncrement = {startObject: 1, startArray: 1},
depthDecrement = {endObject: 1, endArray: 1},
values = {startKey: 'keyValue', startString: 'stringValue', startNumber: 'numberValue'},
stopNames = {startKey: 'endKey', startString: 'endString', startNumber: 'endNumber'},
symbols = {
startObject: '{',
endObject: '}',
startArray: '[',
endArray: ']',
startKey: '"',
endKey: '":',
startString: '"',
endString: '"',
startNumber: '',
endNumber: '',
nullValue: 'null',
trueValue: 'true',
falseValue: 'false'
};
const skipValue = endName =>
function (chunk, encoding, callback) {
if (chunk.name === endName) {
this._transform = this._prev_transform;
}
callback(null);
};
const replaceSymbols = {'\b': '\\b', '\f': '\\f', '\n': '\\n', '\r': '\\r', '\t': '\\t', '"': '\\"', '\\': '\\\\'};
const sanitizeString = value =>
value.replace(/[\b\f\n\r\t\"\\\u0000-\u001F\u007F-\u009F]/g, match =>
replaceSymbols.hasOwnProperty(match) ? replaceSymbols[match] : '\\u' + ('0000' + match.charCodeAt(0).toString(16)).slice(-4)
);
const doNothing = () => {};
class Stringer extends Transform {
static make(options) {
return new Stringer(options);
}
constructor(options) {
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: false}));
this._values = {};
if (options) {
'useValues' in options && (this._values.keyValue = this._values.stringValue = this._values.numberValue = options.useValues);
'useKeyValues' in options && (this._values.keyValue = options.useKeyValues);
'useStringValues' in options && (this._values.stringValue = options.useStringValues);
'useNumberValues' in options && (this._values.numberValue = options.useNumberValues);
this._makeArray = options.makeArray;
}
this._prev = '';
this._depth = 0;
if (this._makeArray) {
this._transform = this._arrayTransform;
this._flush = this._arrayFlush;
}
}
_arrayTransform(chunk, encoding, callback) {
// it runs once
delete this._transform;
this._transform({name: 'startArray'}, encoding, doNothing);
this._transform(chunk, encoding, callback);
}
_arrayFlush(callback) {
if (this._transform === this._arrayTransform) {
delete this._transform;
this._transform({name: 'startArray'}, null, doNothing);
}
this._transform({name: 'endArray'}, null, callback);
}
_transform(chunk, _, callback) {
if (this._values[chunk.name]) {
if (this._depth && noCommaAfter[this._prev] !== 1) this.push(',');
switch (chunk.name) {
case 'keyValue':
this.push('"' + sanitizeString(chunk.value) + '":');
break;
case 'stringValue':
this.push('"' + sanitizeString(chunk.value) + '"');
break;
case 'numberValue':
this.push(chunk.value);
break;
}
} else {
// filter out values
switch (chunk.name) {
case 'endObject':
case 'endArray':
case 'endKey':
case 'endString':
case 'endNumber':
this.push(symbols[chunk.name]);
break;
case 'stringChunk':
this.push(sanitizeString(chunk.value));
break;
case 'numberChunk':
this.push(chunk.value);
break;
case 'keyValue':
case 'stringValue':
case 'numberValue':
// skip completely
break;
case 'startKey':
case 'startString':
case 'startNumber':
if (this._values[values[chunk.name]]) {
this._prev_transform = this._transform;
this._transform = skipValue(stopNames[chunk.name]);
return callback(null);
}
// intentional fall down
default:
// case 'startObject': case 'startArray': case 'startKey': case 'startString':
// case 'startNumber': case 'nullValue': case 'trueValue': case 'falseValue':
if (this._depth) {
if (noCommaAfter[this._prev] !== 1) this.push(',');
} else {
if (noSpaceAfter[this._prev] !== 1 && noSpaceBefore[chunk.name] !== 1) this.push(' ');
}
this.push(symbols[chunk.name]);
break;
}
if (depthIncrement[chunk.name]) {
++this._depth;
} else if (depthDecrement[chunk.name]) {
--this._depth;
}
}
this._prev = chunk.name;
callback(null);
}
}
Stringer.stringer = Stringer.make;
Stringer.make.Constructor = Stringer;
module.exports = Stringer;

130
server/node_modules/stream-json/filters/Filter.js generated vendored Normal file
View File

@@ -0,0 +1,130 @@
'use strict';
const FilterBase = require('./FilterBase');
const withParser = require('../utils/withParser');
class Filter extends FilterBase {
static make(options) {
return new Filter(options);
}
static withParser(options) {
return withParser(Filter.make, options);
}
constructor(options) {
super(options);
this._once = false;
this._lastStack = [];
}
_flush(callback) {
this._syncStack();
callback(null);
}
_checkChunk(chunk) {
switch (chunk.name) {
case 'startObject':
if (this._filter(this._stack, chunk)) {
this._syncStack();
this.push(chunk);
this._lastStack.push(null);
}
break;
case 'startArray':
if (this._filter(this._stack, chunk)) {
this._syncStack();
this.push(chunk);
this._lastStack.push(-1);
}
break;
case 'nullValue':
case 'trueValue':
case 'falseValue':
case 'stringValue':
case 'numberValue':
if (this._filter(this._stack, chunk)) {
this._syncStack();
this.push(chunk);
}
break;
case 'startString':
if (this._filter(this._stack, chunk)) {
this._syncStack();
this.push(chunk);
this._transform = this._passString;
} else {
this._transform = this._skipString;
}
break;
case 'startNumber':
if (this._filter(this._stack, chunk)) {
this._syncStack();
this.push(chunk);
this._transform = this._passNumber;
} else {
this._transform = this._skipNumber;
}
break;
}
return false;
}
_syncStack() {
const stack = this._stack,
last = this._lastStack,
stackLength = stack.length,
lastLength = last.length;
// find the common part
let commonLength = 0;
for (const n = Math.min(stackLength, lastLength); commonLength < n && stack[commonLength] === last[commonLength]; ++commonLength);
// close old objects
for (let i = lastLength - 1; i > commonLength; --i) {
this.push({name: typeof last[i] == 'number' ? 'endArray' : 'endObject'});
}
if (commonLength < lastLength) {
if (commonLength < stackLength) {
if (typeof stack[commonLength] == 'string') {
const key = stack[commonLength];
if (this._streamKeys) {
this.push({name: 'startKey'});
this.push({name: 'stringChunk', value: key});
this.push({name: 'endKey'});
}
this.push({name: 'keyValue', value: key});
}
++commonLength;
} else {
this.push({name: typeof last[commonLength] == 'number' ? 'endArray' : 'endObject'});
}
}
// open new objects
for (let i = commonLength; i < stackLength; ++i) {
const key = stack[i];
if (typeof key == 'number') {
if (key >= 0) {
this.push({name: 'startArray'});
}
} else if (typeof key == 'string') {
this.push({name: 'startObject'});
if (this._streamKeys) {
this.push({name: 'startKey'});
this.push({name: 'stringChunk', value: key});
this.push({name: 'endKey'});
}
this.push({name: 'keyValue', value: key});
}
}
// update the last stack
this._lastStack = Array.prototype.concat.call(stack);
}
}
Filter.filter = Filter.make;
Filter.make.Constructor = Filter;
module.exports = Filter;

201
server/node_modules/stream-json/filters/FilterBase.js generated vendored Normal file
View File

@@ -0,0 +1,201 @@
'use strict';
const {Transform} = require('stream');
class FilterBase extends Transform {
static stringFilter(string, separator) {
return stack => {
const path = stack.join(separator);
return (
(path.length === string.length && path === string) ||
(path.length > string.length && path.substr(0, string.length) === string && path.substr(string.length, separator.length) === separator)
);
};
}
static regExpFilter(regExp, separator) {
return stack => regExp.test(stack.join(separator));
}
static arrayReplacement(array) {
return () => array;
}
constructor(options) {
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: true}));
this._transform = this._check;
this._stack = [];
const filter = options && options.filter,
separator = (options && options.pathSeparator) || '.';
if (typeof filter == 'string') {
this._filter = FilterBase.stringFilter(filter, separator);
} else if (typeof filter == 'function') {
this._filter = filter;
} else if (filter instanceof RegExp) {
this._filter = FilterBase.regExpFilter(filter, separator);
}
const replacement = options && options.replacement;
if (typeof replacement == 'function') {
this._replacement = replacement;
} else {
this._replacement = FilterBase.arrayReplacement(replacement || FilterBase.defaultReplacement);
}
this._allowEmptyReplacement = options && options.allowEmptyReplacement;
this._streamKeys = true;
if (options) {
'streamValues' in options && (this._streamKeys = options.streamValues);
'streamKeys' in options && (this._streamKeys = options.streamKeys);
}
this._once = options && options.once;
this._previousToken = '';
}
_check(chunk, _, callback) {
// update the last stack key
switch (chunk.name) {
case 'startObject':
case 'startArray':
case 'startString':
case 'startNumber':
case 'nullValue':
case 'trueValue':
case 'falseValue':
if (typeof this._stack[this._stack.length - 1] == 'number') {
// array
++this._stack[this._stack.length - 1];
}
break;
case 'keyValue':
this._stack[this._stack.length - 1] = chunk.value;
break;
case 'numberValue':
if (this._previousToken !== 'endNumber' && typeof this._stack[this._stack.length - 1] == 'number') {
// array
++this._stack[this._stack.length - 1];
}
break;
case 'stringValue':
if (this._previousToken !== 'endString' && typeof this._stack[this._stack.length - 1] == 'number') {
// array
++this._stack[this._stack.length - 1];
}
break;
}
this._previousToken = chunk.name;
// check, if we allow a chunk
if (this._checkChunk(chunk)) {
return callback(null);
}
// update the stack
switch (chunk.name) {
case 'startObject':
this._stack.push(null);
break;
case 'startArray':
this._stack.push(-1);
break;
case 'endObject':
case 'endArray':
this._stack.pop();
break;
}
callback(null);
}
_passObject(chunk, _, callback) {
this.push(chunk);
switch (chunk.name) {
case 'startObject':
case 'startArray':
++this._depth;
break;
case 'endObject':
case 'endArray':
--this._depth;
break;
}
if (!this._depth) {
this._transform = this._once ? this._skip : this._check;
}
callback(null);
}
_pass(chunk, _, callback) {
this.push(chunk);
callback(null);
}
_skipObject(chunk, _, callback) {
switch (chunk.name) {
case 'startObject':
case 'startArray':
++this._depth;
break;
case 'endObject':
case 'endArray':
--this._depth;
break;
}
if (!this._depth) {
this._transform = this._once ? this._pass : this._check;
}
callback(null);
}
_skip(chunk, _, callback) {
callback(null);
}
}
FilterBase.defaultReplacement = [{name: 'nullValue', value: null}];
const passValue = (last, post) =>
function(chunk, _, callback) {
if (this._expected) {
const expected = this._expected;
this._expected = '';
this._transform = this._once ? this._skip : this._check;
if (expected === chunk.name) {
this.push(chunk);
} else {
return this._transform(chunk, _, callback);
}
} else {
this.push(chunk);
if (chunk.name === last) {
this._expected = post;
}
}
callback(null);
};
FilterBase.prototype._passNumber = passValue('endNumber', 'numberValue');
FilterBase.prototype._passString = passValue('endString', 'stringValue');
FilterBase.prototype._passKey = passValue('endKey', 'keyValue');
const skipValue = (last, post) =>
function(chunk, _, callback) {
if (this._expected) {
const expected = this._expected;
this._expected = '';
this._transform = this._once ? this._pass : this._check;
if (expected !== chunk.name) {
return this._transform(chunk, _, callback);
}
} else {
if (chunk.name === last) {
this._expected = post;
}
}
callback(null);
};
FilterBase.prototype._skipNumber = skipValue('endNumber', 'numberValue');
FilterBase.prototype._skipString = skipValue('endString', 'stringValue');
FilterBase.prototype._skipKey = skipValue('endKey', 'keyValue');
module.exports = FilterBase;

24
server/node_modules/stream-json/filters/Ignore.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
'use strict';
const Replace = require('./Replace');
const withParser = require('../utils/withParser');
class Ignore extends Replace {
static make(options) {
return new Ignore(options);
}
static withParser(options) {
return withParser(Ignore.make, options);
}
constructor(options) {
super(options);
this._replacement = Replace.arrayReplacement([]);
this._allowEmptyReplacement = true;
}
}
Ignore.ignore = Ignore.make;
Ignore.make.Constructor = Ignore;
module.exports = Ignore;

58
server/node_modules/stream-json/filters/Pick.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
'use strict';
const FilterBase = require('./FilterBase');
const withParser = require('../utils/withParser');
class Pick extends FilterBase {
static make(options) {
return new Pick(options);
}
static withParser(options) {
return withParser(Pick.make, options);
}
_checkChunk(chunk) {
switch (chunk.name) {
case 'startObject':
case 'startArray':
if (this._filter(this._stack, chunk)) {
this.push(chunk);
this._transform = this._passObject;
this._depth = 1;
return true;
}
break;
case 'startString':
if (this._filter(this._stack, chunk)) {
this.push(chunk);
this._transform = this._passString;
return true;
}
break;
case 'startNumber':
if (this._filter(this._stack, chunk)) {
this.push(chunk);
this._transform = this._passNumber;
return true;
}
break;
case 'nullValue':
case 'trueValue':
case 'falseValue':
case 'stringValue':
case 'numberValue':
if (this._filter(this._stack, chunk)) {
this.push(chunk);
this._transform = this._once ? this._skip : this._check;
return true;
}
break;
}
return false;
}
}
Pick.pick = Pick.make;
Pick.make.Constructor = Pick;
module.exports = Pick;

115
server/node_modules/stream-json/filters/Replace.js generated vendored Normal file
View File

@@ -0,0 +1,115 @@
'use strict';
const FilterBase = require('./FilterBase');
const withParser = require('../utils/withParser');
class Replace extends FilterBase {
static make(options) {
return new Replace(options);
}
static withParser(options) {
return withParser(Replace.make, options);
}
_checkChunk(chunk) {
switch (chunk.name) {
case 'startKey':
if (this._allowEmptyReplacement) {
this._transform = this._skipKeyChunks;
return true;
}
break;
case 'keyValue':
if (this._allowEmptyReplacement) return true;
break;
case 'startObject':
case 'startArray':
case 'startString':
case 'startNumber':
case 'nullValue':
case 'trueValue':
case 'falseValue':
case 'stringValue':
case 'numberValue':
if (this._filter(this._stack, chunk)) {
let replacement = this._replacement(this._stack, chunk);
if (this._allowEmptyReplacement) {
if (replacement.length) {
const key = this._stack[this._stack.length - 1];
if (typeof key == 'string') {
if (this._streamKeys) {
this.push({name: 'startKey'});
this.push({name: 'stringChunk', value: key});
this.push({name: 'endKey'});
}
this.push({name: 'keyValue', value: key});
}
}
} else {
if (!replacement.length) replacement = FilterBase.defaultReplacement;
}
replacement.forEach(value => this.push(value));
switch (chunk.name) {
case 'startObject':
case 'startArray':
this._transform = this._skipObject;
this._depth = 1;
break;
case 'startString':
this._transform = this._skipString;
break;
case 'startNumber':
this._transform = this._skipNumber;
break;
case 'nullValue':
case 'trueValue':
case 'falseValue':
case 'stringValue':
case 'numberValue':
this._transform = this._once ? this._pass : this._check;
break;
}
return true;
}
break;
}
// issue a key, if needed
if (this._allowEmptyReplacement) {
const key = this._stack[this._stack.length - 1];
if (typeof key == 'string') {
switch (chunk.name) {
case 'startObject':
case 'startArray':
case 'startString':
case 'startNumber':
case 'nullValue':
case 'trueValue':
case 'falseValue':
case 'stringValue':
case 'numberValue':
if (this._streamKeys) {
this.push({name: 'startKey'});
this.push({name: 'stringChunk', value: key});
this.push({name: 'endKey'});
}
this.push({name: 'keyValue', value: key});
break;
}
}
}
this.push(chunk);
return false;
}
_skipKeyChunks(chunk, _, callback) {
if (chunk.name === 'endKey') {
this._transform = this._check;
}
callback(null);
}
}
Replace.replace = Replace.make;
Replace.make.Constructor = Replace;
module.exports = Replace;

11
server/node_modules/stream-json/index.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
'use strict';
const Parser = require('./Parser');
const emit = require('./utils/emit');
const make = options => emit(new Parser(options));
make.Parser = Parser;
make.parser = Parser.parser;
module.exports = make;

131
server/node_modules/stream-json/jsonl/Parser.js generated vendored Normal file
View File

@@ -0,0 +1,131 @@
'use strict';
const Utf8Stream = require('../utils/Utf8Stream');
class JsonlParser extends Utf8Stream {
static make(options) {
return new JsonlParser(options);
}
static checkedParse(input, reviver, errorIndicator) {
try {
return JSON.parse(input, reviver);
} catch (error) {
if (typeof errorIndicator == 'function') return errorIndicator(error);
}
return errorIndicator;
}
constructor(options) {
super(Object.assign({}, options, {readableObjectMode: true}));
this._rest = '';
this._counter = 0;
this._reviver = options && options.reviver;
this._errorIndicator = options && options.errorIndicator;
if (options && options.checkErrors) {
this._processBuffer = this._checked_processBuffer;
this._flush = this._checked_flush;
}
if (options && 'errorIndicator' in options) {
this._processBuffer = this._suppressed_processBuffer;
this._flush = this._suppressed_flush;
}
}
_processBuffer(callback) {
const lines = this._buffer.split('\n');
this._rest += lines[0];
if (lines.length > 1) {
this._rest && this.push({key: this._counter++, value: JSON.parse(this._rest, this._reviver)});
this._rest = lines.pop();
for (let i = 1; i < lines.length; ++i) {
lines[i] && this.push({key: this._counter++, value: JSON.parse(lines[i], this._reviver)});
}
}
this._buffer = '';
callback(null);
}
_flush(callback) {
super._flush(error => {
if (error) return callback(error);
if (this._rest) {
this.push({key: this._counter++, value: JSON.parse(this._rest, this._reviver)});
this._rest = '';
}
callback(null);
});
}
_suppressed_processBuffer(callback) {
const lines = this._buffer.split('\n');
this._rest += lines[0];
if (lines.length > 1) {
if (this._rest) {
const value = JsonlParser.checkedParse(this._rest, this._reviver, this._errorIndicator);
value !== undefined && this.push({key: this._counter++, value});
}
this._rest = lines.pop();
for (let i = 1; i < lines.length; ++i) {
if (!lines[i]) continue;
const value = JsonlParser.checkedParse(lines[i], this._reviver, this._errorIndicator);
value !== undefined && this.push({key: this._counter++, value});
}
}
this._buffer = '';
callback(null);
}
_suppressed_flush(callback) {
super._flush(error => {
if (error) return callback(error);
if (this._rest) {
const value = JsonlParser.checkedParse(this._rest, this._reviver, this._errorIndicator);
value !== undefined && this.push({key: this._counter++, value});
this._rest = '';
}
callback(null);
});
}
_checked_processBuffer(callback) {
const lines = this._buffer.split('\n');
this._rest += lines[0];
if (lines.length > 1) {
try {
this._rest && this.push({key: this._counter++, value: JSON.parse(this._rest, this._reviver)});
this._rest = lines.pop();
for (let i = 1; i < lines.length; ++i) {
lines[i] && this.push({key: this._counter++, value: JSON.parse(lines[i], this._reviver)});
}
} catch (cbErr) {
this._buffer = '';
callback(cbErr);
return;
}
}
this._buffer = '';
callback(null);
}
_checked_flush(callback) {
super._flush(error => {
if (error) return callback(error);
if (this._rest) {
try {
this.push({key: this._counter++, value: JSON.parse(this._rest, this._reviver)});
} catch (cbErr) {
this._rest = '';
callback(cbErr);
return;
}
this._rest = '';
}
callback(null);
});
}
}
JsonlParser.parser = JsonlParser.make;
JsonlParser.make.Constructor = JsonlParser;
module.exports = JsonlParser;

29
server/node_modules/stream-json/jsonl/Stringer.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
'use strict';
const {Transform} = require('stream');
class JsonlStringer extends Transform {
static make(options) {
return new JsonlStringer(options);
}
constructor(options) {
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: false}));
this._replacer = options && options.replacer;
}
_transform(chunk, _, callback) {
this.push(JSON.stringify(chunk, this._replacer));
this._transform = this._nextTransform;
callback(null);
}
_nextTransform(chunk, _, callback) {
this.push('\n' + JSON.stringify(chunk, this._replacer));
callback(null);
}
}
JsonlStringer.stringer = JsonlStringer.make;
JsonlStringer.make.Constructor = JsonlStringer;
module.exports = JsonlStringer;

45
server/node_modules/stream-json/package.json generated vendored Normal file
View File

@@ -0,0 +1,45 @@
{
"name": "stream-json",
"version": "1.8.0",
"description": "stream-json is the micro-library of Node.js stream components for creating custom JSON processing pipelines with a minimal memory footprint. It can parse JSON files far exceeding available memory streaming individual primitives using a SAX-inspired API. Includes utilities to stream JSON database dumps.",
"homepage": "http://github.com/uhop/stream-json",
"bugs": "http://github.com/uhop/stream-json/issues",
"main": "index.js",
"directories": {
"test": "tests"
},
"dependencies": {
"stream-chain": "^2.2.5"
},
"devDependencies": {
"heya-unit": "^0.3.0"
},
"scripts": {
"test": "node tests/tests.js",
"debug": "node --inspect-brk tests/tests.js"
},
"github": "http://github.com/uhop/stream-json",
"repository": {
"type": "git",
"url": "git://github.com/uhop/stream-json.git"
},
"keywords": [
"scanner",
"lexer",
"tokenizer",
"parser",
"django",
"stream",
"streaming",
"json"
],
"author": "Eugene Lazutkin <eugene.lazutkin@gmail.com> (http://lazutkin.com/)",
"license": "BSD-3-Clause",
"files": [
"/*.js",
"/filters",
"/jsonl",
"/streamers",
"/utils"
]
}

View File

@@ -0,0 +1,44 @@
'use strict';
const StreamBase = require('./StreamBase');
const withParser = require('../utils/withParser');
class StreamArray extends StreamBase {
static make(options) {
return new StreamArray(options);
}
static withParser(options) {
return withParser(StreamArray.make, options);
}
constructor(options) {
super(options);
this._level = 1;
this._counter = 0;
}
_wait(chunk, _, callback) {
// first chunk should open an array
if (chunk.name !== 'startArray') {
return callback(new Error('Top-level object should be an array.'));
}
this._transform = this._filter;
return this._transform(chunk, _, callback);
}
_push(discard) {
if (this._assembler.current.length) {
if (discard) {
++this._counter;
this._assembler.current.pop();
} else {
this.push({key: this._counter++, value: this._assembler.current.pop()});
}
}
}
}
StreamArray.streamArray = StreamArray.make;
StreamArray.make.Constructor = StreamArray;
module.exports = StreamArray;

101
server/node_modules/stream-json/streamers/StreamBase.js generated vendored Normal file
View File

@@ -0,0 +1,101 @@
'use strict';
const {Transform} = require('stream');
const Assembler = require('../Assembler');
class Counter {
constructor(initialDepth) {
this.depth = initialDepth;
}
startObject() {
++this.depth;
}
endObject() {
--this.depth;
}
startArray() {
++this.depth;
}
endArray() {
--this.depth;
}
}
class StreamBase extends Transform {
constructor(options) {
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: true}));
if (options) {
this.objectFilter = options.objectFilter;
this.includeUndecided = options.includeUndecided;
}
if (typeof this.objectFilter != 'function') {
this._filter = this._transform;
}
this._transform = this._wait || this._filter;
this._assembler = new Assembler(options);
}
_transform(chunk, encoding, callback) {
if (this._assembler[chunk.name]) {
this._assembler[chunk.name](chunk.value);
if (this._assembler.depth === this._level) {
this._push();
}
}
callback(null);
}
_filter(chunk, encoding, callback) {
if (this._assembler[chunk.name]) {
this._assembler[chunk.name](chunk.value);
const result = this.objectFilter(this._assembler);
if (result) {
if (this._assembler.depth === this._level) {
this._push();
this._transform = this._filter;
}
this._transform = this._accept;
return callback(null);
}
if (result === false) {
this._saved_assembler = this._assembler;
this._assembler = new Counter(this._saved_assembler.depth);
this._saved_assembler.dropToLevel(this._level);
if (this._assembler.depth === this._level) {
this._assembler = this._saved_assembler;
this._transform = this._filter;
}
this._transform = this._reject;
return callback(null);
}
if (this._assembler.depth === this._level) {
this._push(!this.includeUndecided);
}
}
callback(null);
}
_accept(chunk, encoding, callback) {
if (this._assembler[chunk.name]) {
this._assembler[chunk.name](chunk.value);
if (this._assembler.depth === this._level) {
this._push();
this._transform = this._filter;
}
}
callback(null);
}
_reject(chunk, encoding, callback) {
if (this._assembler[chunk.name]) {
this._assembler[chunk.name](chunk.value);
if (this._assembler.depth === this._level) {
this._assembler = this._saved_assembler;
this._transform = this._filter;
}
}
callback(null);
}
}
module.exports = StreamBase;

View File

@@ -0,0 +1,43 @@
'use strict';
const StreamBase = require('./StreamBase');
const withParser = require('../utils/withParser');
class StreamObject extends StreamBase {
static make(options) {
return new StreamObject(options);
}
static withParser(options) {
return withParser(StreamObject.make, options);
}
constructor(options) {
super(options);
this._level = 1;
this._lastKey = null;
}
_wait(chunk, _, callback) {
// first chunk should open an array
if (chunk.name !== 'startObject') {
return callback(new Error('Top-level object should be an object.'));
}
this._transform = this._filter;
return this._transform(chunk, _, callback);
}
_push(discard) {
if (this._lastKey === null) {
this._lastKey = this._assembler.key;
} else {
!discard && this.push({key: this._lastKey, value: this._assembler.current[this._lastKey]});
this._assembler.current = {};
this._lastKey = null;
}
}
}
StreamObject.streamObject = StreamObject.make;
StreamObject.make.Constructor = StreamObject;
module.exports = StreamObject;

View File

@@ -0,0 +1,33 @@
'use strict';
const StreamBase = require('./StreamBase');
const withParser = require('../utils/withParser');
class StreamValues extends StreamBase {
static make(options) {
return new StreamValues(options);
}
static withParser(options) {
return withParser(StreamValues.make, Object.assign({}, options, {jsonStreaming: true}));
}
constructor(options) {
super(options);
this._counter = 0;
this._level = 0;
}
_push(discard) {
if (discard) {
++this._counter;
} else {
this.push({key: this._counter++, value: this._assembler.current});
}
this._assembler.current = this._assembler.key = null;
}
}
StreamValues.streamValues = StreamValues.make;
StreamValues.make.Constructor = StreamValues;
module.exports = StreamValues;

44
server/node_modules/stream-json/utils/Batch.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
'use strict';
const {Transform} = require('stream');
const withParser = require('./withParser');
class Batch extends Transform {
static make(options) {
return new Batch(options);
}
static withParser(options) {
return withParser(Batch.make, options);
}
constructor(options) {
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: true}));
this._batchSize = 1000;
if (options && typeof options.batchSize == 'number' && options.batchSize > 0) {
this._batchSize = options.batchSize;
}
this._accumulator = [];
}
_transform(chunk, _, callback) {
this._accumulator.push(chunk);
if (this._accumulator.length >= this._batchSize) {
this.push(this._accumulator);
this._accumulator = [];
}
callback(null);
}
_flush(callback) {
if (this._accumulator.length) {
this.push(this._accumulator);
this._accumulator = null;
}
callback(null);
}
}
Batch.batch = Batch.make;
Batch.make.Constructor = Batch;
module.exports = Batch;

53
server/node_modules/stream-json/utils/Utf8Stream.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
'use strict';
const {Transform} = require('stream');
const {StringDecoder} = require('string_decoder');
class Utf8Stream extends Transform {
constructor(options) {
super(Object.assign({}, options, {writableObjectMode: false}));
this._buffer = '';
}
_transform(chunk, encoding, callback) {
if (typeof chunk == 'string') {
this._transform = this._transformString;
} else {
this._stringDecoder = new StringDecoder();
this._transform = this._transformBuffer;
}
this._transform(chunk, encoding, callback);
}
_transformBuffer(chunk, _, callback) {
this._buffer += this._stringDecoder.write(chunk);
this._processBuffer(callback);
}
_transformString(chunk, _, callback) {
this._buffer += chunk.toString();
this._processBuffer(callback);
}
_processBuffer(callback) {
if (this._buffer) {
this.push(this._buffer, 'utf8');
this._buffer = '';
}
callback(null);
}
_flushInput() {
// meant to be called from _flush()
if (this._stringDecoder) {
this._buffer += this._stringDecoder.end();
}
}
_flush(callback) {
this._flushInput();
this._processBuffer(callback);
}
}
module.exports = Utf8Stream;

485
server/node_modules/stream-json/utils/Verifier.js generated vendored Normal file
View File

@@ -0,0 +1,485 @@
'use strict';
const {Writable} = require('stream');
const {StringDecoder} = require('string_decoder');
const patterns = {
value1: /^(?:[\"\{\[\]\-\d]|true\b|false\b|null\b|\s{1,256})/,
string: /^(?:[^\"\\]{1,256}|\\[bfnrt\"\\\/]|\\u[\da-fA-F]{4}|\")/,
key1: /^(?:[\"\}]|\s{1,256})/,
colon: /^(?:\:|\s{1,256})/,
comma: /^(?:[\,\]\}]|\s{1,256})/,
ws: /^\s{1,256}/,
numberStart: /^\d/,
numberDigit: /^\d{0,256}/,
numberFraction: /^[\.eE]/,
numberExponent: /^[eE]/,
numberExpSign: /^[-+]/
};
const MAX_PATTERN_SIZE = 16;
let noSticky = true;
try {
new RegExp('.', 'y');
noSticky = false;
} catch (e) {
// suppress
}
!noSticky &&
Object.keys(patterns).forEach(key => {
let src = patterns[key].source.slice(1); // lop off ^
if (src.slice(0, 3) === '(?:' && src.slice(-1) === ')') {
src = src.slice(3, -1);
}
patterns[key] = new RegExp(src, 'y');
});
patterns.numberFracStart = patterns.numberExpStart = patterns.numberStart;
patterns.numberFracDigit = patterns.numberExpDigit = patterns.numberDigit;
const eol = /[\u000A\u2028\u2029]|\u000D\u000A|\u000D/g;
const expected = {object: 'objectStop', array: 'arrayStop', '': 'done'};
class Verifier extends Writable {
static make(options) {
return new Verifier(options);
}
constructor(options) {
super(Object.assign({}, options, {objectMode: false}));
if (options) {
this._jsonStreaming = options.jsonStreaming;
}
this._buffer = '';
this._done = false;
this._expect = this._jsonStreaming ? 'done' : 'value';
this._stack = [];
this._parent = '';
this._line = this._pos = 1;
this._offset = 0;
}
_write(chunk, encoding, callback) {
if (typeof chunk == 'string') {
this._write = this._writeString;
} else {
this._stringDecoder = new StringDecoder();
this._write = this._writeBuffer;
}
this._write(chunk, encoding, callback);
}
_writeBuffer(chunk, _, callback) {
this._buffer += this._stringDecoder.write(chunk);
this._processBuffer(callback);
}
_writeString(chunk, _, callback) {
this._buffer += chunk.toString();
this._processBuffer(callback);
}
_final(callback) {
if (this._stringDecoder) {
this._buffer += this._stringDecoder.end();
}
this._done = true;
this._processBuffer(callback);
}
_makeError(msg) {
const error = new Error('ERROR at ' + this._offset + ' (' + this._line + ', ' + this._pos + '): ' + msg);
error.line = this._line;
error.pos = this._pos;
error.offset = this._offset;
return error;
}
_updatePos(value) {
let len = value.length;
this._offset += len;
value.replace(eol, (match, offset) => {
len = value.length - match.length - offset;
++this._line;
this._pos = 1;
return '';
});
this._pos += len;
}
_processBuffer(callback) {
let match,
value,
index = 0;
main: for (;;) {
switch (this._expect) {
case 'value1':
case 'value':
patterns.value1.lastIndex = index;
match = patterns.value1.exec(this._buffer);
if (!match) {
if (this._done || index + MAX_PATTERN_SIZE < this._buffer.length) {
if (index < this._buffer.length) return callback(this._makeError('Verifier cannot parse input: expected a value'));
return callback(this._makeError('Verifier has expected a value'));
}
break main; // wait for more input
}
value = match[0];
switch (value) {
case '"':
this._expect = 'string';
break;
case '{':
this._stack.push(this._parent);
this._parent = 'object';
this._expect = 'key1';
break;
case '[':
this._stack.push(this._parent);
this._parent = 'array';
this._expect = 'value1';
break;
case ']':
if (this._expect !== 'value1') return callback(this._makeError("Verifier cannot parse input: unexpected token ']'"));
this._parent = this._stack.pop();
this._expect = expected[this._parent];
break;
case '-':
this._expect = 'numberStart';
break;
case '0':
this._expect = 'numberFraction';
break;
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
this._expect = 'numberDigit';
break;
case 'true':
case 'false':
case 'null':
if (this._buffer.length - index === value.length && !this._done) break main; // wait for more input
this._expect = expected[this._parent];
break;
// default: // ws
}
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'keyVal':
case 'string':
patterns.string.lastIndex = index;
match = patterns.string.exec(this._buffer);
if (!match) {
if (index < this._buffer.length && (this._done || this._buffer.length - index >= 6))
return callback(this._makeError('Verifier cannot parse input: escaped characters'));
if (this._done) return callback(this._makeError('Verifier has expected a string value'));
break main; // wait for more input
}
value = match[0];
if (value === '"') {
if (this._expect === 'keyVal') {
this._expect = 'colon';
} else {
this._expect = expected[this._parent];
}
}
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'key1':
case 'key':
patterns.key1.lastIndex = index;
match = patterns.key1.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(this._makeError('Verifier cannot parse input: expected an object key'));
break main; // wait for more input
}
value = match[0];
if (value === '"') {
this._expect = 'keyVal';
} else if (value === '}') {
if (this._expect !== 'key1') return callback(this._makeError("Verifier cannot parse input: unexpected token '}'"));
this._parent = this._stack.pop();
this._expect = expected[this._parent];
}
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'colon':
patterns.colon.lastIndex = index;
match = patterns.colon.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(this._makeError("Verifier cannot parse input: expected ':'"));
break main; // wait for more input
}
value = match[0];
value === ':' && (this._expect = 'value');
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'arrayStop':
case 'objectStop':
patterns.comma.lastIndex = index;
match = patterns.comma.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(this._makeError("Verifier cannot parse input: expected ','"));
break main; // wait for more input
}
value = match[0];
if (value === ',') {
this._expect = this._expect === 'arrayStop' ? 'value' : 'key';
} else if (value === '}' || value === ']') {
if (value === '}' ? this._expect === 'arrayStop' : this._expect !== 'arrayStop') {
return callback(this._makeError("Verifier cannot parse input: expected '" + (this._expect === 'arrayStop' ? ']' : '}') + "'"));
}
this._parent = this._stack.pop();
this._expect = expected[this._parent];
}
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
// number chunks
case 'numberStart': // [0-9]
patterns.numberStart.lastIndex = index;
match = patterns.numberStart.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(this._makeError('Verifier cannot parse input: expected a starting digit'));
break main; // wait for more input
}
value = match[0];
this._expect = value === '0' ? 'numberFraction' : 'numberDigit';
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberDigit': // [0-9]*
patterns.numberDigit.lastIndex = index;
match = patterns.numberDigit.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) return callback(this._makeError('Verifier cannot parse input: expected a digit'));
break main; // wait for more input
}
value = match[0];
if (value) {
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
} else {
if (index < this._buffer.length) {
this._expect = 'numberFraction';
break;
}
if (this._done) {
this._expect = expected[this._parent];
break;
}
break main; // wait for more input
}
break;
case 'numberFraction': // [\.eE]?
patterns.numberFraction.lastIndex = index;
match = patterns.numberFraction.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done) {
this._expect = expected[this._parent];
break;
}
break main; // wait for more input
}
value = match[0];
this._expect = value === '.' ? 'numberFracStart' : 'numberExpSign';
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberFracStart': // [0-9]
patterns.numberFracStart.lastIndex = index;
match = patterns.numberFracStart.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done)
return callback(this._makeError('Verifier cannot parse input: expected a fractional part of a number'));
break main; // wait for more input
}
value = match[0];
this._expect = 'numberFracDigit';
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberFracDigit': // [0-9]*
patterns.numberFracDigit.lastIndex = index;
match = patterns.numberFracDigit.exec(this._buffer);
value = match[0];
if (value) {
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
} else {
if (index < this._buffer.length) {
this._expect = 'numberExponent';
break;
}
if (this._done) {
this._expect = expected[this._parent];
break;
}
break main; // wait for more input
}
break;
case 'numberExponent': // [eE]?
patterns.numberExponent.lastIndex = index;
match = patterns.numberExponent.exec(this._buffer);
if (!match) {
if (index < this._buffer.length) {
this._expect = expected[this._parent];
break;
}
if (this._done) {
this._expect = 'done';
break;
}
break main; // wait for more input
}
value = match[0];
this._expect = 'numberExpSign';
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberExpSign': // [-+]?
patterns.numberExpSign.lastIndex = index;
match = patterns.numberExpSign.exec(this._buffer);
if (!match) {
if (index < this._buffer.length) {
this._expect = 'numberExpStart';
break;
}
if (this._done) return callback(this._makeError('Verifier has expected an exponent value of a number'));
break main; // wait for more input
}
value = match[0];
this._expect = 'numberExpStart';
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberExpStart': // [0-9]
patterns.numberExpStart.lastIndex = index;
match = patterns.numberExpStart.exec(this._buffer);
if (!match) {
if (index < this._buffer.length || this._done)
return callback(this._makeError('Verifier cannot parse input: expected an exponent part of a number'));
break main; // wait for more input
}
value = match[0];
this._expect = 'numberExpDigit';
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
case 'numberExpDigit': // [0-9]*
patterns.numberExpDigit.lastIndex = index;
match = patterns.numberExpDigit.exec(this._buffer);
value = match[0];
if (value) {
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
} else {
if (index < this._buffer.length || this._done) {
this._expect = expected[this._parent];
break;
}
break main; // wait for more input
}
break;
case 'done':
patterns.ws.lastIndex = index;
match = patterns.ws.exec(this._buffer);
if (!match) {
if (index < this._buffer.length) {
if (this._jsonStreaming) {
this._expect = 'value';
break;
}
return callback(this._makeError('Verifier cannot parse input: unexpected characters'));
}
break main; // wait for more input
}
value = match[0];
this._updatePos(value);
if (noSticky) {
this._buffer = this._buffer.slice(value.length);
} else {
index += value.length;
}
break;
}
}
!noSticky && (this._buffer = this._buffer.slice(index));
callback(null);
}
}
Verifier.verifier = Verifier.make;
Verifier.make.Constructor = Verifier;
module.exports = Verifier;

5
server/node_modules/stream-json/utils/emit.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
'use strict';
const emit = stream => stream.on('data', item => stream.emit(item.name, item.value));
module.exports = emit;

10
server/node_modules/stream-json/utils/withParser.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
'use strict';
const Chain = require('stream-chain');
const Parser = require('../Parser');
const withParser = (fn, options) =>
new Chain([new Parser(options), fn(options)], Object.assign({}, options, {writableObjectMode: false, readableObjectMode: true}));
module.exports = withParser;