Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-stable-stringify

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-stable-stringify - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

test/space.js

18

index.js

@@ -6,2 +6,4 @@ var json = typeof JSON !== 'undefined' ? JSON : require('jsonify');

if (typeof opts === 'function') opts = { cmp: opts };
var space = opts.space || '';
if (typeof space === 'number') space = Array(space+1).join(' ');
var cmp = opts.cmp && (function (f) {

@@ -17,3 +19,5 @@ return function (node) {

return (function stringify (node) {
return (function stringify (node, level) {
var indent = space ? ('\n' + new Array(level + 1).join(space)) : '';
var colonSeparator = space ? ': ' : ':';
if (typeof node !== 'object' || node === null) {

@@ -25,5 +29,6 @@ return json.stringify(node);

for (var i = 0; i < node.length; i++) {
out.push(stringify(node[i]));
var item = stringify(node[i], level+1);
out.push(indent + space + item);
}
return '[' + out.join(',') + ']';
return '[' + out.join(',') + indent + ']';
}

@@ -35,7 +40,8 @@ else {

var key = keys[i];
out.push(stringify(key) + ':' + stringify(node[key]));
var keyValue = stringify(key,0) + colonSeparator + stringify(node[key],level+1);
out.push(indent + space + keyValue);
}
return '{' + out.join(',') + '}';
return '{' + out.join(',') + indent + '}';
}
})(obj);
})(obj, 0);
};

@@ -42,0 +48,0 @@

{
"name": "json-stable-stringify",
"version": "0.0.1",
"version": "0.1.0",
"description": "deterministic JSON.stringify() with custom sorting to get deterministic hashes from stringified results",

@@ -5,0 +5,0 @@ "main": "index.js",

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