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.1.0 to 1.1.1

4

CHANGELOG.md
# fast-stringify CHANGELOG
## 1.1.1
- Upgrade to use Babel 7 for transformations
## 1.1.0

@@ -4,0 +8,0 @@

@@ -7,5 +7,55 @@ (function (global, factory) {

var first=function(a,b){for(var c=Array(b),d=0;d<b;d++)c[d]=a[d];return c};var getCircularValue=function(a,b,c){return '[ref-'+c+']'};var indexOf=function(a,b){for(var c=0;c<a.length;c++)if(a[c]===b)return c;return -1};var createReplacer=function(a,b){var c=[],d=void 0,e=void 0;return function(f,g){if(!c.length)c[0]=g;else if(d=indexOf(c,this),~d?c=first(c,d+1):c[c.length]=this,e=indexOf(c,g),~e)return (b||getCircularValue).call(this,f,g,e);return 'function'==typeof a?a.call(this,f,g):g}};
/**
* @function first
*
* @description
* get the first n number of items from the array as a new array (faster than native splice)
*
* @param {Array<any>} array the array to get the items from
* @param {number} length the length to limit the size to
* @returns {Array<any>} the array limited in size
*/var first=function(a,b){for(var c=Array(b),d=0;d<b;d++)c[d]=a[d];return c};/**
* @function getCircularValue
*
* @description
* create a method that will get a placeholder for the circular value based
* on the value saved in the cache for it
*
* @param {any} key the key of the object to stringify
* @param {any} value the value of the object at key
* @param {number} refCount the index of the ref
* @returns {string} the circular value
*/var getCircularValue=function(a,b,c){return "[ref-"+c+"]"};/**
* @function indexOf
*
* @description
* get the index of the value in the array (faster than native indexOf)
*
* @param {Array<any>} array the array to get the index of the value at
* @param {any} value the value to match
* @returns {number} the index of the value in array
*/var indexOf=function(a,b){for(var c=0;c<a.length;c++)if(a[c]===b)return c;return -1};/**
* @function createReplacer
*
* @description
* create a replacer method that handles circular values
*
* @param {function} [replacer] a custom replacer to use for non-circular values
* @param {function} [circularReplacer] a custom replacer to use for circular methods
* @returns {any} the value to stringify
*/var createReplacer=function(a,b){var c,d,e=[];return function(f,g){if(!e.length)e[0]=g;else if(c=indexOf(e,this),~c?e=first(e,c+1):e[e.length]=this,d=indexOf(e,g),~d)return (b||getCircularValue).call(this,f,g,d);return "function"==typeof a?a.call(this,f,g):g}};
function stringify(a,b,c,d){return JSON.stringify(a,createReplacer(b,d),c)}
// utils
/**
* @function stringify
*
* @description
* strinigifer that handles circular values
*
* @param {any} value the value to stringify
* @param {function} [replacer] a custom replacer function for stringifying standard values
* @param {number} [indent] the number of spaces to indent the output by
* @param {function} [circularReplacer] a custom replacer function for stringifying circular values
* @returns {string} the stringified output
*/function stringify(a,b,c,d){return JSON.stringify(a,createReplacer(b,d),c)}

@@ -12,0 +62,0 @@ exports.default = stringify;

2

dist/fast-stringify.min.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.fastCopy={})}(this,function(t){"use strict";var u=function(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1},f=function(n,r){var f=[],i=void 0,o=void 0;return function(t,e){if(f.length){if(~(i=u(f,this))?f=function(t,e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}(f,i+1):f[f.length]=this,~(o=u(f,e)))return(r||function(t,e,n){return"[ref-"+n+"]"}).call(this,t,e,o)}else f[0]=e;return"function"==typeof n?n.call(this,t,e):e}};t.default=function(t,e,n,r){return JSON.stringify(t,f(e,r),n)},Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.fastCopy={})}(this,function(t){"use strict";var u=function(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1},f=function(n,r){var f,i,o=[];return function(t,e){if(o.length){if(~(f=u(o,this))?o=function(t,e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}(o,f+1):o[o.length]=this,~(i=u(o,e)))return(r||function(t,e,n){return"[ref-"+n+"]"}).call(this,t,e,i)}else o[0]=e;return"function"==typeof n?n.call(this,t,e):e}};t.default=function(t,e,n,r){return JSON.stringify(t,f(e,r),n)},Object.defineProperty(t,"__esModule",{value:!0})});
// utils
import { createReplacer } from './utils';
/**

@@ -16,4 +15,5 @@ * @function stringify

*/
export default function stringify(value, replacer, indent, circularReplacer) {
return JSON.stringify(value, createReplacer(replacer, circularReplacer), indent);
}

