pull-json-parse
Advanced tools
Comparing version 0.0.2 to 0.0.3
20
index.js
@@ -6,2 +6,3 @@ 'use strict'; | ||
var BRACKET_END = 0x5d; | ||
var NEWLINE = 0xa; | ||
@@ -18,2 +19,4 @@ module.exports = parse; | ||
var line = ''; | ||
var cc = 0; | ||
var ll = 0; | ||
@@ -60,9 +63,16 @@ return function again( abort, cb ){ | ||
if (line.length === 1 && (line.charCodeAt(0) === BRACKET_START || line.charCodeAt(0) === BRACKET_END)) | ||
ll = line.length; | ||
if (ll === 0) | ||
continue; | ||
/* | ||
Optimization: find next `ni`, if non and query is | ||
empty, callback directly and avoid queue overhead | ||
*/ | ||
if (ll === 1) { | ||
cc = line.charCodeAt(0); | ||
if (cc === BRACKET_START | ||
|| cc === BRACKET_END | ||
|| cc === NEWLINE) | ||
continue; | ||
} | ||
queue.push(JSON.parse(line)); | ||
@@ -69,0 +79,0 @@ } |
{ | ||
"name": "pull-json-parse", | ||
"description": "Parse a pull-stream with newline delimited JSON", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"repository": "srcagency/pull-json-parse", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -26,2 +26,6 @@ 'use strict'; | ||
[ '"ping"', [ 'ping' ] ], | ||
[ '[\n]', [] ], | ||
[ '[\n\n]', [] ], | ||
[ '[\ntrue\n\n]', [ true ] ], | ||
[ '[\n|\ntrue\n|\n|\n\n|\n]', [ true ] ], | ||
].forEach(function( set ){ | ||
@@ -51,2 +55,2 @@ test(function( t ){ | ||
); | ||
}) | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4853
5
109