You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Uncaught SyntaxError: Unexpected token u in JSON at position 0
63
61
JSON.parse();
@@ -68,8 +66,6 @@ destr();
68
66
69
67
### ✅ Fast lookup for known string values
70
68
71
-
> 🚀 Up to 900 times faster than `JSON.parse`!
72
-
73
69
```js
74
70
// Uncaught SyntaxError: Unexpected token T in JSON at position 0
75
71
JSON.parse("TRUE");
@@ -80,8 +76,6 @@ destr("TRUE");
80
76
81
77
### ✅ Fallback to original value if parse fails (empty or any plain string)
82
78
83
-
> 🚀 Up to 900 times faster than `JSON.parse`!
84
-
85
79
```js
86
80
// Uncaught SyntaxError: Unexpected token s in JSON at position 0
87
81
JSON.parse("salam");
@@ -118,9 +112,9 @@ safeDestr("[foo");
118
112
119
113
## Benchmarks
120
114
121
-
`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.
115
+
`destr` is faster generally for arbitrary inputs but also 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.
122
116
123
-
Check [Benchmarks](./BENCH.md)
117
+
Check [Benchmark Results](./BENCH.md) or run with `pnpm run bench:node` or `pnpm run bench:bun` yourself!
0 commit comments