javascript-stringify
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -256,2 +256,3 @@ (function (root, stringify) { | ||
var references = !!options.references; | ||
var valueCount = Number(options.maxValues) || 100000; | ||
@@ -288,7 +289,7 @@ var path = []; | ||
if (value && (typeof value === 'object' || typeof value === 'function')) { | ||
var exists = encountered.indexOf(value); | ||
var seen = encountered.indexOf(value); | ||
// Track nodes to restore later. | ||
if (exists > -1) { | ||
restore.push(path.slice(), paths[exists]); | ||
if (seen > -1) { | ||
restore.push(path.slice(), paths[seen]); | ||
return; | ||
@@ -303,3 +304,3 @@ } | ||
// Stop when we hit the max depth. | ||
if (path.length > maxDepth) { | ||
if (path.length > maxDepth || valueCount-- <= 0) { | ||
return; | ||
@@ -314,3 +315,3 @@ } | ||
if (seen > -1 || path.length > maxDepth) { | ||
if (seen > -1 || path.length > maxDepth || valueCount-- <= 0) { | ||
return; | ||
@@ -317,0 +318,0 @@ } |
{ | ||
"name": "javascript-stringify", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Stringify is to `eval` as `JSON.stringify` is to `JSON.parse`", | ||
@@ -5,0 +5,0 @@ "main": "javascript-stringify.js", |
@@ -47,4 +47,5 @@ # JavaScript Stringify | ||
* **maxDepth** _(number)_ The maximum depth of values to stringify | ||
* **references** _(boolean)_ Restore circular/repeated references in the object (uses IIFE) | ||
* **maxDepth** _(number, default: 100)_ The maximum depth of values to stringify | ||
* **maxValues** _(number, default: 100000)_ The maximum number of values to stringify | ||
* **references** _(boolean, default: false)_ Restore circular/repeated references in the object (uses IIFE) | ||
@@ -83,2 +84,3 @@ ### Examples | ||
javascriptStringify(obj); // "{x:10}" | ||
javascriptStringify(obj, null, null, { references: true }); // "(function(){var x={x:10};x.circular=x;return x;}())" | ||
@@ -85,0 +87,0 @@ /** |
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
15739
316
118