Socket
Socket
Sign inDemoInstall

fast-stringify

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-stringify - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

CHANGELOG.md

2

dist/fast-stringify.js

@@ -9,3 +9,3 @@ (function (global, factory) {

var _this=undefined,_typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a};var create=Object.create;var getCircularValue=function(a,b,c){return '[ref-'+c+']'};var getNewCache=function(){return HAS_WEAKSET_SUPPORT?new WeakSet:create({_values:[],add:function b(a){this._values.push(a);},has:function b(a){return !!~this._values.indexOf(a)}})};var getValue=function(a,b){return b};var createReplacer=function(a,b){var c=getNewCache(),d=0;return function(e,f){if(f&&'object'===('undefined'==typeof f?'undefined':_typeof(f))){if(c.has(f))return (b||getCircularValue).call(_this,e,f,d++);c.add(f);}return (a||getValue).call(_this,e,f)}};
var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a};var create=Object.create;var getCircularValue=function(a,b,c){return '[ref-'+c+']'};var getNewCache=function(){return HAS_WEAKSET_SUPPORT?new WeakSet:create({_values:[],add:function b(a){this._values.push(a);},has:function b(a){return !!~this._values.indexOf(a)}})};var createReplacer=function(a,b){var c=getNewCache(),d=0,e=0;return function(f,g){if(g&&'object'===('undefined'==typeof g?'undefined':_typeof(g))&&!(g instanceof Date||g instanceof RegExp)){if(e){if(c.has(g))return (b||getCircularValue).call(this,f,g,d++);c.add(this);}else c.add(g);e++;}return null==a?g:a.call(this,f,g)}};

@@ -12,0 +12,0 @@ function stringify(a,b,c,d){return JSON.stringify(a,createReplacer(b,d),c)}

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.fastCopy={})}(this,function(e){"use strict";var t="function"==typeof global.WeakSet,r=void 0,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=Object.create,f=function(n,o){var f=t?new WeakSet:c({_values:[],add:function(e){this._values.push(e)},has:function(e){return!!~this._values.indexOf(e)}}),u=0;return function(e,t){if(t&&"object"===(void 0===t?"undefined":i(t))){if(f.has(t))return(o||function(e,t,n){return"[ref-"+n+"]"}).call(r,e,t,u++);f.add(t)}return(n||function(e,t){return t}).call(r,e,t)}};e.default=function(e,t,n,o){return JSON.stringify(e,f(t,o),n)},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.fastCopy={})}(this,function(e){"use strict";var t="function"==typeof global.WeakSet,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=Object.create,f=function(n,o){var f=t?new WeakSet:c({_values:[],add:function(e){this._values.push(e)},has:function(e){return!!~this._values.indexOf(e)}}),i=0,u=0;return function(e,t){if(t&&"object"===(void 0===t?"undefined":r(t))&&!(t instanceof Date||t instanceof RegExp)){if(u){if(f.has(t))return(o||function(e,t,n){return"[ref-"+n+"]"}).call(this,e,t,i++);f.add(this)}else f.add(t);u++}return null==n?t:n.call(this,e,t)}};e.default=function(e,t,n,o){return JSON.stringify(e,f(t,o),n)},Object.defineProperty(e,"__esModule",{value:!0})});

@@ -1,3 +0,1 @@

var _this = this;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -72,18 +70,25 @@

var cache = getNewCache();
var getStandard = replacer || getValue;
var getCircular = circularReplacer || getCircularValue;
var refCount = 0;
var refCount = 0,
cacheCount = 0;
return function (key, value) {
if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
if (cache.has(value)) {
return getCircular.call(_this, key, value, refCount++);
return function customReplacer(key, value) {
if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !(value instanceof Date || value instanceof RegExp)) {
if (cacheCount) {
if (cache.has(value)) {
return getCircular.call(this, key, value, refCount++);
}
cache.add(this);
} else {
cache.add(value);
}
cache.add(value);
cacheCount++;
}
return getStandard.call(_this, key, value);
// eslint-disable-next-line eqeqeq
return replacer == null ? value : replacer.call(this, key, value);
};
};

@@ -75,18 +75,25 @@ 'use strict';

var cache = getNewCache();
var getStandard = replacer || getValue;
var getCircular = circularReplacer || getCircularValue;
var refCount = 0;
var refCount = 0,
cacheCount = 0;
return function (key, value) {
if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
if (cache.has(value)) {
return getCircular.call(undefined, key, value, refCount++);
return function customReplacer(key, value) {
if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !(value instanceof Date || value instanceof RegExp)) {
if (cacheCount) {
if (cache.has(value)) {
return getCircular.call(this, key, value, refCount++);
}
cache.add(this);
} else {
cache.add(value);
}
cache.add(value);
cacheCount++;
}
return getStandard.call(undefined, key, value);
// eslint-disable-next-line eqeqeq
return replacer == null ? value : replacer.call(this, key, value);
};
};

@@ -93,3 +93,3 @@ {

"types": "index.d.ts",
"version": "1.0.0"
"version": "1.0.1"
}

@@ -54,8 +54,8 @@ # fast-stringify

| -------------------------- | ------------------- | ------------------------ |
| **fast-stringify** | **620,309** | **0.72%** |
| fast-json-stable-stringify | 377,226 | 0.79% |
| json-stringify-safe | 293,797 | 0.85% |
| json-stable-stringify | 273,134 | 0.74% |
| json-cycle | 197.671 | 0.79% |
| decircularize | 132,988 | 0.84% |
| **fast-stringify** | **633,749** | **0.85%** |
| fast-json-stable-stringify | 349,351 | 0.58% |
| json-stringify-safe | 292,456 | 0.75% |
| json-stable-stringify | 267,359 | 0.57% |
| json-cycle | 193,863 | 0.71% |
| decircularize | 121,932 | 0.70% |

@@ -68,8 +68,8 @@ #### Complex objects

| -------------------------- | ------------------- | ------------------------ |
| **fast-stringify** | **103,217** | **0.92%** |
| fast-json-stable-stringify | 59,009 | 0.94% |
| json-cycle | 53,639 | 0.84% |
| json-stringify-safe | 53,112 | 0.70% |
| json-stable-stringify | 42,912 | 0.94% |
| decircularize | 22,649 | 0.85% |
| **fast-stringify** | **116,155** | **0.67%** |
| fast-json-stable-stringify | 57,484 | 0.68% |
| json-cycle | 52,758 | 0.71% |
| json-stringify-safe | 52,575 | 0.72% |
| json-stable-stringify | 41,761 | 0.60% |
| decircularize | 21,784 | 0.88% |

@@ -82,6 +82,6 @@ #### Circular objects

| ------------------------------------------ | ------------------- | ------------------------ |
| **fast-stringify** | **97,382** | **0.78%** |
| json-stringify-safe | 50,941 | 0.61% |
| json-cycle | 50,275 | 0.74% |
| decircularize | 21,108 | 0.82% |
| **fast-stringify** | **105,932** | **0.84%** |
| json-stringify-safe | 49,366 | 1.07% |
| json-cycle | 49,152 | 0.67% |
| decircularize | 20,626 | 0.81% |
| fast-json-stable-stringify (not supported) | 0 | 0.00% |

@@ -96,8 +96,8 @@ | json-stable-stringify (not supported) | 0 | 0.00% |

| -------------------------- | ------------------- | ------------------------ |
| **fast-stringify** | **32,684** | **0.63%** |
| json-cycle | 21,410 | 0.83% |
| fast-json-stable-stringify | 18,825 | 0.86% |
| json-stringify-safe | 17,386 | 0.97% |
| json-stable-stringify | 14,193 | 0.86% |
| decircularize | 7,368 | 0.80% |
| **fast-stringify** | **35,391** | **0.67%** |
| json-cycle | 20,413 | 0.63% |
| fast-json-stable-stringify | 17,908 | 0.52% |
| json-stringify-safe | 16,988 | 0.85% |
| json-stable-stringify | 13,984 | 0.85% |
| decircularize | 7,223 | 0.65% |

@@ -104,0 +104,0 @@ ## Development

Sorry, the diff of this file is not supported yet

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