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

json-dry

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-dry - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 2.0.3 (2024-08-12)
* Fix placeholders not being replaced in certain circular circumstances
## 2.0.2 (2023-10-05)

@@ -2,0 +6,0 @@

@@ -236,3 +236,3 @@ "use strict";

* @since 2.0.0
* @version 2.0.0
* @version 2.0.3
*

@@ -258,3 +258,15 @@ * @param {Object} original_holder The object that holds the value

result = this.createReviverValueWrapper(original_holder, key, value, parent);
result = result.undriedValue(new_holder, key);
if (result && result instanceof Placeholder) {
if (result.done) {
result = result.result;
} else {
result.waiters.push({
holder: new_holder,
key : key,
});
}
}
}

@@ -862,2 +874,19 @@ } else {

/**
* Represent a value that will be replaced later
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 2.0.3
* @version 2.0.3
*/
class Placeholder {
constructor(holder, key) {
this.holder = holder;
this.key = key;
this.result = undefined;
this.done = false;
this.waiters = [];
}
}
/**
* Represent a value that needs reviving using registered undriers

@@ -868,3 +897,3 @@ * (Only used during undrying)

* @since 2.0.0
* @version 2.0.1
* @version 2.0.3
*/

@@ -881,5 +910,5 @@ class UndrierValue extends Value {

let placeholder = Symbol();
let placeholder = new Placeholder(holder, key);
this.placeholders.push([holder, key, placeholder]);
this.placeholders.push(placeholder);

@@ -903,3 +932,2 @@ return placeholder;

holder,
entry,
key;

@@ -909,8 +937,8 @@

entry = this.placeholders.shift();
placeholder = this.placeholders.shift();
placeholder.done = true;
placeholder.result = result;
holder = placeholder.holder;
key = placeholder.key;
holder = entry[0];
key = entry[1];
placeholder = entry[2];
holder[key] = result;

@@ -934,2 +962,21 @@

}
if (placeholder.waiters.length) {
while (placeholder.waiters.length) {
let waiter = placeholder.waiters.shift();
let holder = waiter.holder;
let recursive = 0;
while (holder && holder.$replaced) {
holder = holder.$replaced;
recursive++;
if (recursive > 10) {
break;
}
}
holder[waiter.key] = result;
}
}
}

@@ -936,0 +983,0 @@ }

2

package.json
{
"name": "json-dry",
"description": "Don't repeat yourself, JSON: Add support for (circular) references, class instances, ...",
"version": "2.0.2",
"version": "2.0.3",
"author": "Jelle De Loecker <jelle@elevenways.be>",

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

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