Socket
Socket
Sign inDemoInstall

stream-json

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-json - npm Package Compare versions

Comparing version 1.7.5 to 1.8.0

45

jsonl/Parser.js

@@ -10,2 +10,11 @@ 'use strict';

static checkedParse(input, reviver, errorIndicator) {
try {
return JSON.parse(input, reviver);
} catch (error) {
if (typeof errorIndicator == 'function') return errorIndicator(error);
}
return errorIndicator;
}
constructor(options) {

@@ -16,2 +25,3 @@ super(Object.assign({}, options, {readableObjectMode: true}));

this._reviver = options && options.reviver;
this._errorIndicator = options && options.errorIndicator;
if (options && options.checkErrors) {

@@ -21,2 +31,6 @@ this._processBuffer = this._checked_processBuffer;

}
if (options && 'errorIndicator' in options) {
this._processBuffer = this._suppressed_processBuffer;
this._flush = this._suppressed_flush;
}
}

@@ -49,2 +63,33 @@

_suppressed_processBuffer(callback) {
const lines = this._buffer.split('\n');
this._rest += lines[0];
if (lines.length > 1) {
if (this._rest) {
const value = JsonlParser.checkedParse(this._rest, this._reviver, this._errorIndicator);
value !== undefined && this.push({key: this._counter++, value});
}
this._rest = lines.pop();
for (let i = 1; i < lines.length; ++i) {
if (!lines[i]) continue;
const value = JsonlParser.checkedParse(lines[i], this._reviver, this._errorIndicator);
value !== undefined && this.push({key: this._counter++, value});
}
}
this._buffer = '';
callback(null);
}
_suppressed_flush(callback) {
super._flush(error => {
if (error) return callback(error);
if (this._rest) {
const value = JsonlParser.checkedParse(this._rest, this._reviver, this._errorIndicator);
value !== undefined && this.push({key: this._counter++, value});
this._rest = '';
}
callback(null);
});
}
_checked_processBuffer(callback) {

@@ -51,0 +96,0 @@ const lines = this._buffer.split('\n');

2

package.json
{
"name": "stream-json",
"version": "1.7.5",
"version": "1.8.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",

@@ -116,2 +116,3 @@ # stream-json [![NPM version][npm-image]][npm-url]

- 1.8.0 *added an option to indicate/ignore JSONL errors. Thx, [AK](https://github.com/ak--47).*
- 1.7.5 *fixed a stringer bug with ASCII control symbols. Thx, [Kraicheck](https://github.com/Kraicheck).*

@@ -118,0 +119,0 @@ - 1.7.4 *updated dependency (`stream-chain`), bugfix: inconsistent object/array braces. Thx [Xiao Li](https://github.com/xli1000).*

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc