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

safe-json-value

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safe-json-value - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

14

build/src/to_json.js

@@ -44,3 +44,3 @@ import normalizeException from"normalize-exception";

typeof value.toJSON==="function"&&
!(TO_JSON_RECURSION in value));
!TO_JSON_RECURSION.has(value));

@@ -55,11 +55,10 @@ };

const triggerToJSON=function(value){
value[TO_JSON_RECURSION]=true;
const triggerToJSON=function(object){
TO_JSON_RECURSION.add(object);
try{
return value.toJSON();
return object.toJSON();
}finally{
delete value[TO_JSON_RECURSION];
TO_JSON_RECURSION.delete(object);
}

@@ -69,3 +68,4 @@ };

const TO_JSON_RECURSION=Symbol("toJsonRecursion");
const TO_JSON_RECURSION=new WeakSet([]);
//# sourceMappingURL=to_json.js.map
{
"name": "safe-json-value",
"version": "1.4.1",
"version": "1.4.2",
"type": "module",

@@ -5,0 +5,0 @@ "exports": "./build/src/main.js",

@@ -194,5 +194,5 @@ [![Codecov](https://img.shields.io/codecov/c/github/ehmicky/safe-json-value.svg?label=tested&logo=codecov)](https://codecov.io/gh/ehmicky/safe-json-value)

```js
const input = { toJSON: () => ({ one: true, input: { ...input } }) }
const input = { toJSON: () => ({ one: true, input }) }
JSON.stringify(input) // Throws due to infinite `toJSON()` recursion
JSON.stringify(safeJsonValue(input).value) // '{"one":true,"input":{}}"
JSON.stringify(safeJsonValue(input).value) // '{"one":true,"input":{...}}"
```

@@ -199,0 +199,0 @@

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