feat: adding linter for commits

This commit is contained in:
Carlos Gutierrez
2021-11-22 09:39:27 -06:00
commit 2c7c117aa1
3093 changed files with 1215197 additions and 0 deletions

1
node_modules/jsonparse/.npmignore generated vendored Normal file
View File

@ -0,0 +1 @@
node_modules

24
node_modules/jsonparse/LICENSE generated vendored Normal file
View File

@ -0,0 +1,24 @@
The MIT License
Copyright (c) 2012 Tim Caswell
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

11
node_modules/jsonparse/README.markdown generated vendored Normal file
View File

@ -0,0 +1,11 @@
This is a streaming JSON parser. For a simpler, sax-based version see this gist: https://gist.github.com/1821394
The MIT License (MIT)
Copyright (c) 2011-2012 Tim Caswell
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

26
node_modules/jsonparse/bench.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
var fs = require('fs'),
Parser = require('./jsonparse');
var json = fs.readFileSync("samplejson/basic.json");
while (true) {
var start = Date.now();
for (var i = 0; i < 1000; i++) {
JSON.parse(json);
}
var first = Date.now() - start;
start = Date.now();
var p = new Parser();
for (var i = 0; i < 1000; i++) {
p.write(json);
}
var second = Date.now() - start;
console.log("JSON.parse took %s", first);
console.log("streaming parser took %s", second);
console.log("streaming is %s times slower", second / first);
}

30
node_modules/jsonparse/examples/twitterfeed.js generated vendored Normal file
View File

@ -0,0 +1,30 @@
var Parser = require('../jsonparse');
var Http = require('http');
require('./colors');
var p = new Parser();
var cred = require('./credentials');
var client = Http.createClient(80, "stream.twitter.com");
var request = client.request("GET", "/1/statuses/sample.json", {
"Host": "stream.twitter.com",
"Authorization": (new Buffer(cred.username + ":" + cred.password)).toString("base64")
});
request.on('response', function (response) {
console.log(response.statusCode);
console.dir(response.headers);
response.on('data', function (chunk) {
p.write(chunk);
});
response.on('end', function () {
console.log("END");
});
});
request.end();
var text = "", name = "";
p.onValue = function (value) {
if (this.stack.length === 1 && this.key === 'text') { text = value; }
if (this.stack.length === 2 && this.key === 'name' && this.stack[1].key === 'user') { name = value; }
if (this.stack.length === 0) {
console.log(text.blue + " - " + name.yellow);
text = name = "";
}
};

413
node_modules/jsonparse/jsonparse.js generated vendored Normal file
View File

