Socket
Socket
Sign inDemoInstall

json-cycle

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 1.1.0

23

cycle.js

@@ -20,3 +20,3 @@ 'use strict';

/*property
/*property
$ref, apply, call, decycle, hasOwnProperty, length, prototype, push,

@@ -41,6 +41,7 @@ retrocycle, stringify, test, toString

var _value = value && value.toJSON instanceof Function ? value.toJSON() : value;
// typeof null === 'object', so go on if this value is really an object but not
// one of the weird builtin objects.
if (typeof value === 'object' && value !== null) {
if (typeof _value === 'object' && _value !== null) {

@@ -52,3 +53,3 @@ // If the value is an object or array, look to see if we have already

for (i = 0; i < objects.length; i += 1) {
if (objects[i] === value) {
if (objects[i] === _value) {
return {$ref: paths[i]};

@@ -60,3 +61,3 @@ }

objects.push(value);
objects.push(_value);
paths.push(path);

@@ -66,6 +67,6 @@

if (Object.prototype.toString.apply(value) === '[object Array]') {
if (Object.prototype.toString.apply(_value) === '[object Array]') {
nu = [];
for (i = 0; i < value.length; i += 1) {
nu[i] = derez(value[i], path + '[' + i + ']');
for (i = 0; i < _value.length; i += 1) {
nu[i] = derez(_value[i], path + '[' + i + ']');
}

@@ -77,5 +78,5 @@ } else {

nu = {};
for (name in value) {
if (Object.prototype.hasOwnProperty.call(value, name)) {
nu[name] = derez(value[name],
for (name in _value) {
if (Object.prototype.hasOwnProperty.call(_value, name)) {
nu[name] = derez(_value[name],
path + '[' + JSON.stringify(name) + ']');

@@ -87,3 +88,3 @@ }

}
return value;
return _value;
}(object, '$'));

@@ -90,0 +91,0 @@ },

{
"name": "json-cycle",
"version": "1.0.5",
"version": "1.1.0",
"description": "Encode/decode circular structures for converting to and from JSON.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -45,4 +45,3 @@ # json-cycle

**Note** `decycle` function makes a deep copy of any provided structure while original `decycle` function
from [JSON-js][jsonjs-url] does not make copy for `Boolean`, `Date`, `Number`, `RegExp` and `String` objects.
> Note: `decycle` function makes a deep copy of any provided structure while original `decycle` function from [JSON-js][jsonjs-url] does not make copy for `Boolean`, `Date`, `Number`, `RegExp` and `String` objects.

@@ -59,3 +58,2 @@ Makes a deep copy of an provided structure with resolving all circular references.

```js
jc = require('json-cycle');

@@ -70,3 +68,2 @@ var a = {};

```js
{{"$ref":"$"}}

@@ -98,3 +95,2 @@ ```

```js
jc = require('json-cycle');

@@ -108,3 +104,2 @@ var s = '{{"$ref":"$"}}';

```js
produced object equals to

@@ -111,0 +106,0 @@ var a = {};

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc