Socket
Socket
Sign inDemoInstall

fast-safe-stringify

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-safe-stringify - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

9

index.js

@@ -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 @@

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