@ -0,0 +1,413 @@
/*global Buffer*/
// Named constants with unique integer values
var C = {};
// Tokens
var LEFT_BRACE = C.LEFT_BRACE = 0x1;
var RIGHT_BRACE = C.RIGHT_BRACE = 0x2;
var LEFT_BRACKET = C.LEFT_BRACKET = 0x3;
var RIGHT_BRACKET = C.RIGHT_BRACKET = 0x4;
var COLON = C.COLON = 0x5;
var COMMA = C.COMMA = 0x6;
var TRUE = C.TRUE = 0x7;
var FALSE = C.FALSE = 0x8;
var NULL = C.NULL = 0x9;
var STRING = C.STRING = 0xa;
var NUMBER = C.NUMBER = 0xb;
// Tokenizer States
var START = C.START = 0x11;
var STOP = C.STOP = 0x12;
var TRUE1 = C.TRUE1 = 0x21;
var TRUE2 = C.TRUE2 = 0x22;
var TRUE3 = C.TRUE3 = 0x23;
var FALSE1 = C.FALSE1 = 0x31;
var FALSE2 = C.FALSE2 = 0x32;
var FALSE3 = C.FALSE3 = 0x33;
var FALSE4 = C.FALSE4 = 0x34;
var NULL1 = C.NULL1 = 0x41;
var NULL2 = C.NULL2 = 0x42;
var NULL3 = C.NULL3 = 0x43;
var NUMBER1 = C.NUMBER1 = 0x51;
var NUMBER3 = C.NUMBER3 = 0x53;
var STRING1 = C.STRING1 = 0x61;
var STRING2 = C.STRING2 = 0x62;
var STRING3 = C.STRING3 = 0x63;
var STRING4 = C.STRING4 = 0x64;
var STRING5 = C.STRING5 = 0x65;
var STRING6 = C.STRING6 = 0x66;
// Parser States
var VALUE = C.VALUE = 0x71;
var KEY = C.KEY = 0x72;
// Parser Modes
var OBJECT = C.OBJECT = 0x81;
var ARRAY = C.ARRAY = 0x82;
// Character constants
var BACK_SLASH = "\\".charCodeAt(0);
var FORWARD_SLASH = "\/".charCodeAt(0);
var BACKSPACE = "\b".charCodeAt(0);
var FORM_FEED = "\f".charCodeAt(0);
var NEWLINE = "\n".charCodeAt(0);
var CARRIAGE_RETURN = "\r".charCodeAt(0);
var TAB = "\t".charCodeAt(0);
var STRING_BUFFER_SIZE = 64 * 1024;
function Parser() {
this.tState = START;
this.value = undefined;
this.string = undefined; // string data
this.stringBuffer = Buffer.alloc ? Buffer.alloc(STRING_BUFFER_SIZE) : new Buffer(STRING_BUFFER_SIZE);
this.stringBufferOffset = 0;
this.unicode = undefined; // unicode escapes
this.highSurrogate = undefined;
this.key = undefined;
this.mode = undefined;
this.stack = [];
this.state = VALUE;
this.bytes_remaining = 0; // number of bytes remaining in multi byte utf8 char to read after split boundary
this.bytes_in_sequence = 0; // bytes in multi byte utf8 char to read
this.temp_buffs = { "2": new Buffer(2), "3": new Buffer(3), "4": new Buffer(4) }; // for rebuilding chars split before boundary is reached
// Stream offset
this.offset = -1;
}
// Slow code to string converter (only used when throwing syntax errors)
Parser.toknam = function (code) {
var keys = Object.keys(C);
for (var i = 0, l = keys.length; i < l; i++) {
var key = keys[i];
if (C[key] === code) { return key; }
}
return code && ("0x" + code.toString(16));
};
var proto = Parser.prototype;
proto.onError = function (err) { throw err; };
proto.charError = function (buffer, i) {
this.tState = STOP;
this.onError(new Error("Unexpected " + JSON.stringify(String.fromCharCode(buffer[i])) + " at position " + i + " in state " + Parser.toknam(this.tState)));
};
proto.appendStringChar = function (char) {
if (this.stringBufferOffset >= STRING_BUFFER_SIZE) {
this.string += this.stringBuffer.toString('utf8');
this.stringBufferOffset = 0;
}
this.stringBuffer[this.stringBufferOffset++] = char;
};
proto.appendStringBuf = function (buf, start, end) {
var size = buf.length;
if (typeof start === 'number') {
if (typeof end === 'number') {
if (end < 0) {
// adding a negative end decreeses the size
size = buf.length - start + end;
} else {
size = end - start;
}
} else {
size = buf.length - start;
}
}
if (size < 0) {
size = 0;
}
if (this.stringBufferOffset + size > STRING_BUFFER_SIZE) {
this.string += this.stringBuffer.toString('utf8', 0, this.stringBufferOffset);
this.stringBufferOffset = 0;
}
buf.copy(this.stringBuffer, this.stringBufferOffset, start, end);
this.stringBufferOffset += size;
};
proto.write = function (buffer) {
if (typeof buffer === "string") buffer = new Buffer(buffer);
var n;
for (var i = 0, l = buffer.length; i < l; i++) {
if (this.tState === START){
n = buffer[i];
this.offset++;
if(n === 0x7b){ this.onToken(LEFT_BRACE, "{"); // {
}else if(n === 0x7d){ this.onToken(RIGHT_BRACE, "}"); // }
}else if(n === 0x5b){ this.onToken(LEFT_BRACKET, "["); // [
}else if(n === 0x5d){ this.onToken(RIGHT_BRACKET, "]"); // ]
}else if(n === 0x3a){ this.onToken(COLON, ":"); // :
}else if(n === 0x2c){ this.onToken(COMMA, ","); // ,
}else if(n === 0x74){ this.tState = TRUE1; // t
}else if(n === 0x66){ this.tState = FALSE1; // f
}else if(n === 0x6e){ this.tState = NULL1; // n
}else if(n === 0x22){ // "
this.string = "";
this.stringBufferOffset = 0;
this.tState = STRING1;
}else if(n === 0x2d){ this.string = "-"; this.tState = NUMBER1; // -
}else{
if (n >= 0x30 && n < 0x40) { // 1-9
this.string = String.fromCharCode(n); this.tState = NUMBER3;
} else if (n === 0x20 || n === 0x09 || n === 0x0a || n === 0x0d) {
// whitespace
} else {
return this.charError(buffer, i);
}
}
}else if (this.tState === STRING1){ // After open quote
n = buffer[i]; // get current byte from buffer
// check for carry over of a multi byte char split between data chunks
// & fill temp buffer it with start of this data chunk up to the boundary limit set in the last iteration
if (this.bytes_remaining > 0) {
for (var j = 0; j < this.bytes_remaining; j++) {
this.temp_buffs[this.bytes_in_sequence][this.bytes_in_sequence - this.bytes_remaining + j] = buffer[j];
}
this.appendStringBuf(this.temp_buffs[this.bytes_in_sequence]);
this.bytes_in_sequence = this.bytes_remaining = 0;
i = i + j - 1;
} else if (this.bytes_remaining === 0 && n >= 128) { // else if no remainder bytes carried over, parse multi byte (>=128) chars one at a time
if (n <= 193 || n > 244) {
return this.onError(new Error("Invalid UTF-8 character at position " + i + " in state " + Parser.toknam(this.tState)));
}
if ((n >= 194) && (n <= 223)) this.bytes_in_sequence = 2;
if ((n >= 224) && (n <= 239)) this.bytes_in_sequence = 3;
if ((n >= 240) && (n <= 244)) this.bytes_in_sequence = 4;
if ((this.bytes_in_sequence + i) > buffer.length) { // if bytes needed to complete char fall outside buffer length, we have a boundary split
for (var k = 0; k <= (buffer.length - 1 - i); k++) {
this.temp_buffs[this.bytes_in_sequence][k] = buffer[i + k]; // fill temp buffer of correct size with bytes available in this chunk
}
this.bytes_remaining = (i + this.bytes_in_sequence) - buffer.length;
i = buffer.length - 1;
} else {
this.appendStringBuf(buffer, i, i + this.bytes_in_sequence);
i = i + this.bytes_in_sequence - 1;
}
} else if (n === 0x22) {
this.tState = START;
this.string += this.stringBuffer.toString('utf8', 0, this.stringBufferOffset);
this.stringBufferOffset = 0;
this.onToken(STRING, this.string);
this.offset += Buffer.byteLength(this.string, 'utf8') + 1;
this.string = undefined;
}
else if (n === 0x5c) {
this.tState = STRING2;
}
else if (n >= 0x20) { this.appendStringChar(n); }
else {
return this.charError(buffer, i);
}
}else if (this.tState === STRING2){ // After backslash
n = buffer[i];
if(n === 0x22){ this.appendStringChar(n); this.tState = STRING1;
}else if(n === 0x5c){ this.appendStringChar(BACK_SLASH); this.tState = STRING1;
}else if(n === 0x2f){ this.appendStringChar(FORWARD_SLASH); this.tState = STRING1;
}else if(n === 0x62){ this.appendStringChar(BACKSPACE); this.tState = STRING1;
}else if(n === 0x66){ this.appendStringChar(FORM_FEED); this.tState = STRING1;
}else if(n === 0x6e){ this.appendStringChar(NEWLINE); this.tState = STRING1;
}else if(n === 0x72){ this.appendStringChar(CARRIAGE_RETURN); this.tState = STRING1;
}else if(n === 0x74){ this.appendStringChar(TAB); this.tState = STRING1;
}else if(n === 0x75){ this.unicode = ""; this.tState = STRING3;
}else{
return this.charError(buffer, i);
}
}else if (this.tState === STRING3 || this.tState === STRING4 || this.tState === STRING5 || this.tState === STRING6){ // unicode hex codes
n = buffer[i];
// 0-9 A-F a-f
if ((n >= 0x30 && n < 0x40) || (n > 0x40 && n <= 0x46) || (n > 0x60 && n <= 0x66)) {
this.unicode += String.fromCharCode(n);
if (this.tState++ === STRING6) {
var intVal = parseInt(this.unicode, 16);
this.unicode = undefined;
if (this.highSurrogate !== undefined && intVal >= 0xDC00 && intVal < (0xDFFF + 1)) { //<56320,57343> - lowSurrogate
this.appendStringBuf(new Buffer(String.fromCharCode(this.highSurrogate, intVal)));
this.highSurrogate = undefined;
} else if (this.highSurrogate === undefined && intVal >= 0xD800 && intVal < (0xDBFF + 1)) { //<55296,56319> - highSurrogate
this.highSurrogate = intVal;
} else {
if (this.highSurrogate !== undefined) {
this.appendStringBuf(new Buffer(String.fromCharCode(this.highSurrogate)));
this.highSurrogate = undefined;
}
this.appendStringBuf(new Buffer(String.fromCharCode(intVal)));
}
this.tState = STRING1;
}
} else {
return this.charError(buffer, i);
}
} else if (this.tState === NUMBER1 || this.tState === NUMBER3) {
n = buffer[i];
switch (n) {
case 0x30: // 0
case 0x31: // 1
case 0x32: // 2
case 0x33: // 3
case 0x34: // 4
case 0x35: // 5
case 0x36: // 6
case 0x37: // 7
case 0x38: // 8
case 0x39: // 9
case 0x2e: // .
case 0x65: // e
case 0x45: // E
case 0x2b: // +
case 0x2d: // -
this.string += String.fromCharCode(n);
this.tState = NUMBER3;
break;
default:
this.tState = START;
var result = Number(this.string);
if (isNaN(result)){
return this.charError(buffer, i);
}
if ((this.string.match(/[0-9]+/) == this.string) && (result.toString() != this.string)) {
// Long string of digits which is an ID string and not valid and/or safe JavaScript integer Number
this.onToken(STRING, this.string);
} else {
this.onToken(NUMBER, result);
}
this.offset += this.string.length - 1;
this.string = undefined;
i--;
break;
}
}else if (this.tState === TRUE1){ // r
if (buffer[i] === 0x72) { this.tState = TRUE2; }
else { return this.charError(buffer, i); }
}else if (this.tState === TRUE2){ // u
if (buffer[i] === 0x75) { this.tState = TRUE3; }
else { return this.charError(buffer, i); }
}else if (this.tState === TRUE3){ // e
if (buffer[i] === 0x65) { this.tState = START; this.onToken(TRUE, true); this.offset+= 3; }
else { return this.charError(buffer, i); }
}else if (this.tState === FALSE1){ // a
if (buffer[i] === 0x61) { this.tState = FALSE2; }
else { return this.charError(buffer, i); }
}else if (this.tState === FALSE2){ // l
if (buffer[i] === 0x6c) { this.tState = FALSE3; }
else { return this.charError(buffer, i); }
}else if (this.tState === FALSE3){ // s
if (buffer[i] === 0x73) { this.tState = FALSE4; }
else { return this.charError(buffer, i); }
}else if (this.tState === FALSE4){ // e
if (buffer[i] === 0x65) { this.tState = START; this.onToken(FALSE, false); this.offset+= 4; }
else { return this.charError(buffer, i); }
}else if (this.tState === NULL1){ // u
if (buffer[i] === 0x75) { this.tState = NULL2; }
else { return this.charError(buffer, i); }
}else if (this.tState === NULL2){ // l
if (buffer[i] === 0x6c) { this.tState = NULL3; }
else { return this.charError(buffer, i); }
}else if (this.tState === NULL3){ // l
if (buffer[i] === 0x6c) { this.tState = START; this.onToken(NULL, null); this.offset += 3; }
else { return this.charError(buffer, i); }
}
}
};
proto.onToken = function (token, value) {
// Override this to get events
};
proto.parseError = function (token, value) {
this.tState = STOP;
this.onError(new Error("Unexpected " + Parser.toknam(token) + (value ? ("(" + JSON.stringify(value) + ")") : "") + " in state " + Parser.toknam(this.state)));
};
proto.push = function () {
this.stack.push({value: this.value, key: this.key, mode: this.mode});
};
proto.pop = function () {
var value = this.value;
var parent = this.stack.pop();
this.value = parent.value;
this.key = parent.key;
this.mode = parent.mode;
this.emit(value);
if (!this.mode) { this.state = VALUE; }
};
proto.emit = function (value) {
if (this.mode) { this.state = COMMA; }
this.onValue(value);
};
proto.onValue = function (value) {
// Override me
};
proto.onToken = function (token, value) {
if(this.state === VALUE){
if(token === STRING || token === NUMBER || token === TRUE || token === FALSE || token === NULL){
if (this.value) {
this.value[this.key] = value;
}
this.emit(value);
}else if(token === LEFT_BRACE){
this.push();
if (this.value) {
this.value = this.value[this.key] = {};
} else {
this.value = {};
}
this.key = undefined;
this.state = KEY;
this.mode = OBJECT;
}else if(token === LEFT_BRACKET){
this.push();
if (this.value) {
this.value = this.value[this.key] = [];
} else {
this.value = [];
}
this.key = 0;
this.mode = ARRAY;
this.state = VALUE;
}else if(token === RIGHT_BRACE){
if (this.mode === OBJECT) {
this.pop();
} else {
return this.parseError(token, value);
}
}else if(token === RIGHT_BRACKET){
if (this.mode === ARRAY) {
this.pop();
} else {
return this.parseError(token, value);
}
}else{
return this.parseError(token, value);
}
}else if(this.state === KEY){
if (token === STRING) {
this.key = value;
this.state = COLON;
} else if (token === RIGHT_BRACE) {
this.pop();
} else {
return this.parseError(token, value);
}
}else if(this.state === COLON){
if (token === COLON) { this.state = VALUE; }
else { return this.parseError(token, value); }
}else if(this.state === COMMA){
if (token === COMMA) {
if (this.mode === ARRAY) { this.key++; this.state = VALUE; }
else if (this.mode === OBJECT) { this.state = KEY; }
} else if (token === RIGHT_BRACKET && this.mode === ARRAY || token === RIGHT_BRACE && this.mode === OBJECT) {
this.pop();
} else {
return this.parseError(token, value);
}
}else{
return this.parseError(token, value);
}
};
Parser.C = C;
module.exports = Parser;

22
node_modules/jsonparse/package.json generated vendored Normal file
View File

@ -0,0 +1,22 @@
{
"name": "jsonparse",
"description": "This is a pure-js JSON streaming parser for node.js",
"tags": ["json", "stream"],
"version": "1.3.1",
"author": "Tim Caswell <tim@creationix.com>",
"repository": {
"type": "git",
"url": "http://github.com/creationix/jsonparse.git"
},
"devDependencies": {
"tape": "~0.1.1",
"tap": "~0.3.3"
},
"scripts": {
"test": "tap test/*.js"
},
"bugs": "http://github.com/creationix/jsonparse/issues",
"engines": ["node >= 0.2.0"],
"license": "MIT",
"main": "jsonparse.js"
}

167
node_modules/jsonparse/samplejson/basic.json generated vendored Normal file
View File

@ -0,0 +1,167 @@
[
{
},
{
"image": [
{"shape": "rect", "fill": "#333", "stroke": "#999", "x": 0.5e+1, "y": 0.5, "z": 0.8e-0, "w": 0.5e5, "u": 2E10, "foo": 2E+1, "bar": 2E-0, "width": 47, "height": 47}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [2,6],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": true,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#248", "stroke": "#48f", "points": [[0.5,47.5],[47.5,47.5],[47.5,0.5]]}
],
"solid": {
"1": [2,4],
"2": [1],
"3": [2],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": false,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#248", "stroke": "#48f", "points": [[0.5,0.5],[47.5,47.5],[0.5,47.5]]}
],
"solid": {
"1": [2],
"2": [3],
"3": [2,6],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": true,"9": false}
},
{
"image": [
{"shape": "polygon", "fill": "#333", "stroke": "#999", "points": [[0.5,0.5],[47.5,47.5],[47.5,0.5]]}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [2,6],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [3],
"7": [4,8],
"8": [7],
"9": [6,8]
},
"corners": {"1": false,"3": true,"7": true,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#333", "stroke": "#999", "points": [[0.5,0.5],[0.5,47.5],[47.5,0.5]]}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [2,6],
"4": [1],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [9],
"9": [6,8]
},
"corners": {"1": true,"3": false,"7": true,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#482", "stroke": "#8f4", "points": [[0.5,47.5],[0.5,23.5],[24.5,23.5],[24.5,0.5],[47.5,0.5],[47.5,47.5]]}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [6,2],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [9],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": false,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#482", "stroke": "#8f4", "points": [[0.5,0.5],[23.5,0.5],[23.5,24.5],[47.5,24.5],[47.5,47.5],[0.5,47.5]]}
],
"jumpable": 3,
"solid": {
"1": [4,2],
"2": [],
"3": [2,6],
"4": [7],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": true,"9": false}
},
{
"image": [
{"shape": "circle", "fill": "#ff0", "stroke": "#ff8", "cx": 24, "cy": 24, "r": 18}
],
"item": true
},
{
"image": [
{"shape": "polygon", "fill": "#842", "stroke": "#f84", "points": [[4.5,0.5],[14.5,0.5],[14.5,17.5],[34,17.5],[33.5,0.5],[43.5,0.5],[43.5,47.5],[33.5,47.5],[33.5,30.5],[14.5,30.5],[14.5,47.5],[4.5,47.5]]}
],
"jumpable": 3
},
{
"image": [
{"shape": "polygon", "fill": "#333", "stroke": "#999", "points": [[0.5,0.5],[47.5,0.5],[24,47.5]]}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [2,6],
"4": [1],
"5": [2,8,1,3,7,9,4,6],
"6": [3],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": false,"3": false,"7": true,"9": true}
},
{
"image": [
{"shape": "rect", "fill": "#114acb", "x": 0.5, "y": 0.5, "width": 47, "height": 47},
{"shape": "polygon", "fill": "rgba(255,255,255,0.30)", "points": [[0.5,0.5],[47.5,0.5],[40,8],[8,8],[8,40],[0.5,47.5]]},
{"shape": "polygon", "fill": "rgba(0,0,0,0.30)", "points": [[47.5,0.5],[48,48],[0.5,47.5],[8,40],[40,40],[40,8]]},
{"shape": "polygon", "fill": "rgb(255,255,0)", "stroke": "rgba(255,255,0,0.5)", "points": [[24,9],[35,20],[26,29],[26,33],[22,33],[22,27],[29,20],[24,15],[16,23],[13,20]]},
{"shape": "rect", "fill": "rgb(255,255,0)", "stroke": "rgba(255,255,0,0.5)", "x": 22, "y":35, "width": 4, "height": 4}
]
}
]

180
node_modules/jsonparse/samplejson/basic2.json generated vendored Normal file
View File

@ -0,0 +1,180 @@
[
{
},
{
"image": [
{"shape": "rect", "fill": "#333", "stroke": "#999", "x": 0.5, "y": 0.5, "width": 47, "height": 47}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [2,6],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": true,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#248", "stroke": "#48f", "points": [[0.5,47.5],[47.5,47.5],[47.5,0.5]]}
],
"solid": {
"1": [2,4],
"2": [1],
"3": [2],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": false,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#248", "stroke": "#48f", "points": [[0.5,0.5],[47.5,47.5],[0.5,47.5]]}
],
"solid": {
"1": [2],
"2": [3],
"3": [2,6],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": true,"9": false}
},
{
"image": [
{"shape": "polygon", "fill": "#333", "stroke": "#999", "points": [[0.5,0.5],[47.5,47.5],[47.5,0.5]]}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [2,6],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [3],
"7": [4,8],
"8": [7],
"9": [6,8]
},
"corners": {"1": false,"3": true,"7": true,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#333", "stroke": "#999", "points": [[0.5,0.5],[0.5,47.5],[47.5,0.5]]}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [2,6],
"4": [1],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [9],
"9": [6,8]
},
"corners": {"1": true,"3": false,"7": true,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#482", "stroke": "#8f4", "points": [[0.5,47.5],[0.5,23.5],[24.5,23.5],[24.5,0.5],[47.5,0.5],[47.5,47.5]]}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [6,2],
"4": [],
"5": [2,8,1,3,7,9,4,6],
"6": [9],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": false,"9": true}
},
{
"image": [
{"shape": "polygon", "fill": "#482", "stroke": "#8f4", "points": [[0.5,0.5],[23.5,0.5],[23.5,24.5],[47.5,24.5],[47.5,47.5],[0.5,47.5]]}
],
"jumpable": 3,
"solid": {
"1": [4,2],
"2": [],
"3": [2,6],
"4": [7],
"5": [2,8,1,3,7,9,4,6],
"6": [],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": true,"3": true,"7": true,"9": false}
},
{
"image": [
{"shape": "circle", "fill": "#ff0", "stroke": "#ff8", "cx": 24, "cy": 24, "r": 18}
],
"item": true
},
{
"image": [
{"shape": "polygon", "fill": "#842", "stroke": "#f84", "points": [[4.5,0.5],[14.5,0.5],[14.5,17.5],[34,17.5],[33.5,0.5],[43.5,0.5],[43.5,47.5],[33.5,47.5],[33.5,30.5],[14.5,30.5],[14.5,47.5],[4.5,47.5]]}
],
"jumpable": 3
},
{
"image": [
{"shape": "polygon", "fill": "#333", "stroke": "#999", "points": [[0.5,0.5],[47.5,0.5],[24,47.5]]}
],
"jumpable": 3,
"solid": {
"1": [2,4],
"2": [],
"3": [2,6],
"4": [1],
"5": [2,8,1,3,7,9,4,6],
"6": [3],
"7": [4,8],
"8": [],
"9": [6,8]
},
"corners": {"1": false,"3": false,"7": true,"9": true}
},
{
"image": [
{"shape": "rect", "fill": "#114acb", "x": 0.5, "y": 0.5, "width": 47, "height": 47},
{"shape": "polygon", "fill": "rgba(255,255,255,0.30)", "points": [[0.5,0.5],[47.5,0.5],[40,8],[8,8],[8,40],[0.5,47.5]]},
{"shape": "polygon", "fill": "rgba(0,0,0,0.30)", "points": [[47.5,0.5],[48,48],[0.5,47.5],[8,40],[40,40],[40,8]]},
{"shape": "polygon", "fill": "rgb(255,255,0)", "stroke": "rgba(255,255,0,0.5)", "points": [[24,9],[35,20],[26,29],[26,33],[22,33],[22,27],[29,20],[24,15],[16,23],[13,20]]},
{"shape": "rect", "fill": "rgb(255,255,0)", "stroke": "rgba(255,255,0,0.5)", "x": 22, "y":35, "width": 4, "height": 4}
],
"item": true
},
{
"image": [
{"shape": "circle", "fill": "#80f", "stroke": "#88f", "cx": 24, "cy": 24, "r": 18}
],
"item": true
},
{
"image": [
{"shape": "circle", "fill": "#4f4", "stroke": "#8f8", "cx": 24, "cy": 24, "r": 18}
],
"item": true
}
]

24
node_modules/jsonparse/test/big-token.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
var stream = require('stream');
var JsonParse = require('../jsonparse');
var test = require('tape');
test('can handle large tokens without running out of memory', function (t) {
var parser = new JsonParse();
var chunkSize = 1024;
var chunks = 1024 * 200; // 200mb
var quote = Buffer.from ? Buffer.from('"') : new Buffer('"');
t.plan(1);
parser.onToken = function (type, value) {
t.equal(value.length, chunkSize * chunks, 'token should be size of input json');
t.end();
};
parser.write(quote);
for (var i = 0; i < chunks; ++i) {
var buf = Buffer.alloc ? Buffer.alloc(chunkSize) : new Buffer(chunkSize);
buf.fill('a');
parser.write(buf);
}
parser.write(quote);
});

110
node_modules/jsonparse/test/boundary.js generated vendored Normal file
View File

@ -0,0 +1,110 @@
var test = require('tape');
var Parser = require('../');
test('2 byte utf8 \'De\' character: д', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, 'д');
};
var de_buffer = new Buffer([0xd0, 0xb4]);
p.write('"');
p.write(de_buffer);
p.write('"');
});
test('3 byte utf8 \'Han\' character: 我', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, '我');
};
var han_buffer = new Buffer([0xe6, 0x88, 0x91]);
p.write('"');
p.write(han_buffer);
p.write('"');
});
test('4 byte utf8 character (unicode scalar U+2070E): 𠜎', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, '𠜎');
};
var Ux2070E_buffer = new Buffer([0xf0, 0xa0, 0x9c, 0x8e]);
p.write('"');
p.write(Ux2070E_buffer);
p.write('"');
});
test('3 byte utf8 \'Han\' character chunked inbetween 2nd and 3rd byte: 我', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, '我');
};
var han_buffer_first = new Buffer([0xe6, 0x88]);
var han_buffer_second = new Buffer([0x91]);
p.write('"');
p.write(han_buffer_first);
p.write(han_buffer_second);
p.write('"');
});
test('4 byte utf8 character (unicode scalar U+2070E) chunked inbetween 2nd and 3rd byte: 𠜎', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, '𠜎');
};
var Ux2070E_buffer_first = new Buffer([0xf0, 0xa0]);
var Ux2070E_buffer_second = new Buffer([0x9c, 0x8e]);
p.write('"');
p.write(Ux2070E_buffer_first);
p.write(Ux2070E_buffer_second);
p.write('"');
});
test('1-4 byte utf8 character string chunked inbetween random bytes: Aж文𠜱B', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, 'Aж文𠜱B');
};
var eclectic_buffer = new Buffer([0x41, // A
0xd0, 0xb6, // ж
0xe6, 0x96, 0x87, // 文
0xf0, 0xa0, 0x9c, 0xb1, // 𠜱
0x42]); // B
var rand_chunk = Math.floor(Math.random() * (eclectic_buffer.length));
var first_buffer = eclectic_buffer.slice(0, rand_chunk);
var second_buffer = eclectic_buffer.slice(rand_chunk);
//console.log('eclectic_buffer: ' + eclectic_buffer)
//console.log('sliced from 0 to ' + rand_chunk);
//console.log(first_buffer);
//console.log('then sliced from ' + rand_chunk + ' to the end');
//console.log(second_buffer);
console.log('chunked after offset ' + rand_chunk);
p.write('"');
p.write(first_buffer);
p.write(second_buffer);
p.write('"');
});

