stream-json
Advanced tools
+3
-1
| { | ||
| "printWidth": 160, | ||
| "singleQuote": true, | ||
| "bracketSpacing": false | ||
| "bracketSpacing": false, | ||
| "arrowParens": "avoid", | ||
| "trailingComma": "none" | ||
| } |
+1
-1
@@ -9,2 +9,2 @@ sudo: false | ||
| - "12" | ||
| - "13" | ||
| - "14" |
+0
-1
@@ -28,3 +28,2 @@ 'use strict'; | ||
| 'streamNumbers' in options && (this._streamNumbers = options.streamNumbers); | ||
| this._jsonStreaming = options.jsonStreaming; | ||
| } | ||
@@ -31,0 +30,0 @@ !this._packKeys && (this._streamKeys = true); |
+1
-1
| { | ||
| "name": "stream-json", | ||
| "version": "1.3.3", | ||
| "version": "1.4.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.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/uhop/stream-json", |
+1
-0
@@ -113,2 +113,3 @@ # stream-json | ||
| - 1.4.0 *added `makeArray` functionality to `Stringer`. Thx all who asked for it!* | ||
| - 1.3.3 *Bugfix: very large/infinite streams with garbage didn't fail. Thx [Arne Marschall](https://github.com/Disco1267)!* | ||
@@ -115,0 +116,0 @@ - 1.3.2 *Bugfix: filters could fail with packed-only token streams. Thx [Trey Brisbane](https://github.com/treybrisbane)!* |
+19
-0
@@ -39,2 +39,4 @@ 'use strict'; | ||
| const doNothing = () => {}; | ||
| class Stringer extends Transform { | ||
@@ -54,2 +56,3 @@ static make(options) { | ||
| 'useNumberValues' in options && (this._values.numberValue = options.useNumberValues); | ||
| this._makeArray = options.makeArray; | ||
| } | ||
@@ -59,4 +62,20 @@ | ||
| this._depth = 0; | ||
| if (this._makeArray) { | ||
| this._transform = this._arrayTransform; | ||
| this._flush = this._arrayFlush; | ||
| } | ||
| } | ||
| _arrayTransform(chunk, encoding, callback) { | ||
| // it runs once | ||
| delete this._transform; | ||
| this._transform({name: 'startArray'}, encoding, doNothing); | ||
| this._transform(chunk, encoding, callback); | ||
| } | ||
| _arrayFlush(callback) { | ||
| this._transform({name: 'endArray'}, null, callback); | ||
| } | ||
| _transform(chunk, _, callback) { | ||
@@ -63,0 +82,0 @@ if (this._values[chunk.name]) { |
@@ -136,2 +136,36 @@ 'use strict'; | ||
| }, | ||
| function test_stringer_json_stream_objects_as_array(t) { | ||
| const async = t.startAsync('test_stringer_json_stream_objects_as_array'); | ||
| const parser = makeParser({jsonStreaming: true}), | ||
| stringer = new Stringer({makeArray: true}), | ||
| pattern = { | ||
| a: [[[]]], | ||
| b: {a: 1}, | ||
| c: {a: 1, b: 2}, | ||
| d: [true, 1, "'x\"y'", null, false, true, {}, [], ''], | ||
| e: 1, | ||
| f: '', | ||
| g: true, | ||
| h: false, | ||
| i: null, | ||
| j: [], | ||
| k: {} | ||
| }; | ||
| let string = JSON.stringify(pattern), | ||
| shouldBe = '[' + string + ',' + string + ']', | ||
| buffer = ''; | ||
| string += string; | ||
| parser.pipe(stringer); | ||
| stringer.on('data', data => (buffer += data)); | ||
| stringer.on('end', () => { | ||
| eval(t.TEST('shouldBe === buffer')); | ||
| async.done(); | ||
| }); | ||
| new ReadString(string).pipe(parser); | ||
| }, | ||
| function test_stringer_json_stream_primitives(t) { | ||
@@ -138,0 +172,0 @@ const async = t.startAsync('test_stringer_json_stream_primitives'); |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
213081
0.68%4341
1%159
0.63%10
11.11%242
0.41%