New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

json-stable-stringify-pretty

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-stable-stringify-pretty - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

7

index.js

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

var sortarrays = opts.sortarrays === true;
var undef = opts.undef === true;

@@ -36,3 +37,7 @@ var cmp = opts.cmp && (function (f) {

if (node === undefined) {
if (undef) {
return 'undefined';
} else {
return;
}
}

@@ -48,3 +53,3 @@ if (pretty && typeof node === 'string') {

for (var i = 0; i < node.length; i++) {
var item = stringify(node, i, node[i], level+1) || json.stringify(null);
var item = stringify(node, i, node[i], level+1);
out.push(indent + space + item);

@@ -51,0 +56,0 @@ }

2

package.json
{
"name": "json-stable-stringify-pretty",
"version": "1.0.1",
"version": "1.1.0",
"description": "A fork of substack's json-stable-stringify: deterministic JSON.stringify() with useful options",

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

@@ -11,11 +11,15 @@ var test = require('tape');

test('object with undefined', function (t) {
t.plan(1);
t.plan(4);
var obj = { a: 3, z: undefined };
t.equal(stringify(obj), '{"a":3}');
t.equal(stringify(obj, {undef: true}), '{"a":3,"z":undefined}');
t.equal(stringify(obj, {undef: true, pretty: true}), '{a:3,z:undefined}');
t.equal(stringify(obj, {undef: true, pretty: true, space: 2}), '{\n a: 3,\n z: undefined\n}');
});
test('array with undefined', function (t) {
t.plan(1);
t.plan(2);
var obj = [4, undefined, 6];
t.equal(stringify(obj), '[4,null,6]');
t.equal(stringify(obj), '[4,undefined,6]');
t.equal(stringify(obj, {undef: true}), '[4,undefined,6]');
});

@@ -22,0 +26,0 @@

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