67
node_modules/jsonparse/test/offset.js generated vendored Normal file
View File

@ -0,0 +1,67 @@
var test = require('tape');
var Parser = require('../');
var input = '{\n "string": "value",\n "number": 3,\n "object"';
var input2 = ': {\n "key": "vд"\n },\n "array": [\n -1,\n 12\n ]\n ';
var input3 = '"null": null, "true": true, "false": false, "frac": 3.14 }';
var offsets = [
[ 0, Parser.C.LEFT_BRACE ],
[ 4, Parser.C.STRING ],
[ 12, Parser.C.COLON ],
[ 14, Parser.C.STRING ],
[ 21, Parser.C.COMMA ],
[ 25, Parser.C.STRING ],
[ 33, Parser.C.COLON ],
[ 35, Parser.C.NUMBER ],
[ 36, Parser.C.COMMA ],
[ 40, Parser.C.STRING ],
[ 48, Parser.C.COLON ],
[ 50, Parser.C.LEFT_BRACE ],
[ 54, Parser.C.STRING ],
[ 59, Parser.C.COLON ],
[ 61, Parser.C.STRING ],
[ 69, Parser.C.RIGHT_BRACE ],
[ 70, Parser.C.COMMA ],
[ 74, Parser.C.STRING ],
[ 81, Parser.C.COLON ],
[ 83, Parser.C.LEFT_BRACKET ],
[ 87, Parser.C.NUMBER ],
[ 89, Parser.C.COMMA ],
[ 93, Parser.C.NUMBER ],
[ 98, Parser.C.RIGHT_BRACKET ],
[ 102, Parser.C.STRING ],
[ 108, Parser.C.COLON ],
[ 110, Parser.C.NULL ],
[ 114, Parser.C.COMMA ],
[ 116, Parser.C.STRING ],
[ 122, Parser.C.COLON ],
[ 124, Parser.C.TRUE ],
[ 128, Parser.C.COMMA ],
[ 130, Parser.C.STRING ],
[ 137, Parser.C.COLON ],
[ 139, Parser.C.FALSE ],
[ 144, Parser.C.COMMA ],
[ 146, Parser.C.STRING ],
[ 152, Parser.C.COLON ],
[ 154, Parser.C.NUMBER ],
[ 159, Parser.C.RIGHT_BRACE ]
];
test('offset', function(t) {
t.plan(offsets.length * 2 + 1);
var p = new Parser();
var i = 0;
p.onToken = function (token) {
t.equal(p.offset, offsets[i][0]);
t.equal(token, offsets[i][1]);
i++;
};
p.write(input);
p.write(input2);
p.write(input3);
t.equal(i, offsets.length);
});

