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.7 to 3.1.8

7

lib/cycle.js

@@ -55,2 +55,9 @@ var pathGetter = require('./path-getter');

}
if (options['nan'] && typeof value === 'number' && isNaN(value)) {
return {$jsan: 'n'}
}
if (options['infinity']) {
if (Number.POSITIVE_INFINITY === value) return {$jsan: 'i'}
if (Number.NEGATIVE_INFINITY === value) return {$jsan: 'y'}
}
if (options['undefined'] && value === undefined) {

@@ -57,0 +64,0 @@ return {$jsan: 'u'}

4

lib/index.js

@@ -25,3 +25,5 @@ var cycle = require('./cycle');

'map': options,
'set': options
'set': options,
'nan': options,
'infinity': options
}

@@ -28,0 +30,0 @@ }

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

return new Set(jsan.parse(rest));
case 'n':
return NaN;
case 'i':
return Infinity;
case 'y':
return -Infinity;
default:

@@ -56,0 +62,0 @@ console.warn('unknown type', obj);

{
"name": "jsan",
"version": "3.1.7",
"version": "3.1.8",
"description": "handle circular references when stringifying and parsing",

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

@@ -53,2 +53,26 @@ var assert = require('assert');

it('can handle NaN', function() {
var obj = {
u: NaN
}
var str = jsan.stringify(obj, null, null, true);
assert.deepEqual(str, '{"u":{"$jsan":"n"}}');
});
it('can handle Infinity', function() {
var obj = {
u: Infinity
}
var str = jsan.stringify(obj, null, null, true);
assert.deepEqual(str, '{"u":{"$jsan":"i"}}');
});
it('can handle -Infinity', function() {
var obj = {
u: -Infinity
}
var str = jsan.stringify(obj, null, null, true);
assert.deepEqual(str, '{"u":{"$jsan":"y"}}');
});
it('can handle errors', function() {

@@ -183,2 +207,20 @@ var obj = {

it('can decode NaN', function() {
str = '{"u":{"$jsan":"n"}}';
var obj = jsan.parse(str);
assert('u' in obj && isNaN(obj.u) && typeof obj.u === 'number');
});
it('can decode Infinity', function() {
str = '{"u":{"$jsan":"i"}}';
var obj = jsan.parse(str);
assert('u' in obj && obj.u === Number.POSITIVE_INFINITY);
});
it('can decode -Infinity', function() {
str = '{"u":{"$jsan":"y"}}';
var obj = jsan.parse(str);
assert('u' in obj && obj.u === Number.NEGATIVE_INFINITY);
});
it('can decode errors', function() {

@@ -185,0 +227,0 @@ str = '{"e":{"$jsan":"e:("}}';

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