fast-safe-stringify
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -1,2 +0,5 @@ | ||
function circular(obj, stack) { | ||
function circular(self, obj, stack) { | ||
var pos = stack.indexOf(self) | ||
if (++pos) stack.length = pos | ||
else stack.push(self) | ||
if (~stack.indexOf(obj)) return true | ||
@@ -8,4 +11,3 @@ if (Object(obj) === obj) stack.push(obj) | ||
function r(k, v) { | ||
if (circular(v, r.stack)) return '[Circular]' | ||
return v | ||
return circular(this, v, r.stack) ? '[Circular]' : v | ||
} | ||
@@ -18,3 +20,2 @@ | ||
module.exports = stringify |
{ | ||
"name": "fast-safe-stringify", | ||
"version": "1.0.5", | ||
"description": "", | ||
"version": "1.0.6", | ||
"description": "Safely and quickly serialize JavaScript objects", | ||
"main": "index.js", | ||
@@ -14,3 +14,15 @@ "scripts": { | ||
"json-stringify-safe": "^5.0.1" | ||
} | ||
}, | ||
"dependencies": { | ||
"fastbench": "^1.0.1", | ||
"json-stringify-safe": "^5.0.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/davidmarkclements/fast-safe-stringify.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/davidmarkclements/fast-safe-stringify/issues" | ||
}, | ||
"homepage": "https://github.com/davidmarkclements/fast-safe-stringify#readme" | ||
} |
@@ -21,19 +21,18 @@ # fast-safe-stringify | ||
The [json-stringify-safe](http://npm.im/json-stringify-safe) module supplies similar | ||
functionality with slightly more info. Although not JSON, | ||
the core `util.inspect` method can be used for similar purposes (e.g. | ||
logging) and also handles circular references. | ||
The [json-stringify-safe](http://npm.im/json-stringify-safe) module supplies similar functionality with more info and flexibility. | ||
Although not JSON, the core `util.inspect` method can be used for similar purposes (e.g. logging) and also handles circular references. | ||
Here we compare `fast-safe-stringify` with these alternatives: | ||
```js | ||
inspectBench*10000: 163.506ms | ||
jsonStringifySafeBench*10000: 71.508ms | ||
fastSafeStringifyBench*10000: 35.447ms | ||
inspectBench*10000: 135.528ms | ||
jsonStringifySafeBench*10000: 64.065ms | ||
fastSafeStringifyBench*10000: 33.956ms | ||
inspectBench*10000: 155.304ms | ||
jsonStringifySafeBench*10000: 86.004ms | ||
fastSafeStringifyBench*10000: 39.039ms | ||
inspectBench*10000: 133.499ms | ||
jsonStringifySafeBench*10000: 74.028ms | ||
fastSafeStringifyBench*10000: 38.698ms | ||
``` | ||
`fast-safe-stringify` is 2x faster than `json-stringify-safe` and 4x | ||
`fast-safe-stringify` is 2x faster than `json-stringify-safe` and 3x-4x | ||
faster than `util.inspect`. | ||
@@ -40,0 +39,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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
2765
37
0
1
0
2
47
+ Addedfastbench@^1.0.1
+ Addedjson-stringify-safe@^5.0.1
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfastbench@1.0.1(transitive)
+ Addedfastseries@1.7.2(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedxtend@4.0.2(transitive)