Comparing version 2.0.1 to 2.0.2
@@ -7,2 +7,2 @@ type Options = { | ||
export { Options, destr as default, destr, safeDestr }; | ||
export { type Options, destr as default, destr, safeDestr }; |
{ | ||
"name": "destr", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "A faster, secure and convenient alternative for JSON.parse", | ||
@@ -23,3 +23,4 @@ "repository": "unjs/destr", | ||
"scripts": { | ||
"bench": "pnpm build && node ./bench.mjs", | ||
"bench:bun": "pnpm build && bun --bun ./bench.mjs", | ||
"bench:node": "pnpm build && node ./bench.mjs", | ||
"build": "unbuild", | ||
@@ -34,14 +35,14 @@ "dev": "vitest dev", | ||
"@hapi/bourne": "^3.0.0", | ||
"@vitest/coverage-v8": "^0.34.1", | ||
"@vitest/coverage-v8": "^0.34.6", | ||
"benchmark": "^2.1.4", | ||
"changelogen": "^0.5.4", | ||
"eslint": "^8.46.0", | ||
"changelogen": "^0.5.5", | ||
"eslint": "^8.52.0", | ||
"eslint-config-unjs": "^0.2.1", | ||
"prettier": "^3.0.0", | ||
"prettier": "^3.0.3", | ||
"secure-json-parse": "^2.7.0", | ||
"typescript": "^5.1.6", | ||
"unbuild": "^1.2.1", | ||
"vitest": "^0.34.1" | ||
"typescript": "^5.2.2", | ||
"unbuild": "^2.0.0", | ||
"vitest": "^0.34.6" | ||
}, | ||
"packageManager": "pnpm@8.6.9" | ||
"packageManager": "pnpm@8.9.2" | ||
} |
@@ -59,3 +59,3 @@ # destr | ||
> 🚀 Up to 500 faster than `JSON.parse`! | ||
> 🚀 Up to 500 times faster than `JSON.parse`! | ||
@@ -122,48 +122,6 @@ ```js | ||
Locally try with `pnpm benchmark`. Below are esults on Node.js **v18.16.0** with MBA M2. | ||
`destr` is sometimes little bit slower than `JSON.parse` when parsing a valid JSON string mainly because of transform to avoid [prototype pollution](https://learn.snyk.io/lessons/prototype-pollution/javascript/) which can lead to serious security issues if not being sanitized. In the other words, `destr` is better when input is not always a JSON string or from untrusted source like request body. | ||
**Note** `destr` is sometimes little bit slower than `JSON.parse` when parsing a valid JSON string mainly because of transform to avoid [prototype pollution](https://learn.snyk.io/lessons/prototype-pollution/javascript/) which can lead to serious security issues if not being sanitized. In the other words, `destr` is better when input is not always a json string or from untrusted source like request body. | ||
Check [Benchmarks](./BENCH.md) | ||
``` | ||
=== Non-string fallback == | ||
JSON.parse x 9,498,532 ops/sec ±0.57% (96 runs sampled) | ||
destr x 153,323,211 ops/sec ±0.13% (99 runs sampled) | ||
safeDestr x 64,237,062 ops/sec ±0.22% (96 runs sampled) | ||
sjson: | ||
@hapi/bourne x 9,190,459 ops/sec ±0.50% (93 runs sampled) | ||
Fastest is destr | ||
=== Known values == | ||
JSON.parse x 14,260,909 ops/sec ±0.54% (95 runs sampled) | ||
destr x 72,916,945 ops/sec ±0.15% (98 runs sampled) | ||
safeDestr x 36,544,906 ops/sec ±0.31% (98 runs sampled) | ||
sjson x 11,157,730 ops/sec ±0.53% (96 runs sampled) | ||
@hapi/bourne x 13,241,853 ops/sec ±0.73% (93 runs sampled) | ||
Fastest is destr | ||
=== plain string == | ||
JSON.parse (try-catch) x 10,603,912 ops/sec ±0.75% (91 runs sampled) | ||
destr x 82,123,481 ops/sec ±2.37% (99 runs sampled) | ||
safeDestr x 40,737,935 ops/sec ±0.97% (96 runs sampled) | ||
sjson (try-catch) x 9,194,305 ops/sec ±1.96% (94 runs sampled) | ||
@hapi/bourne x 10,816,232 ops/sec ±1.59% (90 runs sampled) | ||
Fastest is destr | ||
=== package.json == | ||
JSON.parse x 403,428 ops/sec ±0.31% (101 runs sampled) | ||
destr x 338,668 ops/sec ±0.27% (97 runs sampled) | ||
safeDestr x 335,756 ops/sec ±0.29% (98 runs sampled) | ||
sjson x 355,493 ops/sec ±0.15% (101 runs sampled) | ||
@hapi/bourne x 384,948 ops/sec ±0.24% (98 runs sampled) | ||
Fastest is JSON.parse | ||
=== broken object == | ||
JSON.parse (try-catch) x 406,262 ops/sec ±0.18% (100 runs sampled) | ||
destr x 337,602 ops/sec ±0.37% (99 runs sampled) | ||
safeDestr x 320,071 ops/sec ±0.35% (97 runs sampled) | ||
sjson (try-catch) x 326,689 ops/sec ±0.41% (97 runs sampled) | ||
@hapi/bourne x 313,024 ops/sec ±0.91% (94 runs sampled) | ||
Fastest is JSON.parse (try-catch) | ||
``` | ||
## License | ||
@@ -170,0 +128,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
9
161
11144
139