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.12 to 3.1.13

17

lib/cycle.js

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

var hasCircular = Object.prototype.hasOwnProperty.call(options, 'circular');
var noCircularOption = !Object.prototype.hasOwnProperty.call(options, 'circular');
var withRefs = options.refs !== false;

@@ -108,11 +109,17 @@ return (function derez(_value, path, key) {

if (typeof value === 'object' && options['refs']) {
if (typeof value === 'object') {
var foundPath = map.get(value);
if (foundPath) {
if (hasCircular && path.indexOf(foundPath) === 0) {
return typeof options.circular === 'function'?
if (noCircularOption && withRefs) {
return {$jsan: foundPath};
}
if (path.indexOf(foundPath) === 0) {
if (!noCircularOption) {
return typeof options.circular === 'function'?
options.circular(value, path, foundPath):
options.circular;
}
return {$jsan: foundPath};
}
return {$jsan: foundPath};
if (withRefs) return {$jsan: foundPath};
}

@@ -119,0 +126,0 @@ map.set(value, path);

@@ -30,3 +30,2 @@ var cycle = require('./cycle');

}
if (typeof options.refs === 'undefined') options.refs = true;

@@ -33,0 +32,0 @@ var decycled = cycle.decycle(value, options, replacer);

{
"name": "jsan",
"version": "3.1.12",
"version": "3.1.13",
"description": "handle circular references when stringifying and parsing",

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

@@ -202,2 +202,12 @@ var assert = require('assert');

it('works with refs option with circular references', function() {
var obj = {};
obj.self = obj;
obj.a = 1;
obj.b = {t: 1};
obj.c = obj.b;
assert.equal(jsan.stringify(obj, null, null, {refs: false}), '{"self":{"$jsan":"$"},"a":1,"b":{"t":1},"c":{"t":1}}');
assert.equal(jsan.stringify(obj, null, null, {refs: false, circular: 'Circular'}), '{"self":"Circular","a":1,"b":{"t":1},"c":{"t":1}}');
});
it('works on objects with "[", "\'", and "]" in the keys', function() {

@@ -204,0 +214,0 @@ var obj = {};

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