57
node_modules/jsonparse/test/primitives.js generated vendored Normal file
View File

@ -0,0 +1,57 @@
var test = require('tape');
var Parser = require('../');
var expected = [
[ [], '' ],
[ [], 'Hello' ],
[ [], 'This"is' ],
[ [], '\r\n\f\t\\/"' ],
[ [], 'Λάμβδα' ],
[ [], '\\' ],
[ [], '/' ],
[ [], '"' ],
[ [ 0 ], 0 ],
[ [ 1 ], 1 ],
[ [ 2 ], -1 ],
[ [], [ 0, 1, -1 ] ],
[ [ 0 ], 1 ],
[ [ 1 ], 1.1 ],
[ [ 2 ], -1.1 ],
[ [ 3 ], -1 ],
[ [], [ 1, 1.1, -1.1, -1 ] ],
[ [ 0 ], -1 ],
[ [], [ -1 ] ],
[ [ 0 ], -0.1 ],
[ [], [ -0.1 ] ],
[ [ 0 ], 6.02e+23 ],
[ [], [ 6.02e+23 ] ],
[ [ 0 ], '7161093205057351174' ],
[ [], [ '7161093205057351174'] ]
];
test('primitives', function (t) {
t.plan(25);
var p = new Parser();
p.onValue = function (value) {
var keys = this.stack
.slice(1)
.map(function (item) { return item.key })
.concat(this.key !== undefined ? this.key : [])
;
t.deepEqual(
[ keys, value ],
expected.shift()
);
};
p.write('"""Hello""This\\"is""\\r\\n\\f\\t\\\\\\/\\""');
p.write('"\\u039b\\u03ac\\u03bc\\u03b2\\u03b4\\u03b1"');
p.write('"\\\\"');
p.write('"\\/"');
p.write('"\\""');
p.write('[0,1,-1]');
p.write('[1.0,1.1,-1.1,-1.0][-1][-0.1]');
p.write('[6.02e23]');
p.write('[7161093205057351174]');
});

26
node_modules/jsonparse/test/surrogate.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
var test = require('tape');
var Parser = require('../');
test('parse surrogate pair', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, '😋');
};
p.write('"\\uD83D\\uDE0B"');
});
test('parse chunked surrogate pair', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, '😋');
};
p.write('"\\uD83D');
p.write('\\uDE0B"');
});

15
node_modules/jsonparse/test/unvalid.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
var test = require('tape');
var Parser = require('../');
test('unvalid', function (t) {
var count = 0;
var p = new Parser();
p.onError = function (value) {
count++;
t.equal(1, count);
t.end();
};
p.write('{"test": eer[');
});

38
node_modules/jsonparse/test/utf8.js generated vendored Normal file
View File

@ -0,0 +1,38 @@
var test = require('tape');
var Parser = require('../');
test('3 bytes of utf8', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, '├──');
};
p.write('"├──"');
});
test('utf8 snowman', function (t) {
t.plan(1);
var p = new Parser();
p.onValue = function (value) {
t.equal(value, '☃');
};
p.write('"☃"');
});
test('utf8 with regular ascii', function (t) {
t.plan(4);
var p = new Parser();
var expected = [ "snow: ☃!", "xyz", "¡que!" ];
expected.push(expected.slice());
p.onValue = function (value) {
t.deepEqual(value, expected.shift());
};
p.write('["snow: ☃!","xyz","¡que!"]');
});