Comparing version 4.0.1 to 4.1.0
{ | ||
"name": "devalue", | ||
"description": "Gets the job done when JSON.stringify can't", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"repository": "Rich-Harris/devalue", | ||
"exports": { | ||
".": { | ||
"types": "./types/index.d.ts", | ||
"import": "./index.js", | ||
"types": "./types/index.d.ts" | ||
"default": "./index.js" | ||
} | ||
@@ -11,0 +12,0 @@ }, |
@@ -157,2 +157,3 @@ # devalue | ||
- [arson](https://github.com/benjamn/arson) by Ben Newman. The `stringify`/`parse` approach in `devalue` was inspired by `arson` | ||
- [oson](https://github.com/KnorpelSenf/oson) by Steffen Trog | ||
- [tosource](https://github.com/marcello3d/node-tosource) by Marcello Bastéa-Forte | ||
@@ -159,0 +160,0 @@ - [serialize-javascript](https://github.com/yahoo/serialize-javascript) by Eric Ferraiuolo |
@@ -17,9 +17,14 @@ import { | ||
if (typeof parsed === 'number') return hydrate(parsed); | ||
if (typeof parsed === 'number') return hydrate(parsed, true); | ||
if (!Array.isArray(parsed) || parsed.length === 0) { | ||
throw new Error('Invalid input'); | ||
} | ||
const values = /** @type {any[]} */ (parsed); | ||
const hydrated = Array(values.length); | ||
/** @param {number} index */ | ||
function hydrate(index) { | ||
function hydrate(index, standalone = false) { | ||
if (index === UNDEFINED) return undefined; | ||
@@ -31,2 +36,4 @@ if (index === NAN) return NaN; | ||
if (standalone) throw new Error(`Invalid input`); | ||
if (index in hydrated) return hydrated[index]; | ||
@@ -33,0 +40,0 @@ |
@@ -33,10 +33,10 @@ import { | ||
if (counts.has(thing)) { | ||
counts.set(thing, counts.get(thing) + 1); | ||
return; | ||
} | ||
if (!is_primitive(thing)) { | ||
if (counts.has(thing)) { | ||
counts.set(thing, counts.get(thing) + 1); | ||
return; | ||
} | ||
counts.set(thing, 1); | ||
counts.set(thing, 1); | ||
if (!is_primitive(thing)) { | ||
const type = get_type(thing); | ||
@@ -43,0 +43,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22907
614
166