jsonstream-next
Advanced tools
Comparing version 1.4.0 to 2.0.0
10
bin.js
#! /usr/bin/env node | ||
var JSONStream = require('./') | ||
var JSONStream = require("./"); | ||
if(!module.parent && process.title !== 'browser') { | ||
if (!module.parent && process.title !== "browser") { | ||
process.stdin | ||
.pipe(JSONStream.parse(process.argv[2])) | ||
.pipe(JSONStream.stringify('[', ',\n', ']\n', 2)) | ||
.pipe(process.stdout) | ||
.pipe(JSONStream.stringify("[", ",\n", "]\n", 2)) | ||
.pipe(process.stdout); | ||
} | ||
@@ -1,13 +0,14 @@ | ||
var request = require('request') | ||
, JSONStream = require('JSONStream') | ||
, es = require('event-stream') | ||
var request = require("request"), | ||
JSONStream = require("JSONStream"), | ||
es = require("event-stream"); | ||
var parser = JSONStream.parse(['rows', true]) //emit parts that match this path (any element of the rows array) | ||
, req = request({url: 'http://isaacs.couchone.com/registry/_all_docs'}) | ||
, logger = es.mapSync(function (data) { //create a stream that logs to stderr, | ||
console.error(data) | ||
return data | ||
}) | ||
var parser = JSONStream.parse(["rows", true]), //emit parts that match this path (any element of the rows array) | ||
req = request({ url: "http://isaacs.couchone.com/registry/_all_docs" }), | ||
logger = es.mapSync(function (data) { | ||
//create a stream that logs to stderr, | ||
console.error(data); | ||
return data; | ||
}); | ||
req.pipe(parser) | ||
parser.pipe(logger) | ||
req.pipe(parser); | ||
parser.pipe(logger); |
260
index.js
@@ -1,98 +0,70 @@ | ||
'use strict' | ||
const Parser = require('jsonparse') | ||
const through2 = require('through2') | ||
var Parser = require('jsonparse') | ||
, through = require('through') | ||
var bufferFrom = Buffer.from && Buffer.from !== Uint8Array.from | ||
/* | ||
the value of this.stack that creationix's jsonparse has is weird. | ||
it makes this code ugly, but his problem is way harder that mine, | ||
so i'll forgive him. | ||
*/ | ||
exports.parse = function (path, map) { | ||
var header, footer | ||
var parser = new Parser() | ||
var stream = through(function (chunk) { | ||
if('string' === typeof chunk) | ||
chunk = bufferFrom ? Buffer.from(chunk) : new Buffer(chunk) | ||
let header, footer | ||
const parser = new Parser() | ||
const stream = through2.obj(function (chunk, enc, cb) { | ||
if (typeof chunk === 'string') chunk = Buffer.from(chunk) | ||
parser.write(chunk) | ||
}, | ||
function (data) { | ||
if(data) | ||
stream.write(data) | ||
if (header) | ||
stream.emit('header', header) | ||
if (footer) | ||
stream.emit('footer', footer) | ||
cb() | ||
}, function (cb) { | ||
if (header) stream.emit('header', header) | ||
if (footer) stream.emit('footer', footer) | ||
if (parser.tState != Parser.C.START || parser.stack.length > 0) { | ||
stream.emit('error', new Error('Incomplete JSON')) | ||
if(!stream.writable && stream.autoDestroy) { | ||
process.nextTick(function () { | ||
stream.destroy() | ||
}); | ||
} | ||
} else { | ||
stream.queue(null) | ||
cb(new Error('Incomplete JSON')) | ||
return | ||
} | ||
cb() | ||
}) | ||
if('string' === typeof path) | ||
if ('string' === typeof path) | ||
path = path.split('.').map(function (e) { | ||
if (e === '$*') | ||
return {emitKey: true} | ||
else if (e === '*') | ||
return true | ||
else if (e === '') // '..'.split('.') returns an empty string | ||
return {recurse: true} | ||
else | ||
return e | ||
if (e === '$*') return { emitKey: true } | ||
else if (e === '*') return true | ||
else if (e === '') | ||
// '..'.split('.') returns an empty string | ||
return { recurse: true } | ||
else return e | ||
}) | ||
let count = 0, | ||
_key | ||
if (!path || !path.length) path = null | ||
var count = 0, _key | ||
if(!path || !path.length) | ||
path = null | ||
parser.onValue = function (value) { | ||
if (!this.root) | ||
stream.root = value | ||
if (!this.root) stream.root = value | ||
if(! path) return | ||
if (!path) return | ||
var i = 0 // iterates on path | ||
var j = 0 // iterates on stack | ||
var emitKey = false; | ||
var emitPath = false; | ||
let i = 0 // iterates on path | ||
let j = 0 // iterates on stack | ||
let emitKey = false | ||
let emitPath = false | ||
while (i < path.length) { | ||
var key = path[i] | ||
var c | ||
let key = path[i] | ||
let c | ||
j++ | ||
if (key && !key.recurse) { | ||
c = (j === this.stack.length) ? this : this.stack[j] | ||
c = j === this.stack.length ? this : this.stack[j] | ||
if (!c) return | ||
if (! check(key, c.key)) { | ||
if (!check(key, c.key)) { | ||
setHeaderFooter(c.key, value) | ||
return | ||
} | ||
emitKey = !!key.emitKey; | ||
emitPath = !!key.emitPath; | ||
emitKey = !!key.emitKey | ||
emitPath = !!key.emitPath | ||
i++ | ||
} else { | ||
i++ | ||
var nextKey = path[i] | ||
if (! nextKey) return | ||
let nextKey = path[i] | ||
if (!nextKey) return | ||
while (true) { | ||
c = (j === this.stack.length) ? this : this.stack[j] | ||
c = j === this.stack.length ? this : this.stack[j] | ||
if (!c) return | ||
if (check(nextKey, c.key)) { | ||
i++; | ||
if (!Object.isFrozen(this.stack[j])) | ||
this.stack[j].value = null | ||
i++ | ||
if (!Object.isFrozen(this.stack[j])) this.stack[j].value = null | ||
break | ||
@@ -105,3 +77,2 @@ } else { | ||
} | ||
} | ||
@@ -111,37 +82,37 @@ | ||
if (header) { | ||
stream.emit('header', header); | ||
header = false; | ||
stream.emit('header', header) | ||
header = false | ||
} | ||
if (j !== this.stack.length) return | ||
count ++ | ||
var actualPath = this.stack.slice(1).map(function(element) { return element.key }).concat([this.key]) | ||
var data = value | ||
if(null != data) | ||
if(null != (data = map ? map(data, actualPath) : data)) { | ||
count++ | ||
let actualPath = this.stack | ||
.slice(1) | ||
.map(function (element) { | ||
return element.key | ||
}) | ||
.concat([this.key]) | ||
let data = value | ||
if (null != data) | ||
if (null != (data = map ? map(data, actualPath) : data)) { | ||
if (emitKey || emitPath) { | ||
data = { value: data }; | ||
if (emitKey) | ||
data["key"] = this.key; | ||
if (emitPath) | ||
data["path"] = actualPath; | ||
data = { value: data } | ||
if (emitKey) data['key'] = this.key | ||
if (emitPath) data['path'] = actualPath | ||
} | ||
stream.queue(data) | ||
stream.push(data) | ||
} | ||
if (this.value) delete this.value[this.key] | ||
for(var k in this.stack) | ||
if (!Object.isFrozen(this.stack[k])) | ||
this.stack[k].value = null | ||
for (let k in this.stack) if (!Object.isFrozen(this.stack[k])) this.stack[k].value = null | ||
} | ||
parser._onToken = parser.onToken; | ||
parser._onToken = parser.onToken | ||
parser.onToken = function (token, value) { | ||
parser._onToken(token, value); | ||
parser._onToken(token, value) | ||
if (this.stack.length === 0) { | ||
if (stream.root) { | ||
if(!path) | ||
stream.queue(stream.root) | ||
count = 0; | ||
stream.root = null; | ||
if (!path) stream.push(stream.root) | ||
count = 0 | ||
stream.root = null | ||
} | ||
@@ -152,4 +123,3 @@ } | ||
parser.onError = function (err) { | ||
if(err.message.indexOf("at position") > -1) | ||
err.message = "Invalid JSON (" + err.message + ")"; | ||
if (err.message.indexOf('at position') > -1) err.message = 'Invalid JSON (' + err.message + ')' | ||
stream.emit('error', err) | ||
@@ -175,11 +145,7 @@ } | ||
function check (x, y) { | ||
if ('string' === typeof x) | ||
return y == x | ||
else if (x && 'function' === typeof x.exec) | ||
return x.exec(y) | ||
else if ('boolean' === typeof x || 'object' === typeof x) | ||
return x | ||
else if ('function' === typeof x) | ||
return x(y) | ||
function check(x, y) { | ||
if ('string' === typeof x) return y == x | ||
else if (x && 'function' === typeof x.exec) return x.exec(y) | ||
else if ('boolean' === typeof x || 'object' === typeof x) return x | ||
else if ('function' === typeof x) return x(y) | ||
return false | ||
@@ -190,3 +156,3 @@ } | ||
indent = indent || 0 | ||
if (op === false){ | ||
if (op === false) { | ||
op = '' | ||
@@ -196,7 +162,5 @@ sep = '\n' | ||
} else if (op == null) { | ||
op = '[\n' | ||
sep = '\n,\n' | ||
cl = '\n]\n' | ||
} | ||
@@ -206,27 +170,31 @@ | ||
var stream | ||
, first = true | ||
, anyData = false | ||
stream = through(function (data) { | ||
let first = true | ||
let anyData = false | ||
const stream = through2.obj(function (data, _, cb) { | ||
anyData = true | ||
let json | ||
try { | ||
var json = JSON.stringify(data, null, indent) | ||
json = JSON.stringify(data, null, indent) | ||
} catch (err) { | ||
return stream.emit('error', err) | ||
return cb(err) | ||
} | ||
if(first) { first = false ; stream.queue((typeof op === 'function' ? op() : op) + json)} | ||
else stream.queue(sep + json) | ||
}, | ||
function (data) { | ||
if(!anyData) stream.queue(op) | ||
if (first) { | ||
first = false | ||
cb(null, (typeof op === 'function' ? op() : op) + json) | ||
} else { | ||
cb(null, sep + json) | ||
} | ||
}, function (cb) { | ||
if (!anyData) this.push(op) | ||
if (typeof cl === 'function') { | ||
cl(function (err, res) { | ||
if (err) return this.emit('error', err) | ||
this.queue(res) | ||
this.queue(null) | ||
}.bind(this)) | ||
cl((err, res) => { | ||
if (err) return cb(err) | ||
this.push(res) | ||
cb() | ||
}) | ||
return | ||
} | ||
this.queue(cl) | ||
this.queue(null) | ||
this.push(cl) | ||
cb() | ||
}) | ||
@@ -239,3 +207,3 @@ | ||
indent = indent || 0 | ||
if (op === false){ | ||
if (op === false) { | ||
op = '' | ||
@@ -245,31 +213,35 @@ sep = '\n' | ||
} else if (op == null) { | ||
op = '{\n' | ||
sep = '\n,\n' | ||
cl = '\n}\n' | ||
} | ||
//else, what ever you like | ||
var first = true | ||
var anyData = false | ||
var stream = through(function (data) { | ||
let first = true | ||
let anyData = false | ||
const stream = through2.obj(function (data, enc, cb) { | ||
anyData = true | ||
var json = JSON.stringify(data[0]) + ':' + JSON.stringify(data[1], null, indent) | ||
if(first) { first = false ; this.queue((typeof op === 'function' ? op() : op) + json)} | ||
else this.queue(sep + json) | ||
}, | ||
function (data) { | ||
if(!anyData) this.queue(op) | ||
let json | ||
try { | ||
json = JSON.stringify(data[0]) + ':' + JSON.stringify(data[1], null, indent) | ||
} catch (err) { | ||
return cb(err) | ||
} | ||
if (first) { | ||
first = false | ||
cb(null, (typeof op === 'function' ? op() : op) + json) | ||
} else { | ||
cb(null, sep + json) | ||
} | ||
}, function (cb) { | ||
if (!anyData) this.push(op) | ||
if (typeof cl === 'function') { | ||
cl(function (err, res) { | ||
if (err) return this.emit('error', err) | ||
this.queue(res) | ||
this.queue(null) | ||
}.bind(this)) | ||
cl((err, res) => { | ||
if (err) return cb(err) | ||
this.push(res) | ||
cb() | ||
}) | ||
return | ||
} | ||
this.queue(cl) | ||
this.queue(null) | ||
this.push(cl) | ||
cb() | ||
}) | ||
@@ -276,0 +248,0 @@ |
{ | ||
"name": "jsonstream-next", | ||
"version": "1.4.0", | ||
"version": "2.0.0", | ||
"description": "rawStream.pipe(JSONStream.parse()).pipe(streamOfObjects)", | ||
@@ -21,11 +21,11 @@ "homepage": "http://github.com/contra/JSONStream", | ||
"jsonparse": "^1.2.0", | ||
"through": ">=2.2.7 <3" | ||
"through2": "^4.0.2" | ||
}, | ||
"devDependencies": { | ||
"assertions": "^2.2.2", | ||
"event-stream": "^0.7.0", | ||
"event-stream": "^4.0.0", | ||
"it-is": "^1", | ||
"render": "^0.1.1", | ||
"tape": "^2.12.3", | ||
"trees": "^0.0.3" | ||
"tape": "^5.0.0", | ||
"trees": "^0.0.4" | ||
}, | ||
@@ -39,4 +39,4 @@ "bin": "./bin.js", | ||
"engines": { | ||
"node": "*" | ||
"node": ">=10" | ||
} | ||
} |
@@ -0,41 +1,37 @@ | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "all_npm.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is").style("colour"); | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','all_npm.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is').style('colour') | ||
function randomObj() { | ||
return Math.random() < 0.4 | ||
? { | ||
hello: "eonuhckmqjk", | ||
whatever: 236515, | ||
lies: true, | ||
nothing: [null], | ||
// stuff: [Math.random(),Math.random(),Math.random()] | ||
} | ||
: ["AOREC", "reoubaor", { ouec: 62642 }, [[[], {}, 53]]]; | ||
} | ||
function randomObj () { | ||
return ( | ||
Math.random () < 0.4 | ||
? {hello: 'eonuhckmqjk', | ||
whatever: 236515, | ||
lies: true, | ||
nothing: [null], | ||
// stuff: [Math.random(),Math.random(),Math.random()] | ||
} | ||
: ['AOREC', 'reoubaor', {ouec: 62642}, [[[], {}, 53]]] | ||
) | ||
} | ||
var expected = [], | ||
stringify = JSONStream.stringify(), | ||
es = require("event-stream"), | ||
stringified = "", | ||
called = 0, | ||
count = 10, | ||
ended = false; | ||
var expected = [] | ||
, stringify = JSONStream.stringify() | ||
, es = require('event-stream') | ||
, stringified = '' | ||
, called = 0 | ||
, count = 10 | ||
, ended = false | ||
while (count --) | ||
expected.push(randomObj()) | ||
while (count--) expected.push(randomObj()); | ||
es.connect( | ||
es.readArray(expected), | ||
stringify, | ||
JSONStream.parse([true]), | ||
es.writeArray(function (err, lines) { | ||
it(lines).has(expected) | ||
console.error('PASSED') | ||
}) | ||
) | ||
es.connect( | ||
es.readArray(expected), | ||
stringify, | ||
JSONStream.parse([true]), | ||
es.writeArray(function (err, lines) { | ||
it(lines).has(expected); | ||
console.error("PASSED"); | ||
}) | ||
); |
@@ -1,18 +0,18 @@ | ||
var test = require('tape') | ||
var JSONStream = require('../') | ||
var testData = '{"rows":[{"hello":"world"}, {"foo": "bar"}]}' | ||
var test = require("tape"); | ||
var JSONStream = require("../"); | ||
var testData = '{"rows":[{"hello":"world"}, {"foo": "bar"}]}'; | ||
test('basic parsing', function (t) { | ||
t.plan(2) | ||
var parsed = JSONStream.parse("rows.*") | ||
var parsedKeys = {} | ||
parsed.on('data', function(match) { | ||
parsedKeys[Object.keys(match)[0]] = true | ||
}) | ||
parsed.on('end', function() { | ||
t.equal(!!parsedKeys['hello'], true) | ||
t.equal(!!parsedKeys['foo'], true) | ||
}) | ||
parsed.write(testData) | ||
parsed.end() | ||
}) | ||
test("basic parsing", function (t) { | ||
t.plan(2); | ||
var parsed = JSONStream.parse("rows.*"); | ||
var parsedKeys = {}; | ||
parsed.on("data", function (match) { | ||
parsedKeys[Object.keys(match)[0]] = true; | ||
}); | ||
parsed.on("finish", function () { | ||
t.equal(!!parsedKeys["hello"], true); | ||
t.equal(!!parsedKeys["foo"], true); | ||
}); | ||
parsed.write(testData); | ||
parsed.end(); | ||
}); |
@@ -1,30 +0,30 @@ | ||
var fs = require ('fs'); | ||
var net = require('net'); | ||
var join = require('path').join; | ||
var file = join(__dirname, 'fixtures','all_npm.json'); | ||
var JSONStream = require('../'); | ||
var fs = require("fs"); | ||
var net = require("net"); | ||
var join = require("path").join; | ||
var file = join(__dirname, "fixtures", "all_npm.json"); | ||
var JSONStream = require("../"); | ||
var server = net.createServer(function(connection) { | ||
var parser = JSONStream.parse([]); | ||
parser.on('close', function() { | ||
console.log('close') | ||
console.error('PASSED'); | ||
server.close(); | ||
}); | ||
parser.on('error', function (err) { | ||
console.log('Parser error as expected: ' + err.message) | ||
}) | ||
connection.pipe(parser) | ||
connection.on('data', function () { | ||
connection.end(); | ||
}) | ||
var server = net.createServer(function (connection) { | ||
var parser = JSONStream.parse([]); | ||
parser.on("finish", function () { | ||
console.log("finish"); | ||
console.error("PASSED"); | ||
server.close(); | ||
}); | ||
parser.on("error", function (err) { | ||
console.log("Parser error as expected: " + err.message); | ||
}); | ||
connection.pipe(parser); | ||
connection.on("data", function () { | ||
connection.end(); | ||
}); | ||
}); | ||
server.listen(() => { | ||
var port = server.address().port | ||
var port = server.address().port; | ||
console.log('Listening on port ' + port) | ||
var client = net.connect({ port : port }, function() { | ||
fs.createReadStream(file).pipe(client).on('data', console.log) //.resume(); | ||
}); | ||
}); | ||
console.log("Listening on port " + port); | ||
var client = net.connect({ port: port }, function () { | ||
fs.createReadStream(file).pipe(client).on("data", console.log); //.resume(); | ||
}); | ||
}); |
@@ -1,29 +0,29 @@ | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','all_npm.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is') | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "all_npm.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is"); | ||
var expected = JSON.parse(fs.readFileSync(file)) | ||
, parser = JSONStream.parse('rows..rev') | ||
, called = 0 | ||
, ended = false | ||
, parsed = [] | ||
var expected = JSON.parse(fs.readFileSync(file)), | ||
parser = JSONStream.parse("rows..rev"), | ||
called = 0, | ||
ended = false, | ||
parsed = []; | ||
fs.createReadStream(file).pipe(parser) | ||
parser.on('data', function (data) { | ||
called ++ | ||
parsed.push(data) | ||
}) | ||
fs.createReadStream(file).pipe(parser); | ||
parser.on('end', function () { | ||
ended = true | ||
}) | ||
parser.on("data", function (data) { | ||
called++; | ||
parsed.push(data); | ||
}); | ||
process.on('exit', function () { | ||
it(called).equal(expected.rows.length) | ||
for (var i = 0 ; i < expected.rows.length ; i++) | ||
it(parsed[i]).deepEqual(expected.rows[i].value.rev) | ||
console.error('PASSED') | ||
}) | ||
parser.on("finish", function () { | ||
ended = true; | ||
}); | ||
process.on("exit", function () { | ||
it(called).equal(expected.rows.length); | ||
for (var i = 0; i < expected.rows.length; i++) | ||
it(parsed[i]).deepEqual(expected.rows[i].value.rev); | ||
console.error("PASSED"); | ||
}); |
@@ -1,30 +0,29 @@ | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','depth.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is') | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "depth.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is"); | ||
var expected = JSON.parse(fs.readFileSync(file)) | ||
, parser = JSONStream.parse(['docs', {recurse: true}, 'value']) | ||
, called = 0 | ||
, ended = false | ||
, parsed = [] | ||
var expected = JSON.parse(fs.readFileSync(file)), | ||
parser = JSONStream.parse(["docs", { recurse: true }, "value"]), | ||
called = 0, | ||
ended = false, | ||
parsed = []; | ||
fs.createReadStream(file).pipe(parser) | ||
parser.on('data', function (data) { | ||
called ++ | ||
parsed.push(data) | ||
}) | ||
fs.createReadStream(file).pipe(parser); | ||
parser.on('end', function () { | ||
ended = true | ||
}) | ||
parser.on("data", function (data) { | ||
called++; | ||
parsed.push(data); | ||
}); | ||
process.on('exit', function () { | ||
var expectedValues = [0, [1], {"a": 2}, "3", 4] | ||
it(called).equal(expectedValues.length) | ||
for (var i = 0 ; i < 5 ; i++) | ||
it(parsed[i]).deepEqual(expectedValues[i]) | ||
console.error('PASSED') | ||
}) | ||
parser.on("finish", function () { | ||
ended = true; | ||
}); | ||
process.on("exit", function () { | ||
var expectedValues = [0, [1], { a: 2 }, "3", 4]; | ||
it(called).equal(expectedValues.length); | ||
for (var i = 0; i < 5; i++) it(parsed[i]).deepEqual(expectedValues[i]); | ||
console.error("PASSED"); | ||
}); |
@@ -1,44 +0,46 @@ | ||
var JSONStream = require('../') | ||
, stream = require('stream') | ||
, it = require('it-is') | ||
var JSONStream = require("../"), | ||
stream = require("stream"), | ||
it = require("it-is"); | ||
var output = [ [], [] ] | ||
var output = [[], []]; | ||
var parser1 = JSONStream.parse(['docs', /./]) | ||
parser1.on('data', function(data) { | ||
output[0].push(data) | ||
}) | ||
var parser1 = JSONStream.parse(["docs", /./]); | ||
parser1.on("data", function (data) { | ||
output[0].push(data); | ||
}); | ||
var parser2 = JSONStream.parse(['docs', /./]) | ||
parser2.on('data', function(data) { | ||
output[1].push(data) | ||
}) | ||
var parser2 = JSONStream.parse(["docs", /./]); | ||
parser2.on("data", function (data) { | ||
output[1].push(data); | ||
}); | ||
var pending = 2 | ||
function onend () { | ||
if (--pending > 0) return | ||
it(output).deepEqual([ | ||
[], [{hello: 'world'}] | ||
]) | ||
console.error('PASSED') | ||
var pending = 2; | ||
function onend() { | ||
if (--pending > 0) return; | ||
it(output).deepEqual([[], [{ hello: "world" }]]); | ||
console.error("PASSED"); | ||
} | ||
parser1.on('end', onend) | ||
parser2.on('end', onend) | ||
parser1.on("finish", onend); | ||
parser2.on("finish", onend); | ||
function makeReadableStream() { | ||
var readStream = new stream.Stream() | ||
readStream.readable = true | ||
readStream.write = function (data) { this.emit('data', data) } | ||
readStream.end = function (data) { this.emit('end') } | ||
return readStream | ||
var readStream = new stream.Stream(); | ||
readStream.readable = true; | ||
readStream.write = function (data) { | ||
this.emit("data", data); | ||
}; | ||
readStream.end = function (data) { | ||
this.emit("finish"); | ||
}; | ||
return readStream; | ||
} | ||
var emptyArray = makeReadableStream() | ||
emptyArray.pipe(parser1) | ||
emptyArray.write('{"docs":[]}') | ||
emptyArray.end() | ||
var emptyArray = makeReadableStream(); | ||
emptyArray.pipe(parser1); | ||
emptyArray.write('{"docs":[]}'); | ||
emptyArray.end(); | ||
var objectArray = makeReadableStream() | ||
objectArray.pipe(parser2) | ||
objectArray.write('{"docs":[{"hello":"world"}]}') | ||
objectArray.end() | ||
var objectArray = makeReadableStream(); | ||
objectArray.pipe(parser2); | ||
objectArray.write('{"docs":[{"hello":"world"}]}'); | ||
objectArray.end(); |
@@ -0,45 +1,43 @@ | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "error.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is"); | ||
var expected = JSON.parse(fs.readFileSync(file)), | ||
parser = JSONStream.parse(["rows"]), | ||
called = 0, | ||
headerCalled = 0, | ||
footerCalled = 0, | ||
ended = false, | ||
parsed = []; | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','error.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is') | ||
fs.createReadStream(file).pipe(parser); | ||
var expected = JSON.parse(fs.readFileSync(file)) | ||
, parser = JSONStream.parse(['rows']) | ||
, called = 0 | ||
, headerCalled = 0 | ||
, footerCalled = 0 | ||
, ended = false | ||
, parsed = [] | ||
fs.createReadStream(file).pipe(parser) | ||
parser.on('header', function (data) { | ||
headerCalled ++ | ||
parser.on("header", function (data) { | ||
headerCalled++; | ||
it(data).deepEqual({ | ||
error: 'error_code', | ||
message: 'this is an error message' | ||
}) | ||
}) | ||
error: "error_code", | ||
message: "this is an error message", | ||
}); | ||
}); | ||
parser.on('footer', function (data) { | ||
footerCalled ++ | ||
}) | ||
parser.on("footer", function (data) { | ||
footerCalled++; | ||
}); | ||
parser.on('data', function (data) { | ||
called ++ | ||
parsed.push(data) | ||
}) | ||
parser.on("data", function (data) { | ||
called++; | ||
parsed.push(data); | ||
}); | ||
parser.on('end', function () { | ||
ended = true | ||
}) | ||
parser.on("finish", function () { | ||
ended = true; | ||
}); | ||
process.on('exit', function () { | ||
it(called).equal(0) | ||
it(headerCalled).equal(1) | ||
it(footerCalled).equal(0) | ||
console.error('PASSED') | ||
}) | ||
process.on("exit", function () { | ||
it(called).equal(0); | ||
it(headerCalled).equal(1); | ||
it(footerCalled).equal(0); | ||
console.error("PASSED"); | ||
}); |
@@ -0,39 +1,37 @@ | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "all_npm.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is"); | ||
function fn(s) { | ||
return !isNaN(parseInt(s, 10)); | ||
} | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','all_npm.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is') | ||
var expected = JSON.parse(fs.readFileSync(file)), | ||
parser = JSONStream.parse(["rows", fn]), | ||
called = 0, | ||
ended = false, | ||
parsed = []; | ||
function fn (s) { | ||
return !isNaN(parseInt(s, 10)) | ||
} | ||
fs.createReadStream(file).pipe(parser); | ||
var expected = JSON.parse(fs.readFileSync(file)) | ||
, parser = JSONStream.parse(['rows', fn]) | ||
, called = 0 | ||
, ended = false | ||
, parsed = [] | ||
fs.createReadStream(file).pipe(parser) | ||
parser.on('data', function (data) { | ||
called ++ | ||
parser.on("data", function (data) { | ||
called++; | ||
it.has({ | ||
id: it.typeof('string'), | ||
value: {rev: it.typeof('string')}, | ||
key:it.typeof('string') | ||
}) | ||
parsed.push(data) | ||
}) | ||
id: it.typeof("string"), | ||
value: { rev: it.typeof("string") }, | ||
key: it.typeof("string"), | ||
}); | ||
parsed.push(data); | ||
}); | ||
parser.on('end', function () { | ||
ended = true | ||
}) | ||
parser.on("finish", function () { | ||
ended = true; | ||
}); | ||
process.on('exit', function () { | ||
it(called).equal(expected.rows.length) | ||
it(parsed).deepEqual(expected.rows) | ||
console.error('PASSED') | ||
}) | ||
process.on("exit", function () { | ||
it(called).equal(expected.rows.length); | ||
it(parsed).deepEqual(expected.rows); | ||
console.error("PASSED"); | ||
}); |
219
test/gen.js
@@ -1,135 +0,128 @@ | ||
return // dont run this test for now since tape is weird and broken on 0.10 | ||
return; // dont run this test for now since tape is weird and broken on 0.10 | ||
var fs = require('fs') | ||
var JSONStream = require('../') | ||
var file = process.argv[2] || '/tmp/JSONStream-test-large.json' | ||
var size = Number(process.argv[3] || 100000) | ||
var tape = require('tape') | ||
var fs = require("fs"); | ||
var JSONStream = require("../"); | ||
var file = process.argv[2] || "/tmp/JSONStream-test-large.json"; | ||
var size = Number(process.argv[3] || 100000); | ||
var tape = require("tape"); | ||
// if (process.title !== 'browser') { | ||
tape('out of mem', function (t) { | ||
t.plan(1) | ||
////////////////////////////////////////////////////// | ||
// Produces a random number between arg1 and arg2 | ||
////////////////////////////////////////////////////// | ||
var randomNumber = function (min, max) { | ||
var number = Math.floor(Math.random() * (max - min + 1) + min); | ||
return number; | ||
}; | ||
tape("out of mem", function (t) { | ||
t.plan(1); | ||
////////////////////////////////////////////////////// | ||
// Produces a random number between arg1 and arg2 | ||
////////////////////////////////////////////////////// | ||
var randomNumber = function (min, max) { | ||
var number = Math.floor(Math.random() * (max - min + 1) + min); | ||
return number; | ||
}; | ||
////////////////////////////////////////////////////// | ||
// Produces a random string of a length between arg1 and arg2 | ||
////////////////////////////////////////////////////// | ||
var randomString = function (min, max) { | ||
////////////////////////////////////////////////////// | ||
// Produces a random string of a length between arg1 and arg2 | ||
////////////////////////////////////////////////////// | ||
var randomString = function (min, max) { | ||
// add several spaces to increase chanses of creating 'words' | ||
var chars = | ||
" 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
var result = ""; | ||
// add several spaces to increase chanses of creating 'words' | ||
var chars = ' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||
var result = ''; | ||
var randomLength = randomNumber(min, max); | ||
var randomLength = randomNumber(min, max); | ||
for (var i = randomLength; i > 0; --i) { | ||
result += chars[Math.round(Math.random() * (chars.length - 1))]; | ||
} | ||
return result; | ||
}; | ||
for (var i = randomLength; i > 0; --i) { | ||
result += chars[Math.round(Math.random() * (chars.length - 1))]; | ||
} | ||
return result; | ||
////////////////////////////////////////////////////// | ||
// Produces a random JSON document, as a string | ||
////////////////////////////////////////////////////// | ||
var randomJsonDoc = function () { | ||
var doc = { | ||
CrashOccurenceID: randomNumber(10000, 50000), | ||
CrashID: randomNumber(1000, 10000), | ||
SiteName: randomString(10, 25), | ||
MachineName: randomString(10, 25), | ||
Date: randomString(26, 26), | ||
ProcessDuration: randomString(18, 18), | ||
ThreadIdentityName: null, | ||
WindowsIdentityName: randomString(15, 40), | ||
OperatingSystemName: randomString(35, 65), | ||
DetailedExceptionInformation: randomString(100, 800), | ||
}; | ||
////////////////////////////////////////////////////// | ||
// Produces a random JSON document, as a string | ||
////////////////////////////////////////////////////// | ||
var randomJsonDoc = function () { | ||
doc = JSON.stringify(doc); | ||
doc = doc.replace(/\,/g, ",\n"); // add new lines after each attribute | ||
return doc; | ||
}; | ||
var doc = { | ||
"CrashOccurenceID": randomNumber(10000, 50000), | ||
"CrashID": randomNumber(1000, 10000), | ||
"SiteName": randomString(10, 25), | ||
"MachineName": randomString(10, 25), | ||
"Date": randomString(26, 26), | ||
"ProcessDuration": randomString(18, 18), | ||
"ThreadIdentityName": null, | ||
"WindowsIdentityName": randomString(15, 40), | ||
"OperatingSystemName": randomString(35, 65), | ||
"DetailedExceptionInformation": randomString(100, 800) | ||
}; | ||
////////////////////////////////////////////////////// | ||
// generates test data | ||
////////////////////////////////////////////////////// | ||
var generateTestData = function (cb) { | ||
console.log("generating large data file..."); | ||
doc = JSON.stringify(doc); | ||
doc = doc.replace(/\,/g, ',\n'); // add new lines after each attribute | ||
return doc; | ||
}; | ||
var stream = fs.createWriteStream(file, { | ||
encoding: "utf8", | ||
}); | ||
////////////////////////////////////////////////////// | ||
// generates test data | ||
////////////////////////////////////////////////////// | ||
var generateTestData = function (cb) { | ||
var i = 0; | ||
var max = size; | ||
var writing = false; | ||
var split = ",\n"; | ||
var doc = randomJsonDoc(); | ||
stream.write("["); | ||
console.log('generating large data file...'); | ||
var stream = fs.createWriteStream(file, { | ||
encoding: 'utf8' | ||
}); | ||
var i = 0; | ||
var max = size; | ||
var writing = false | ||
var split = ',\n'; | ||
var doc = randomJsonDoc(); | ||
stream.write('['); | ||
function write () { | ||
if(writing) return | ||
writing = true | ||
while(++i < max) { | ||
if(Math.random() < 0.001) | ||
console.log('generate..', i + ' / ' + size) | ||
if(!stream.write(doc + split)) { | ||
writing = false | ||
return stream.once('drain', write) | ||
} | ||
function write() { | ||
if (writing) return; | ||
writing = true; | ||
while (++i < max) { | ||
if (Math.random() < 0.001) console.log("generate..", i + " / " + size); | ||
if (!stream.write(doc + split)) { | ||
writing = false; | ||
return stream.once("drain", write); | ||
} | ||
stream.write(doc + ']') | ||
stream.end(); | ||
console.log('END') | ||
} | ||
write() | ||
stream.on('close', cb) | ||
}; | ||
stream.write(doc + "]"); | ||
stream.end(); | ||
console.log("END"); | ||
} | ||
write(); | ||
stream.on("finish", cb); | ||
}; | ||
////////////////////////////////////////////////////// | ||
// Shows that parsing 100000 instances using JSONStream fails | ||
// | ||
// After several seconds, you will get this crash | ||
// FATAL ERROR: JS Allocation failed - process out of memory | ||
////////////////////////////////////////////////////// | ||
var testJSONStreamParse_causesOutOfMem = function (done) { | ||
var items = 0 | ||
console.log('parsing data files using JSONStream...'); | ||
////////////////////////////////////////////////////// | ||
// Shows that parsing 100000 instances using JSONStream fails | ||
// | ||
// After several seconds, you will get this crash | ||
// FATAL ERROR: JS Allocation failed - process out of memory | ||
////////////////////////////////////////////////////// | ||
var testJSONStreamParse_causesOutOfMem = function (done) { | ||
var items = 0; | ||
console.log("parsing data files using JSONStream..."); | ||
var parser = JSONStream.parse([true]); | ||
var stream = fs.createReadStream(file); | ||
stream.pipe(parser); | ||
var parser = JSONStream.parse([true]); | ||
var stream = fs.createReadStream(file); | ||
stream.pipe(parser); | ||
parser.on('data', function (data) { | ||
items++ | ||
if(Math.random() < 0.01) console.log(items, '...') | ||
}); | ||
parser.on('end', function () { | ||
t.equal(items, size) | ||
}); | ||
parser.on("data", function (data) { | ||
items++; | ||
if (Math.random() < 0.01) console.log(items, "..."); | ||
}); | ||
}; | ||
parser.on("finish", function () { | ||
t.equal(items, size); | ||
}); | ||
}; | ||
////////////////////////////////////////////////////// | ||
// main | ||
////////////////////////////////////////////////////// | ||
////////////////////////////////////////////////////// | ||
// main | ||
////////////////////////////////////////////////////// | ||
fs.stat(file, function (err, stat) { | ||
console.log(stat) | ||
if(err) | ||
generateTestData(testJSONStreamParse_causesOutOfMem); | ||
else | ||
testJSONStreamParse_causesOutOfMem() | ||
}) | ||
fs.stat(file, function (err, stat) { | ||
console.log(stat); | ||
if (err) generateTestData(testJSONStreamParse_causesOutOfMem); | ||
else testJSONStreamParse_causesOutOfMem(); | ||
}); | ||
}); | ||
}) | ||
// } |
@@ -0,55 +1,53 @@ | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "header_footer.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is"); | ||
var expected = JSON.parse(fs.readFileSync(file)), | ||
parser = JSONStream.parse(["rows", /\d+/ /*, 'value'*/]), | ||
called = 0, | ||
headerCalled = 0, | ||
footerCalled = 0, | ||
ended = false, | ||
parsed = []; | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','header_footer.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is') | ||
fs.createReadStream(file).pipe(parser); | ||
var expected = JSON.parse(fs.readFileSync(file)) | ||
, parser = JSONStream.parse(['rows', /\d+/ /*, 'value'*/]) | ||
, called = 0 | ||
, headerCalled = 0 | ||
, footerCalled = 0 | ||
, ended = false | ||
, parsed = [] | ||
fs.createReadStream(file).pipe(parser) | ||
parser.on('header', function (data) { | ||
headerCalled ++ | ||
parser.on("header", function (data) { | ||
headerCalled++; | ||
it(data).deepEqual({ | ||
total_rows: 129, | ||
offset: 0 | ||
}) | ||
}) | ||
offset: 0, | ||
}); | ||
}); | ||
parser.on('footer', function (data) { | ||
footerCalled ++ | ||
parser.on("footer", function (data) { | ||
footerCalled++; | ||
it(data).deepEqual({ | ||
foo: { bar: 'baz' } | ||
}) | ||
}) | ||
foo: { bar: "baz" }, | ||
}); | ||
}); | ||
parser.on('data', function (data) { | ||
called ++ | ||
parser.on("data", function (data) { | ||
called++; | ||
it.has({ | ||
id: it.typeof('string'), | ||
value: {rev: it.typeof('string')}, | ||
key:it.typeof('string') | ||
}) | ||
it(headerCalled).equal(1) | ||
parsed.push(data) | ||
}) | ||
id: it.typeof("string"), | ||
value: { rev: it.typeof("string") }, | ||
key: it.typeof("string"), | ||
}); | ||
it(headerCalled).equal(1); | ||
parsed.push(data); | ||
}); | ||
parser.on('end', function () { | ||
ended = true | ||
}) | ||
parser.on("finish", function () { | ||
ended = true; | ||
}); | ||
process.on('exit', function () { | ||
it(called).equal(expected.rows.length) | ||
it(headerCalled).equal(1) | ||
it(footerCalled).equal(1) | ||
it(parsed).deepEqual(expected.rows) | ||
console.error('PASSED') | ||
}) | ||
process.on("exit", function () { | ||
it(called).equal(expected.rows.length); | ||
it(headerCalled).equal(1); | ||
it(footerCalled).equal(1); | ||
it(parsed).deepEqual(expected.rows); | ||
console.error("PASSED"); | ||
}); |
@@ -1,92 +0,70 @@ | ||
var JSONStream = require('../') | ||
var test = require('tape') | ||
var JSONStream = require("../"); | ||
var test = require("tape"); | ||
test('#66', function (t) { | ||
var error = 0 | ||
var stream = JSONStream | ||
.parse() | ||
.on('error', function (err) { | ||
t.ok(err, "error emitted: " + err.message + "\n" + err.stack) | ||
error++ | ||
}) | ||
.on('close', function() { | ||
t.ok(error === 2, "expect error to be called twice ('Invalid JSON', 'Incomplete JSON'): " + error) | ||
t.end() | ||
}) | ||
stream.write('["foo":bar[') | ||
stream.end() | ||
}) | ||
test("#66", function (t) { | ||
var error = 0; | ||
var stream = JSONStream.parse() | ||
.on("error", function (err) { | ||
t.ok(err, "error emitted: " + err.message + "\n" + err.stack); | ||
error++; | ||
}) | ||
.on("finish", function () { | ||
t.ok( | ||
error === 2, | ||
"expect error to be called twice ('Invalid JSON', 'Incomplete JSON'): " + | ||
error | ||
); | ||
t.end(); | ||
}); | ||
stream.write('["foo":bar['); | ||
stream.end(); | ||
}); | ||
test('#112 should allow aborting after first error', function (t) { | ||
var error = 0 | ||
var stream = JSONStream | ||
.parse() | ||
.on('error', function (err) { | ||
t.ok(err, "error emitted: " + err.message + "\n" + err.stack) | ||
error++ | ||
stream.destroy() | ||
}) | ||
.on('close', function() { | ||
t.ok(error === 1, "expect error to be called once: " + error) | ||
t.end() | ||
}) | ||
stream.write('["foo":bar[') | ||
stream.end() | ||
}) | ||
test("#112 should allow aborting after first error", function (t) { | ||
var error = 0; | ||
var stream = JSONStream.parse() | ||
.on("error", function (err) { | ||
t.ok(err, "error emitted: " + err.message + "\n" + err.stack); | ||
error++; | ||
stream.destroy(); | ||
}) | ||
.on("finish", function () { | ||
t.ok(error === 1, "expect error to be called once: " + error); | ||
t.end(); | ||
}); | ||
stream.write('["foo":bar['); | ||
stream.end(); | ||
}); | ||
test('#112 "Incomplete JSON" error is emitted', function (t) { | ||
var stream = JSONStream | ||
.parse() | ||
.on('error', function (err) { | ||
t.ok("error emitted: " + err.message) | ||
t.end() | ||
}) | ||
var stream = JSONStream.parse().on("error", function (err) { | ||
t.ok("error emitted: " + err.message); | ||
t.end(); | ||
}); | ||
stream.write('{"rows":[{"id":"id-1","name":"Name A"},{"id":"id-2","name":"') | ||
stream.end() | ||
}) | ||
stream.write('{"rows":[{"id":"id-1","name":"Name A"},{"id":"id-2","name":"'); | ||
stream.end(); | ||
}); | ||
test('#112 "Incomplete JSON" error is emitted with different JSON', function (t) { | ||
var stream = JSONStream | ||
.parse() | ||
.on('error', function (err) { | ||
t.ok("error emitted: " + err.message) | ||
t.end() | ||
}) | ||
var stream = JSONStream.parse().on("error", function (err) { | ||
t.ok("error emitted: " + err.message); | ||
t.end(); | ||
}); | ||
stream.write('{"rows":[{"id":"id-1","name":"Name A"}') // I changed the incomplete JSON | ||
stream.end() | ||
}) | ||
stream.write('{"rows":[{"id":"id-1","name":"Name A"}'); // I changed the incomplete JSON | ||
stream.end(); | ||
}); | ||
test('#112 end is not emmitted after error', function (t) { | ||
var ended = 0 | ||
var stream = JSONStream | ||
.parse() | ||
.on('error', function (err) { | ||
t.ok(err, "error emitted: " + err.message) | ||
}) | ||
.on('end', function () { | ||
ended = 1 | ||
}) | ||
.on('close', function() { | ||
t.ok(ended === 0 , "`end` emitted despite error") | ||
t.end() | ||
}) | ||
stream.write('{"rows":[{"id":"id-1","name":"Name A"},{"id":"id-2","name":"') | ||
stream.end() | ||
}) | ||
test('#81 - failure to parse nested objects', function (t) { | ||
var stream = JSONStream | ||
.parse('.bar.foo') | ||
.on('error', function (err) { | ||
t.error(err) | ||
test("#81 - failure to parse nested objects", function (t) { | ||
var stream = JSONStream.parse(".bar.foo") | ||
.on("error", function (err) { | ||
t.error(err); | ||
}) | ||
.on('end', function () { | ||
t.end() | ||
}) | ||
.on("finish", function () { | ||
t.end(); | ||
}); | ||
stream.write('{"bar":{"foo":"baz"}}') | ||
stream.end() | ||
}) | ||
stream.write('{"bar":{"foo":"baz"}}'); | ||
stream.end(); | ||
}); |
167
test/keys.js
@@ -1,6 +0,6 @@ | ||
var test = require('tape'); | ||
var fs = require ('fs'); | ||
var join = require('path').join; | ||
var couch_sample_file = join(__dirname, 'fixtures','couch_sample.json'); | ||
var JSONStream = require('../'); | ||
var test = require("tape"); | ||
var fs = require("fs"); | ||
var join = require("path").join; | ||
var couch_sample_file = join(__dirname, "fixtures", "couch_sample.json"); | ||
var JSONStream = require("../"); | ||
@@ -11,96 +11,101 @@ var fixture = { | ||
two: 2, | ||
three: 3 | ||
} | ||
three: 3, | ||
}, | ||
}; | ||
function assertFixtureKeys(stream, t) { | ||
var keys = []; | ||
var values = []; | ||
stream.on('data', function(data) { | ||
keys.push(data.key); | ||
values.push(data.value); | ||
}); | ||
var keys = []; | ||
var values = []; | ||
stream.on("data", function (data) { | ||
keys.push(data.key); | ||
values.push(data.value); | ||
}); | ||
stream.on('end', function() { | ||
t.deepEqual(keys, ['one', 'two', 'three']); | ||
t.deepEqual(values, [1,2,3]); | ||
t.end(); | ||
}); | ||
stream.write(JSON.stringify(fixture)); | ||
stream.end(); | ||
stream.on("finish", function () { | ||
t.deepEqual(keys, ["one", "two", "three"]); | ||
t.deepEqual(values, [1, 2, 3]); | ||
t.end(); | ||
}); | ||
stream.write(JSON.stringify(fixture)); | ||
stream.end(); | ||
} | ||
test('keys via string', function(t) { | ||
var stream = JSONStream.parse('obj.$*'); | ||
assertFixtureKeys(stream, t); | ||
test("keys via string", function (t) { | ||
var stream = JSONStream.parse("obj.$*"); | ||
assertFixtureKeys(stream, t); | ||
}); | ||
test('keys via array', function(t) { | ||
var stream = JSONStream.parse(['obj',{emitKey: true}]); | ||
assertFixtureKeys(stream, t); | ||
test("keys via array", function (t) { | ||
var stream = JSONStream.parse(["obj", { emitKey: true }]); | ||
assertFixtureKeys(stream, t); | ||
}); | ||
test('path via array', function(t) { | ||
var stream = JSONStream.parse(['obj',{emitPath: true}]); | ||
var paths = []; | ||
var values = []; | ||
stream.on('data', function(data) { | ||
console.log(JSON.stringify(data)); | ||
paths.push(data.path); | ||
values.push(data.value); | ||
}); | ||
test("path via array", function (t) { | ||
var stream = JSONStream.parse(["obj", { emitPath: true }]); | ||
stream.on('end', function() { | ||
t.deepEqual(paths, [['obj', 'one'], ['obj', 'two'], ['obj', 'three']]); | ||
t.deepEqual(values, [1,2,3]); | ||
t.end(); | ||
}); | ||
stream.write(JSON.stringify(fixture)); | ||
stream.end(); | ||
var paths = []; | ||
var values = []; | ||
stream.on("data", function (data) { | ||
console.log(JSON.stringify(data)); | ||
paths.push(data.path); | ||
values.push(data.value); | ||
}); | ||
stream.on("finish", function () { | ||
t.deepEqual(paths, [ | ||
["obj", "one"], | ||
["obj", "two"], | ||
["obj", "three"], | ||
]); | ||
t.deepEqual(values, [1, 2, 3]); | ||
t.end(); | ||
}); | ||
stream.write(JSON.stringify(fixture)); | ||
stream.end(); | ||
}); | ||
test('advanced keys', function(t) { | ||
var advanced = fs.readFileSync(couch_sample_file); | ||
var stream = JSONStream.parse(['rows', true, 'doc', {emitKey: true}]); | ||
test("advanced keys", function (t) { | ||
var advanced = fs.readFileSync(couch_sample_file); | ||
var stream = JSONStream.parse(["rows", true, "doc", { emitKey: true }]); | ||
var keys = []; | ||
var values = []; | ||
stream.on('data', function(data) { | ||
keys.push(data.key); | ||
values.push(data.value); | ||
}); | ||
var keys = []; | ||
var values = []; | ||
stream.on("data", function (data) { | ||
keys.push(data.key); | ||
values.push(data.value); | ||
}); | ||
stream.on('end', function() { | ||
t.deepEqual(keys, [ | ||
'_id', '_rev', 'hello', | ||
'_id', '_rev', 'hello' | ||
]); | ||
t.deepEqual(values, [ | ||
"change1_0.6995461115147918", "1-e240bae28c7bb3667f02760f6398d508", 1, | ||
"change2_0.6995461115147918", "1-13677d36b98c0c075145bb8975105153", 2 | ||
]); | ||
t.end(); | ||
}); | ||
stream.write(advanced); | ||
stream.end(); | ||
stream.on("finish", function () { | ||
t.deepEqual(keys, ["_id", "_rev", "hello", "_id", "_rev", "hello"]); | ||
t.deepEqual(values, [ | ||
"change1_0.6995461115147918", | ||
"1-e240bae28c7bb3667f02760f6398d508", | ||
1, | ||
"change2_0.6995461115147918", | ||
"1-13677d36b98c0c075145bb8975105153", | ||
2, | ||
]); | ||
t.end(); | ||
}); | ||
stream.write(advanced); | ||
stream.end(); | ||
}); | ||
test('parent keys', function(t) { | ||
var stream = JSONStream.parse('$*'); | ||
var d = null; | ||
stream.on('data', function(data) { | ||
if(d) t.fail('should only be called once'); | ||
d = data; | ||
}); | ||
test("parent keys", function (t) { | ||
var stream = JSONStream.parse("$*"); | ||
var d = null; | ||
stream.on("data", function (data) { | ||
if (d) t.fail("should only be called once"); | ||
d = data; | ||
}); | ||
stream.on('end', function() { | ||
t.deepEqual(d,{ | ||
key: 'obj', | ||
value: fixture.obj | ||
}); | ||
t.end(); | ||
stream.on("finish", function () { | ||
t.deepEqual(d, { | ||
key: "obj", | ||
value: fixture.obj, | ||
}); | ||
stream.write(JSON.stringify(fixture)); | ||
stream.end(); | ||
}) | ||
t.end(); | ||
}); | ||
stream.write(JSON.stringify(fixture)); | ||
stream.end(); | ||
}); |
@@ -0,40 +1,39 @@ | ||
var test = require("tape"); | ||
var test = require('tape') | ||
var JSONStream = require("../"); | ||
var JSONStream = require('../') | ||
test("map function", function (t) { | ||
var actual = []; | ||
test('map function', function (t) { | ||
stream = JSONStream.parse([true], function (e) { | ||
return e * 10; | ||
}); | ||
stream.on("data", function (v) { | ||
actual.push(v); | ||
}); | ||
stream.on("finish", function () { | ||
t.deepEqual(actual, [10, 20, 30, 40, 50, 60]); | ||
t.end(); | ||
}); | ||
var actual = [] | ||
stream.write(JSON.stringify([1, 2, 3, 4, 5, 6], null, 2)); | ||
stream.end(); | ||
}); | ||
stream = JSONStream.parse([true], function (e) { return e*10 }) | ||
stream.on('data', function (v) { actual.push(v)}) | ||
stream.on('end', function () { | ||
t.deepEqual(actual, [10,20,30,40,50,60]) | ||
t.end() | ||
test("filter function", function (t) { | ||
var actual = []; | ||
stream = JSONStream.parse([true], function (e) { | ||
return e % 2 ? e : null; | ||
}) | ||
.on("data", function (v) { | ||
actual.push(v); | ||
}) | ||
.on("finish", function () { | ||
t.deepEqual(actual, [1, 3, 5]); | ||
t.end(); | ||
}); | ||
stream.write(JSON.stringify([1,2,3,4,5,6], null, 2)) | ||
stream.end() | ||
}) | ||
test('filter function', function (t) { | ||
var actual = [] | ||
stream = JSONStream | ||
.parse([true], function (e) { return e%2 ? e : null}) | ||
.on('data', function (v) { actual.push(v)}) | ||
.on('end', function () { | ||
t.deepEqual(actual, [1,3,5]) | ||
t.end() | ||
}) | ||
stream.write(JSON.stringify([1,2,3,4,5,6], null, 2)) | ||
stream.end() | ||
}) | ||
stream.write(JSON.stringify([1, 2, 3, 4, 5, 6], null, 2)); | ||
stream.end(); | ||
}); |
@@ -1,33 +0,33 @@ | ||
var fs = require ('fs'); | ||
var net = require('net'); | ||
var join = require('path').join; | ||
var file = join(__dirname, 'fixtures','all_npm.json'); | ||
var it = require('it-is'); | ||
var JSONStream = require('../'); | ||
var fs = require("fs"); | ||
var net = require("net"); | ||
var join = require("path").join; | ||
var file = join(__dirname, "fixtures", "all_npm.json"); | ||
var it = require("it-is"); | ||
var JSONStream = require("../"); | ||
var str = fs.readFileSync(file); | ||
var server = net.createServer(function(client) { | ||
var data_calls = 0; | ||
var parser = JSONStream.parse(); | ||
parser.on('error', function(err) { | ||
console.log(err); | ||
server.close(); | ||
}); | ||
var server = net.createServer(function (client) { | ||
var data_calls = 0; | ||
var parser = JSONStream.parse(); | ||
parser.on("error", function (err) { | ||
console.log(err); | ||
server.close(); | ||
}); | ||
parser.on('end', function() { | ||
console.log('END'); | ||
server.close(); | ||
}); | ||
client.pipe(parser); | ||
parser.on("finish", function () { | ||
console.log("END"); | ||
server.close(); | ||
}); | ||
client.pipe(parser); | ||
}); | ||
server.listen(() => { | ||
var port = server.address().port | ||
var port = server.address().port; | ||
console.log('Listening on port ' + port) | ||
var client = net.connect({ port : port }, function() { | ||
var msgs = str + '}'; | ||
client.end(msgs); | ||
}); | ||
console.log("Listening on port " + port); | ||
var client = net.connect({ port: port }, function () { | ||
var msgs = str + "}"; | ||
client.end(msgs); | ||
}); | ||
}); |
@@ -1,40 +0,39 @@ | ||
var fs = require ('fs'); | ||
var net = require('net'); | ||
var join = require('path').join; | ||
var file = join(__dirname, 'fixtures','all_npm.json'); | ||
var it = require('it-is'); | ||
var JSONStream = require('../'); | ||
var fs = require("fs"); | ||
var net = require("net"); | ||
var join = require("path").join; | ||
var file = join(__dirname, "fixtures", "all_npm.json"); | ||
var it = require("it-is"); | ||
var JSONStream = require("../"); | ||
var str = fs.readFileSync(file); | ||
var datas = {} | ||
var datas = {}; | ||
var server = net.createServer(function(client) { | ||
var data_calls = 0; | ||
var parser = JSONStream.parse(['rows', true, 'key']); | ||
parser.on('data', function(data) { | ||
++ data_calls; | ||
datas[data] = (datas[data] || 0) + 1 | ||
it(data).typeof('string') | ||
}); | ||
var server = net.createServer(function (client) { | ||
var data_calls = 0; | ||
var parser = JSONStream.parse(["rows", true, "key"]); | ||
parser.on("data", function (data) { | ||
++data_calls; | ||
datas[data] = (datas[data] || 0) + 1; | ||
it(data).typeof("string"); | ||
}); | ||
parser.on('end', function() { | ||
console.log('END') | ||
var min = Infinity | ||
for (var d in datas) | ||
min = min > datas[d] ? datas[d] : min | ||
it(min).equal(3); | ||
server.close(); | ||
}); | ||
client.pipe(parser); | ||
parser.on("finish", function () { | ||
console.log("END"); | ||
var min = Infinity; | ||
for (var d in datas) min = min > datas[d] ? datas[d] : min; | ||
it(min).equal(3); | ||
server.close(); | ||
}); | ||
client.pipe(parser); | ||
}); | ||
server.listen(() => { | ||
var port = server.address().port | ||
var port = server.address().port; | ||
console.log('Listening on port ' + port) | ||
var client = net.connect({ port : port }, function() { | ||
var msgs = str + ' ' + str + '\n\n' + str | ||
client.end(msgs); | ||
}); | ||
console.log("Listening on port " + port); | ||
var client = net.connect({ port: port }, function () { | ||
var msgs = str + " " + str + "\n\n" + str; | ||
client.end(msgs); | ||
}); | ||
}); |
@@ -1,28 +0,27 @@ | ||
var JSONStream = require('../') | ||
var JSONStream = require("../"); | ||
var data = [ | ||
{ID: 1, optional: null}, | ||
{ID: 2, optional: null}, | ||
{ID: 3, optional: 20}, | ||
{ID: 4, optional: null}, | ||
{ID: 5, optional: 'hello'}, | ||
{ID: 6, optional: null} | ||
] | ||
{ ID: 1, optional: null }, | ||
{ ID: 2, optional: null }, | ||
{ ID: 3, optional: 20 }, | ||
{ ID: 4, optional: null }, | ||
{ ID: 5, optional: "hello" }, | ||
{ ID: 6, optional: null }, | ||
]; | ||
var test = require("tape"); | ||
var test = require('tape') | ||
test ('null properties', function (t) { | ||
var actual = [] | ||
var stream = | ||
JSONStream.parse('*.optional') | ||
.on('data', function (v) { actual.push(v) }) | ||
.on('end', function () { | ||
t.deepEqual(actual, [20, 'hello']) | ||
t.end() | ||
test("null properties", function (t) { | ||
var actual = []; | ||
var stream = JSONStream.parse("*.optional") | ||
.on("data", function (v) { | ||
actual.push(v); | ||
}) | ||
.on("finish", function () { | ||
t.deepEqual(actual, [20, "hello"]); | ||
t.end(); | ||
}); | ||
stream.write(JSON.stringify(data, null, 2)) | ||
stream.end() | ||
}) | ||
stream.write(JSON.stringify(data, null, 2)); | ||
stream.end(); | ||
}); |
@@ -1,3 +0,1 @@ | ||
/* | ||
@@ -7,24 +5,20 @@ sometimes jsonparse changes numbers slightly. | ||
var r = Math.random() | ||
, Parser = require('jsonparse') | ||
, p = new Parser() | ||
, assert = require('assert') | ||
, times = 20 | ||
, bufferFrom = Buffer.from && Buffer.from !== Uint8Array.from | ||
, str | ||
var r = Math.random(), | ||
Parser = require("jsonparse"), | ||
p = new Parser(), | ||
assert = require("assert"), | ||
times = 20, | ||
bufferFrom = Buffer.from && Buffer.from !== Uint8Array.from, | ||
str; | ||
while (times --) { | ||
while (times--) { | ||
assert.equal(JSON.parse(JSON.stringify(r)), r, "core JSON"); | ||
assert.equal(JSON.parse(JSON.stringify(r)), r, 'core JSON') | ||
p.onValue = function (v) { | ||
console.error('parsed', v) | ||
assert.equal(v,r) | ||
} | ||
console.error('correct', r) | ||
str = JSON.stringify([r]) | ||
p.write (bufferFrom ? Buffer.from(str) : new Buffer(str)) | ||
console.error("parsed", v); | ||
assert.equal(v, r); | ||
}; | ||
console.error("correct", r); | ||
str = JSON.stringify([r]); | ||
p.write(bufferFrom ? Buffer.from(str) : new Buffer(str)); | ||
} |
@@ -1,13 +0,14 @@ | ||
var readdirSync = require('fs').readdirSync | ||
var spawnSync = require('child_process').spawnSync | ||
var extname = require('path').extname | ||
var readdirSync = require("fs").readdirSync; | ||
var spawnSync = require("child_process").spawnSync; | ||
var extname = require("path").extname; | ||
var files = readdirSync(__dirname) | ||
files.forEach(function(file){ | ||
if (extname(file) !== '.js' || file === 'run.js') | ||
return | ||
console.log(`*** ${file} ***`) | ||
var result = spawnSync(process.argv0, [file], { stdio: 'inherit', cwd: __dirname} ) | ||
if (result.status !== 0) | ||
process.exit(result.status) | ||
}) | ||
var files = readdirSync(__dirname); | ||
files.forEach(function (file) { | ||
if (extname(file) !== ".js" || file === "run.js") return; | ||
console.log(`*** ${file} ***`); | ||
var result = spawnSync(process.argv0, [file], { | ||
stdio: "inherit", | ||
cwd: __dirname, | ||
}); | ||
if (result.status !== 0) process.exit(result.status); | ||
}); |
@@ -0,47 +1,46 @@ | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "all_npm.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is").style("colour"), | ||
es = require("event-stream"), | ||
pending = 10, | ||
passed = true; | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','all_npm.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is').style('colour') | ||
, es = require('event-stream') | ||
, pending = 10 | ||
, passed = true | ||
function randomObj() { | ||
return Math.random() < 0.4 | ||
? { | ||
hello: "eonuhckmqjk", | ||
whatever: 236515, | ||
lies: true, | ||
nothing: [null], | ||
stuff: [Math.random(), Math.random(), Math.random()], | ||
} | ||
: ["AOREC", "reoubaor", { ouec: 62642 }, [[[], {}, 53]]]; | ||
} | ||
function randomObj () { | ||
return ( | ||
Math.random () < 0.4 | ||
? {hello: 'eonuhckmqjk', | ||
whatever: 236515, | ||
lies: true, | ||
nothing: [null], | ||
stuff: [Math.random(),Math.random(),Math.random()] | ||
} | ||
: ['AOREC', 'reoubaor', {ouec: 62642}, [[[], {}, 53]]] | ||
) | ||
} | ||
for (var ix = 0; ix < pending; ix++) | ||
(function (count) { | ||
var expected = {}, | ||
stringify = JSONStream.stringifyObject(); | ||
for (var ix = 0; ix < pending; ix++) (function (count) { | ||
var expected = {} | ||
, stringify = JSONStream.stringifyObject() | ||
es.connect( | ||
stringify, | ||
es.writeArray(function (err, lines) { | ||
it(JSON.parse(lines.join(''))).deepEqual(expected) | ||
if (--pending === 0) { | ||
console.error('PASSED') | ||
} | ||
}) | ||
) | ||
es.connect( | ||
stringify, | ||
es.writeArray(function (err, lines) { | ||
it(JSON.parse(lines.join(""))).deepEqual(expected); | ||
if (--pending === 0) { | ||
console.error("PASSED"); | ||
} | ||
}) | ||
); | ||
while (count --) { | ||
var key = Math.random().toString(16).slice(2) | ||
expected[key] = randomObj() | ||
stringify.write([ key, expected[key] ]) | ||
} | ||
while (count--) { | ||
var key = Math.random().toString(16).slice(2); | ||
expected[key] = randomObj(); | ||
stringify.write([key, expected[key]]); | ||
} | ||
process.nextTick(function () { | ||
stringify.end() | ||
}) | ||
})(ix) | ||
process.nextTick(function () { | ||
stringify.end(); | ||
}); | ||
})(ix); |
@@ -0,41 +1,37 @@ | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "all_npm.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is").style("colour"); | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','all_npm.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is').style('colour') | ||
function randomObj() { | ||
return Math.random() < 0.4 | ||
? { | ||
hello: "eonuhckmqjk", | ||
whatever: 236515, | ||
lies: true, | ||
nothing: [null], | ||
stuff: [Math.random(), Math.random(), Math.random()], | ||
} | ||
: ["AOREC", "reoubaor", { ouec: 62642 }, [[[], {}, 53]]]; | ||
} | ||
function randomObj () { | ||
return ( | ||
Math.random () < 0.4 | ||
? {hello: 'eonuhckmqjk', | ||
whatever: 236515, | ||
lies: true, | ||
nothing: [null], | ||
stuff: [Math.random(),Math.random(),Math.random()] | ||
} | ||
: ['AOREC', 'reoubaor', {ouec: 62642}, [[[], {}, 53]]] | ||
) | ||
} | ||
var expected = [], | ||
stringify = JSONStream.stringify(), | ||
es = require("event-stream"), | ||
stringified = "", | ||
called = 0, | ||
count = 10, | ||
ended = false; | ||
var expected = [] | ||
, stringify = JSONStream.stringify() | ||
, es = require('event-stream') | ||
, stringified = '' | ||
, called = 0 | ||
, count = 10 | ||
, ended = false | ||
while (count --) | ||
expected.push(randomObj()) | ||
while (count--) expected.push(randomObj()); | ||
es.connect( | ||
es.readArray(expected), | ||
stringify, | ||
//JSONStream.parse([/./]), | ||
es.writeArray(function (err, lines) { | ||
it(JSON.parse(lines.join(''))).deepEqual(expected) | ||
console.error('PASSED') | ||
}) | ||
) | ||
es.connect( | ||
es.readArray(expected), | ||
stringify, | ||
//JSONStream.parse([/./]), | ||
es.writeArray(function (err, lines) { | ||
it(JSON.parse(lines.join(""))).deepEqual(expected); | ||
console.error("PASSED"); | ||
}) | ||
); |
@@ -0,35 +1,33 @@ | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "all_npm.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is"); | ||
var expected = JSON.parse(fs.readFileSync(file)), | ||
parser = JSONStream.parse(["rows", /\d+/ /*, 'value'*/]), | ||
called = 0, | ||
ended = false, | ||
parsed = []; | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','all_npm.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is') | ||
fs.createReadStream(file).pipe(parser); | ||
var expected = JSON.parse(fs.readFileSync(file)) | ||
, parser = JSONStream.parse(['rows', /\d+/ /*, 'value'*/]) | ||
, called = 0 | ||
, ended = false | ||
, parsed = [] | ||
fs.createReadStream(file).pipe(parser) | ||
parser.on('data', function (data) { | ||
called ++ | ||
parser.on("data", function (data) { | ||
called++; | ||
it.has({ | ||
id: it.typeof('string'), | ||
value: {rev: it.typeof('string')}, | ||
key:it.typeof('string') | ||
}) | ||
parsed.push(data) | ||
}) | ||
id: it.typeof("string"), | ||
value: { rev: it.typeof("string") }, | ||
key: it.typeof("string"), | ||
}); | ||
parsed.push(data); | ||
}); | ||
parser.on('end', function () { | ||
ended = true | ||
}) | ||
parser.on("finish", function () { | ||
ended = true; | ||
}); | ||
process.on('exit', function () { | ||
it(called).equal(expected.rows.length) | ||
it(parsed).deepEqual(expected.rows) | ||
console.error('PASSED') | ||
}) | ||
process.on("exit", function () { | ||
it(called).equal(expected.rows.length); | ||
it(parsed).deepEqual(expected.rows); | ||
console.error("PASSED"); | ||
}); |
@@ -0,29 +1,27 @@ | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "..", "package.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is"); | ||
var expected = JSON.parse(fs.readFileSync(file)), | ||
parser = JSONStream.parse([]), | ||
called = 0, | ||
ended = false, | ||
parsed = []; | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, '..','package.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is') | ||
fs.createReadStream(file).pipe(parser); | ||
var expected = JSON.parse(fs.readFileSync(file)) | ||
, parser = JSONStream.parse([]) | ||
, called = 0 | ||
, ended = false | ||
, parsed = [] | ||
parser.on("data", function (data) { | ||
called++; | ||
it(data).deepEqual(expected); | ||
}); | ||
fs.createReadStream(file).pipe(parser) | ||
parser.on('data', function (data) { | ||
called ++ | ||
it(data).deepEqual(expected) | ||
}) | ||
parser.on("finish", function () { | ||
ended = true; | ||
}); | ||
parser.on('end', function () { | ||
ended = true | ||
}) | ||
process.on('exit', function () { | ||
it(called).equal(1) | ||
console.error('PASSED') | ||
}) | ||
process.on("exit", function () { | ||
it(called).equal(1); | ||
console.error("PASSED"); | ||
}); |
@@ -0,41 +1,37 @@ | ||
var fs = require("fs"), | ||
join = require("path").join, | ||
file = join(__dirname, "fixtures", "all_npm.json"), | ||
JSONStream = require("../"), | ||
it = require("it-is").style("colour"); | ||
var fs = require ('fs') | ||
, join = require('path').join | ||
, file = join(__dirname, 'fixtures','all_npm.json') | ||
, JSONStream = require('../') | ||
, it = require('it-is').style('colour') | ||
function randomObj() { | ||
return Math.random() < 0.4 | ||
? { | ||
hello: "eonuhckmqjk", | ||
whatever: 236515, | ||
lies: true, | ||
nothing: [null], | ||
// stuff: [Math.random(),Math.random(),Math.random()] | ||
} | ||
: ["AOREC", "reoubaor", { ouec: 62642 }, [[[], {}, 53]]]; | ||
} | ||
function randomObj () { | ||
return ( | ||
Math.random () < 0.4 | ||
? {hello: 'eonuhckmqjk', | ||
whatever: 236515, | ||
lies: true, | ||
nothing: [null], | ||
// stuff: [Math.random(),Math.random(),Math.random()] | ||
} | ||
: ['AOREC', 'reoubaor', {ouec: 62642}, [[[], {}, 53]]] | ||
) | ||
} | ||
var expected = [], | ||
stringify = JSONStream.stringify(), | ||
es = require("event-stream"), | ||
stringified = "", | ||
called = 0, | ||
count = 10, | ||
ended = false; | ||
var expected = [] | ||
, stringify = JSONStream.stringify() | ||
, es = require('event-stream') | ||
, stringified = '' | ||
, called = 0 | ||
, count = 10 | ||
, ended = false | ||
while (count --) | ||
expected.push(randomObj()) | ||
while (count--) expected.push(randomObj()); | ||
es.connect( | ||
es.readArray(expected), | ||
stringify, | ||
JSONStream.parse([/./]), | ||
es.writeArray(function (err, lines) { | ||
it(lines).has(expected) | ||
console.error('PASSED') | ||
}) | ||
) | ||
es.connect( | ||
es.readArray(expected), | ||
stringify, | ||
JSONStream.parse([/./]), | ||
es.writeArray(function (err, lines) { | ||
it(lines).has(expected); | ||
console.error("PASSED"); | ||
}) | ||
); |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
413290
37
5255
+ Addedthrough2@^4.0.2
+ Addedinherits@2.0.4(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedthrough2@4.0.2(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedthrough@>=2.2.7 <3
- Removedthrough@2.3.8(transitive)