stream-json
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -55,3 +55,3 @@ 'use strict'; | ||
stack.push(new Emit('endArray')); | ||
for (var i = top.length - 1; i >= 0; --i) { | ||
for (let i = top.length - 1; i >= 0; --i) { | ||
stack.push(top[i]); | ||
@@ -63,3 +63,3 @@ } | ||
stack.push(new Emit('endObject')); | ||
for (var i = keys.length - 1; i >= 0; --i) { | ||
for (let i = keys.length - 1; i >= 0; --i) { | ||
const key = keys[i]; | ||
@@ -66,0 +66,0 @@ stack.push(top[key], key, new Emit('keyValue')); |
{ | ||
"name": "stream-json", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"description": "stream-json is the micro-library of Node.js stream components for creating custom JSON processing pipelines with a minimal memory footprint. It can parse JSON files far exceeding available memory streaming individual primitives using a SAX-inspired API. Includes utilities to stream JSON database dumps.", | ||
@@ -12,3 +12,3 @@ "homepage": "http://github.com/uhop/stream-json", | ||
"dependencies": { | ||
"stream-chain": "^2.0.3" | ||
"stream-chain": "^2.1.0" | ||
}, | ||
@@ -15,0 +15,0 @@ "devDependencies": { |
@@ -88,21 +88,19 @@ 'use strict'; | ||
this._done = true; | ||
this._processInput( | ||
function(err) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
if (this._open_number) { | ||
if (this._streamNumbers) { | ||
this.push({name: 'endNumber'}); | ||
} | ||
this._open_number = false; | ||
if (this._packNumbers) { | ||
this.push({name: 'numberValue', value: this._accumulator}); | ||
this._accumulator = ''; | ||
} | ||
this._processInput(err => { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
if (this._open_number) { | ||
if (this._streamNumbers) { | ||
this.push({name: 'endNumber'}); | ||
} | ||
callback(null); | ||
this._open_number = false; | ||
if (this._packNumbers) { | ||
this.push({name: 'numberValue', value: this._accumulator}); | ||
this._accumulator = ''; | ||
} | ||
} | ||
}.bind(this) | ||
); | ||
callback(null); | ||
} | ||
}); | ||
} | ||
@@ -146,5 +144,3 @@ | ||
if (this._open_number) { | ||
if (this._streamNumbers) { | ||
this.push({name: 'endNumber'}); | ||
} | ||
this._streamNumbers && this.push({name: 'endNumber'}); | ||
this._open_number = false; | ||
@@ -166,5 +162,3 @@ if (this._packNumbers) { | ||
} | ||
if (this._packNumbers) { | ||
this._accumulator = '-'; | ||
} | ||
this._packNumbers && (this._accumulator = '-'); | ||
this._expect = 'numberStart'; | ||
@@ -178,5 +172,3 @@ break; | ||
} | ||
if (this._packNumbers) { | ||
this._accumulator = '0'; | ||
} | ||
this._packNumbers && (this._accumulator = '0'); | ||
this._expect = 'numberFraction'; | ||
@@ -198,5 +190,3 @@ break; | ||
} | ||
if (this._packNumbers) { | ||
this._accumulator = value; | ||
} | ||
this._packNumbers && (this._accumulator = value); | ||
this._expect = 'numberDigit'; | ||
@@ -247,3 +237,3 @@ break; | ||
} else if (value.length > 1 && value.charAt(0) === '\\') { | ||
var t = value.length == 2 ? codes[value.charAt(1)] : fromHex(value); | ||
const t = value.length == 2 ? codes[value.charAt(1)] : fromHex(value); | ||
if (this._expect === 'keyVal' ? this._streamKeys : this._streamStrings) { | ||
@@ -301,5 +291,3 @@ this.push({name: 'stringChunk', value: t}); | ||
value = match[0]; | ||
if (value === ':') { | ||
this._expect = 'value'; | ||
} | ||
value === ':' && (this._expect = 'value'); | ||
if (noSticky) { | ||
@@ -351,5 +339,3 @@ this._buffer = this._buffer.slice(value.length); | ||
this._streamNumbers && this.push({name: 'numberChunk', value: value}); | ||
if (this._packNumbers) { | ||
this._accumulator += value; | ||
} | ||
this._packNumbers && (this._accumulator += value); | ||
this._expect = value === '0' ? 'numberFraction' : 'numberDigit'; | ||
@@ -372,5 +358,3 @@ if (noSticky) { | ||
this._streamNumbers && this.push({name: 'numberChunk', value: value}); | ||
if (this._packNumbers) { | ||
this._accumulator += value; | ||
} | ||
this._packNumbers && (this._accumulator += value); | ||
if (noSticky) { | ||
@@ -405,5 +389,3 @@ this._buffer = this._buffer.slice(value.length); | ||
this._streamNumbers && this.push({name: 'numberChunk', value: value}); | ||
if (this._packNumbers) { | ||
this._accumulator += value; | ||
} | ||
this._packNumbers && (this._accumulator += value); | ||
this._expect = value === '.' ? 'numberFracStart' : 'numberExpSign'; | ||
@@ -425,5 +407,3 @@ if (noSticky) { | ||
this._streamNumbers && this.push({name: 'numberChunk', value: value}); | ||
if (this._packNumbers) { | ||
this._accumulator += value; | ||
} | ||
this._packNumbers && (this._accumulator += value); | ||
this._expect = 'numberFracDigit'; | ||
@@ -442,5 +422,3 @@ if (noSticky) { | ||
this._streamNumbers && this.push({name: 'numberChunk', value: value}); | ||
if (this._packNumbers) { | ||
this._accumulator += value; | ||
} | ||
this._packNumbers && (this._accumulator += value); | ||
if (noSticky) { | ||
@@ -479,5 +457,3 @@ this._buffer = this._buffer.slice(value.length); | ||
this._streamNumbers && this.push({name: 'numberChunk', value: value}); | ||
if (this._packNumbers) { | ||
this._accumulator += value; | ||
} | ||
this._packNumbers && (this._accumulator += value); | ||
this._expect = 'numberExpSign'; | ||
@@ -503,5 +479,3 @@ if (noSticky) { | ||
this._streamNumbers && this.push({name: 'numberChunk', value: value}); | ||
if (this._packNumbers) { | ||
this._accumulator += value; | ||
} | ||
this._packNumbers && (this._accumulator += value); | ||
this._expect = 'numberExpStart'; | ||
@@ -523,5 +497,3 @@ if (noSticky) { | ||
this._streamNumbers && this.push({name: 'numberChunk', value: value}); | ||
if (this._packNumbers) { | ||
this._accumulator += value; | ||
} | ||
this._packNumbers && (this._accumulator += value); | ||
this._expect = 'numberExpDigit'; | ||
@@ -540,5 +512,3 @@ if (noSticky) { | ||
this._streamNumbers && this.push({name: 'numberChunk', value: value}); | ||
if (this._packNumbers) { | ||
this._accumulator += value; | ||
} | ||
this._packNumbers && (this._accumulator += value); | ||
if (noSticky) { | ||
@@ -587,5 +557,3 @@ this._buffer = this._buffer.slice(value.length); | ||
} | ||
if (!noSticky) { | ||
this._buffer = this._buffer.slice(index); | ||
} | ||
!noSticky && (this._buffer = this._buffer.slice(index)); | ||
callback(null); | ||
@@ -592,0 +560,0 @@ } |
@@ -44,2 +44,3 @@ # stream-json | ||
* [withParser()](https://github.com/uhop/stream-json/wiki/withParser()) helps to create stream components with a parser. | ||
* [Verifier](https://github.com/uhop/stream-json/wiki/Verifier) reads a stream and verifies that it is a valid JSON. | ||
@@ -105,2 +106,3 @@ All components are meant to be building blocks to create flexible custom data processing pipelines. They can be extended and/or combined with custom code. They can be used together with [stream-chain](https://www.npmjs.com/package/stream-chain) to simplify data processing. | ||
- 1.2.0 *added `Verifier`.* | ||
- 1.1.4 *fixed `Filter` going haywire, thx [@codebling](https://github.com/codebling)!* | ||
@@ -107,0 +109,0 @@ - 1.1.3 *fixed `Parser` streaming numbers when shouldn't, thx [Grzegorz Lachowski](https://github.com/gregolsky)!* |
@@ -80,3 +80,3 @@ 'use strict'; | ||
function test_parser_streamer(t) { | ||
const async = t.startAsync('test_streamer'); | ||
const async = t.startAsync('test_parser_streamer'); | ||
@@ -83,0 +83,0 @@ const input = '{"a": 1, "b": true, "c": ["d"]}', |
@@ -21,3 +21,4 @@ 'use strict'; | ||
require('./test_disassembler'); | ||
require('./test_verifier'); | ||
unit.run(); |
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
202814
46
4039
145
224
Updatedstream-chain@^2.1.0