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

jsan

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsan - npm Package Compare versions

Comparing version 3.1.9 to 3.1.10

output.js

7

lib/cycle.js

@@ -87,3 +87,8 @@ var pathGetter = require('./path-getter');

if (value && typeof value.toJSON === 'function') {
value = value.toJSON(key);
try {
value = value.toJSON(key);
} catch (error) {
var keyString = (key || '$');
return "toJSON failed for '" + (map.get(value) || keyString) + "'";
}
}

@@ -90,0 +95,0 @@

34

lib/index.js
var cycle = require('./cycle');
exports.stringify = function stringify(value, replacer, space, _options) {
if (arguments.length < 4) {
try {
if (arguments.length === 1) {
return JSON.stringify(value);
} else {
return JSON.stringify.apply(JSON, arguments);
}
} catch (e) {}
}
var options = _options || false;

@@ -32,8 +21,3 @@ if (typeof options === 'boolean') {

var decycled = cycle.decycle(value, options, replacer);
if (arguments.length === 1) {
return JSON.stringify(decycled);
} else {
return JSON.stringify(decycled, replacer, space);
}
return JSON.stringify(decycled);
}

@@ -43,12 +27,10 @@

var needsRetrocycle = /"\$jsan"/.test(text);
var parsed;
if (arguments.length === 1) {
parsed = JSON.parse(text);
} else {
parsed = JSON.parse(text, reviver);
var replaced = JSON.parse(text);
var resolved = cycle.retrocycle(replaced);
if(reviver) {
var temp = JSON.stringify(resolved);
var parsed = JSON.parse(temp, reviver);
return parsed;
}
if (needsRetrocycle) {
parsed = cycle.retrocycle(parsed);
}
return parsed;
return resolved;
}
{
"name": "jsan",
"version": "3.1.9",
"version": "3.1.10",
"description": "handle circular references when stringifying and parsing",

@@ -18,7 +18,8 @@ "main": "index.js",

"circular-json": "^0.3.0",
"immutable": "^3.7.6",
"immutable": "^3.8.2",
"json-stringify-safe": "^5.0.1",
"mobx": "^2.4.1",
"mocha": "^2.2.1",
"rimraf": "^2.5.2"
"rimraf": "^2.5.2",
"remotedev-serialize": "^0.1.1"
},

@@ -25,0 +26,0 @@ "dependencies": {},

@@ -39,3 +39,3 @@ var assert = require('assert');

var obj = {
f: function() {}
f: function () {}
}

@@ -133,3 +133,3 @@ var str = jsan.stringify(obj, null, null, true);

['a', 1],
[{toString: function(){ return 'a' }}, 2],
[{toString: function (){ return 'a' }}, 2],
[{}, 3]

@@ -146,3 +146,3 @@ ])

var obj = {
set: new Set(['a', {toString: function(){ return 'a' }}, {}])
set: new Set(['a', {toString: function (){ return 'a' }}, {}])
}

@@ -149,0 +149,0 @@ var str = jsan.stringify(obj, null, null, true);

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