json-stream-stringify
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -225,3 +225,3 @@ import { Readable } from 'stream'; | ||
key: "addToStack", | ||
value: function addToStack(value, key, index) { | ||
value: function addToStack(value, key, index, parent) { | ||
var _this2 = this; | ||
@@ -252,2 +252,12 @@ | ||
if ((parent && parent.type === 'Array' ? true : realValue !== undefined) && type !== 'Promise') { | ||
if (parent && !parent.first) { | ||
this._push(','); | ||
} | ||
/* eslint-disable-next-line no-param-reassign */ | ||
if (parent) parent.first = false; | ||
} | ||
if (realValue !== undefined && type !== 'Promise' && key) { | ||
@@ -286,3 +296,5 @@ if (this.gap) { | ||
type: type, | ||
value: realValue | ||
value: realValue, | ||
parent: parent, | ||
first: true | ||
}; | ||
@@ -319,3 +331,2 @@ | ||
}); | ||
obj.first = true; | ||
} | ||
@@ -345,8 +356,4 @@ | ||
if (end) this._push(end); | ||
if (item.addSeparatorAfterEnd) { | ||
this._push(','); | ||
} | ||
this.stack.splice(this.stack.indexOf(item), 1); | ||
var stackIndex = this.stack.indexOf(item); | ||
this.stack.splice(stackIndex, 1); | ||
} | ||
@@ -389,2 +396,3 @@ }, { | ||
value: function processObject(current) { | ||
// when no keys left, remove obj from stack | ||
if (!current.unread.length) { | ||
@@ -397,3 +405,3 @@ this.removeFromStack(current); | ||
var value = current.value[key]; | ||
this.addToStack(value, current.type === 'Object' && key, current.type === 'Array' && key).addSeparatorAfterEnd = !!current.unread.length; | ||
this.addToStack(value, current.type === 'Object' && key, current.type === 'Array' && key, current); | ||
} | ||
@@ -473,10 +481,5 @@ }, { | ||
return recursiveResolve(current.value).then(function (value) { | ||
var addSeparatorAfterEnd = current.addSeparatorAfterEnd; | ||
/* eslint-disable-next-line no-param-reassign */ | ||
current.addSeparatorAfterEnd = false; | ||
_this5.removeFromStack(current); | ||
_this5.addToStack(value, current.key, current.index).addSeparatorAfterEnd = addSeparatorAfterEnd; | ||
_this5.addToStack(value, current.key, current.index, current.parent); | ||
}); | ||
@@ -483,0 +486,0 @@ } |
@@ -249,3 +249,3 @@ import 'core-js/modules/es6.array.filter'; | ||
key: "addToStack", | ||
value: function addToStack(value, key, index) { | ||
value: function addToStack(value, key, index, parent) { | ||
var _this2 = this; | ||
@@ -276,2 +276,12 @@ | ||
if ((parent && parent.type === 'Array' ? true : realValue !== undefined) && type !== 'Promise') { | ||
if (parent && !parent.first) { | ||
this._push(','); | ||
} | ||
/* eslint-disable-next-line no-param-reassign */ | ||
if (parent) parent.first = false; | ||
} | ||
if (realValue !== undefined && type !== 'Promise' && key) { | ||
@@ -310,3 +320,5 @@ if (this.gap) { | ||
type: type, | ||
value: realValue | ||
value: realValue, | ||
parent: parent, | ||
first: true | ||
}; | ||
@@ -343,3 +355,2 @@ | ||
}); | ||
obj.first = true; | ||
} | ||
@@ -369,8 +380,4 @@ | ||
if (end) this._push(end); | ||
if (item.addSeparatorAfterEnd) { | ||
this._push(','); | ||
} | ||
this.stack.splice(this.stack.indexOf(item), 1); | ||
var stackIndex = this.stack.indexOf(item); | ||
this.stack.splice(stackIndex, 1); | ||
} | ||
@@ -413,2 +420,3 @@ }, { | ||
value: function processObject(current) { | ||
// when no keys left, remove obj from stack | ||
if (!current.unread.length) { | ||
@@ -421,3 +429,3 @@ this.removeFromStack(current); | ||
var value = current.value[key]; | ||
this.addToStack(value, current.type === 'Object' && key, current.type === 'Array' && key).addSeparatorAfterEnd = !!current.unread.length; | ||
this.addToStack(value, current.type === 'Object' && key, current.type === 'Array' && key, current); | ||
} | ||
@@ -497,10 +505,5 @@ }, { | ||
return recursiveResolve(current.value).then(function (value) { | ||
var addSeparatorAfterEnd = current.addSeparatorAfterEnd; | ||
/* eslint-disable-next-line no-param-reassign */ | ||
current.addSeparatorAfterEnd = false; | ||
_this5.removeFromStack(current); | ||
_this5.addToStack(value, current.key, current.index).addSeparatorAfterEnd = addSeparatorAfterEnd; | ||
_this5.addToStack(value, current.key, current.index, current.parent); | ||
}); | ||
@@ -507,0 +510,0 @@ } |
{ | ||
"name": "json-stream-stringify", | ||
"description": "JSON.Stringify as a readable stream", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Faleij <faleij@gmail.com> (https://github.com/faleij)", |
@@ -50,7 +50,7 @@ # JSON Stream Stringify | ||
// No Polyfills | ||
import JsonStreamStringify from 'JsonStreamStringify'; | ||
import JsonStreamStringify from 'json-stream-stringify'; | ||
``` | ||
```javascript | ||
// Polyfilled; loads only needed polyfills from @babel/polyfill @babel/runtime | ||
import JsonStreamStringify from 'JsonStreamStringify/module.polyfill'; | ||
import JsonStreamStringify from 'json-stream-stringify/module.polyfill'; | ||
``` | ||
@@ -60,3 +60,3 @@ | ||
```javascript | ||
const JsonStreamStringify = require('JsonStreamStringify'); | ||
const JsonStreamStringify = require('json-stream-stringify'); | ||
``` | ||
@@ -66,3 +66,3 @@ | ||
```javascript | ||
var JsonStreamStringify = require('JsonStreamStringify/umd.polyfill'); | ||
var JsonStreamStringify = require('json-stream-stringify/umd.polyfill'); | ||
``` | ||
@@ -69,0 +69,0 @@ |
35
umd.js
@@ -229,3 +229,3 @@ (function (global, factory) { | ||
key: "addToStack", | ||
value: function addToStack(value, key, index) { | ||
value: function addToStack(value, key, index, parent) { | ||
var _this2 = this; | ||
@@ -256,2 +256,12 @@ | ||
if ((parent && parent.type === 'Array' ? true : realValue !== undefined) && type !== 'Promise') { | ||
if (parent && !parent.first) { | ||
this._push(','); | ||
} | ||
/* eslint-disable-next-line no-param-reassign */ | ||
if (parent) parent.first = false; | ||
} | ||
if (realValue !== undefined && type !== 'Promise' && key) { | ||
@@ -290,3 +300,5 @@ if (this.gap) { | ||
type: type, | ||
value: realValue | ||
value: realValue, | ||
parent: parent, | ||
first: true | ||
}; | ||
@@ -323,3 +335,2 @@ | ||
}); | ||
obj.first = true; | ||
} | ||
@@ -349,8 +360,4 @@ | ||
if (end) this._push(end); | ||
if (item.addSeparatorAfterEnd) { | ||
this._push(','); | ||
} | ||
this.stack.splice(this.stack.indexOf(item), 1); | ||
var stackIndex = this.stack.indexOf(item); | ||
this.stack.splice(stackIndex, 1); | ||
} | ||
@@ -393,2 +400,3 @@ }, { | ||
value: function processObject(current) { | ||
// when no keys left, remove obj from stack | ||
if (!current.unread.length) { | ||
@@ -401,3 +409,3 @@ this.removeFromStack(current); | ||
var value = current.value[key]; | ||
this.addToStack(value, current.type === 'Object' && key, current.type === 'Array' && key).addSeparatorAfterEnd = !!current.unread.length; | ||
this.addToStack(value, current.type === 'Object' && key, current.type === 'Array' && key, current); | ||
} | ||
@@ -477,10 +485,5 @@ }, { | ||
return recursiveResolve(current.value).then(function (value) { | ||
var addSeparatorAfterEnd = current.addSeparatorAfterEnd; | ||
/* eslint-disable-next-line no-param-reassign */ | ||
current.addSeparatorAfterEnd = false; | ||
_this5.removeFromStack(current); | ||
_this5.addToStack(value, current.key, current.index).addSeparatorAfterEnd = addSeparatorAfterEnd; | ||
_this5.addToStack(value, current.key, current.index, current.parent); | ||
}); | ||
@@ -487,0 +490,0 @@ } |
@@ -239,3 +239,3 @@ (function (global, factory) { | ||
key: "addToStack", | ||
value: function addToStack(value, key, index) { | ||
value: function addToStack(value, key, index, parent) { | ||
var _this2 = this; | ||
@@ -266,2 +266,12 @@ | ||
if ((parent && parent.type === 'Array' ? true : realValue !== undefined) && type !== 'Promise') { | ||
if (parent && !parent.first) { | ||
this._push(','); | ||
} | ||
/* eslint-disable-next-line no-param-reassign */ | ||
if (parent) parent.first = false; | ||
} | ||
if (realValue !== undefined && type !== 'Promise' && key) { | ||
@@ -300,3 +310,5 @@ if (this.gap) { | ||
type: type, | ||
value: realValue | ||
value: realValue, | ||
parent: parent, | ||
first: true | ||
}; | ||
@@ -333,3 +345,2 @@ | ||
}); | ||
obj.first = true; | ||
} | ||
@@ -359,8 +370,4 @@ | ||
if (end) this._push(end); | ||
if (item.addSeparatorAfterEnd) { | ||
this._push(','); | ||
} | ||
this.stack.splice(this.stack.indexOf(item), 1); | ||
var stackIndex = this.stack.indexOf(item); | ||
this.stack.splice(stackIndex, 1); | ||
} | ||
@@ -403,2 +410,3 @@ }, { | ||
value: function processObject(current) { | ||
// when no keys left, remove obj from stack | ||
if (!current.unread.length) { | ||
@@ -411,3 +419,3 @@ this.removeFromStack(current); | ||
var value = current.value[key]; | ||
this.addToStack(value, current.type === 'Object' && key, current.type === 'Array' && key).addSeparatorAfterEnd = !!current.unread.length; | ||
this.addToStack(value, current.type === 'Object' && key, current.type === 'Array' && key, current); | ||
} | ||
@@ -487,10 +495,5 @@ }, { | ||
return recursiveResolve(current.value).then(function (value) { | ||
var addSeparatorAfterEnd = current.addSeparatorAfterEnd; | ||
/* eslint-disable-next-line no-param-reassign */ | ||
current.addSeparatorAfterEnd = false; | ||
_this5.removeFromStack(current); | ||
_this5.addToStack(value, current.key, current.index).addSeparatorAfterEnd = addSeparatorAfterEnd; | ||
_this5.addToStack(value, current.key, current.index, current.parent); | ||
}); | ||
@@ -497,0 +500,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
169010
1903
0