@@ -20,3 +20,2 @@ /**

};
/**

@@ -34,6 +33,6 @@ * @function getCircularValue

*/
export var getCircularValue = function getCircularValue(key, value, refCount) {
return '[ref-' + refCount + ']';
return "[ref-" + refCount + "]";
};
/**

@@ -49,6 +48,6 @@ * @function getValue

*/
export var getValue = function getValue(key, value) {
return value;
};
/**

@@ -64,2 +63,3 @@ * @function indexOf

*/
export var indexOf = function indexOf(array, value) {

@@ -74,3 +74,2 @@ for (var index = 0; index < array.length; index++) {

};
/**

@@ -86,10 +85,9 @@ * @function createReplacer

*/
export var createReplacer = function createReplacer(replacer, circularReplacer) {
var getCircularReplacer = circularReplacer || getCircularValue;
var hasReplacer = typeof replacer === 'function';
var cache = [],
locationOfThis = void 0,
locationOfValue = void 0;
locationOfThis,
locationOfValue;
return function (key, value) {

@@ -96,0 +94,0 @@ if (cache.length) {

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

'use strict';
"use strict";

@@ -6,4 +6,6 @@ exports.__esModule = true;

var _utils = require('./utils');
var _utils = require("./utils");
// utils
/**

@@ -23,2 +25,2 @@ * @function stringify

return JSON.stringify(value, (0, _utils.createReplacer)(replacer, circularReplacer), indent);
} // utils
}

@@ -1,4 +0,6 @@

'use strict';
"use strict";
exports.__esModule = true;
exports.createReplacer = exports.indexOf = exports.getValue = exports.getCircularValue = exports.first = void 0;
/**

@@ -14,3 +16,3 @@ * @function first

*/
var first = exports.first = function first(array, length) {
var first = function first(array, length) {
var newArray = new Array(length);

@@ -24,3 +26,2 @@

};
/**

@@ -38,6 +39,9 @@ * @function getCircularValue

*/
var getCircularValue = exports.getCircularValue = function getCircularValue(key, value, refCount) {
return '[ref-' + refCount + ']';
exports.first = first;
var getCircularValue = function getCircularValue(key, value, refCount) {
return "[ref-" + refCount + "]";
};
/**

@@ -53,6 +57,9 @@ * @function getValue

*/
var getValue = exports.getValue = function getValue(key, value) {
exports.getCircularValue = getCircularValue;
var getValue = function getValue(key, value) {
return value;
};
/**

@@ -68,3 +75,7 @@ * @function indexOf

*/
var indexOf = exports.indexOf = function indexOf(array, value) {
exports.getValue = getValue;
var indexOf = function indexOf(array, value) {
for (var index = 0; index < array.length; index++) {

@@ -78,3 +89,2 @@ if (array[index] === value) {

};
/**

@@ -90,10 +100,12 @@ * @function createReplacer

*/
var createReplacer = exports.createReplacer = function createReplacer(replacer, circularReplacer) {
exports.indexOf = indexOf;
var createReplacer = function createReplacer(replacer, circularReplacer) {
var getCircularReplacer = circularReplacer || getCircularValue;
var hasReplacer = typeof replacer === 'function';
var cache = [],
locationOfThis = void 0,
locationOfValue = void 0;
locationOfThis,
locationOfValue;
return function (key, value) {

@@ -120,2 +132,4 @@ if (cache.length) {

};
};
};
exports.createReplacer = createReplacer;
{
"author": "tony_quetano@planttheidea.com",
"ava": {
"babel": "inherit",
"failFast": true,

@@ -10,6 +9,6 @@ "files": [

"require": [
"babel-register",
"@babel/register",
"test/helpers/setup-browser-env.js"
],
"source": [
"sources": [
"src/*.js"

@@ -24,19 +23,22 @@ ],

"devDependencies": {
"ava": "^0.25.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.2.6",
"babel-loader": "^7.1.5",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-minify": "^0.4.3",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.1.2",
"ava": "^1.0.0-rc.1",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.0",
"babel-preset-minify": "^0.5.0",
"benchmark": "^2.1.4",
"browser-env": "^3.2.5",
"decircularize": "^1.0.0",
"eslint": "^5.3.0",
"eslint-config-rapid7": "^3.0.4",
"eslint": "^5.7.0",
"eslint-config-rapid7": "^3.1.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.0",
"eslint-loader": "^2.1.1",
"fast-json-stable-stringify": "^2.0.0",

@@ -49,14 +51,14 @@ "fs-extra": "^7.0.0",

"json-stringify-safe": "^5.0.1",
"nyc": "^12.0.2",
"nyc": "^13.1.0",
"optimize-js-plugin": "^0.0.4",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"rollup": "^0.64.1",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-uglify": "^4.0.0",
"sinon": "^6.1.5",
"webpack": "^4.16.5",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5"
"react": "^16.5.2",
"react-dom": "^16.5.2",
"rollup": "^0.66.6",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-uglify": "^6.0.0",
"sinon": "^7.0.0",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.9"
},

@@ -101,3 +103,3 @@ "homepage": "https://github.com/planttheidea/fast-stringify#readme",

"types": "index.d.ts",
"version": "1.1.0"
"version": "1.1.1"
}

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

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