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
Copy file name to clipboardexpand all lines: README.md
+2-44
Original file line number
Diff line number
Diff line change
@@ -118,51 +118,9 @@ safeDestr("[foo");
118
118
119
119
## Benchmarks
120
120
121
-
Locally try with `pnpm benchmark`. Below are results on Node.js **v20.5.0** with MBA M2.
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.
122
122
123
-
**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.
124
-
125
-
```
126
-
=== Non-string fallback ==
127
-
JSON.parse x 9,506,702 ops/sec ±1.68% (92 runs sampled)
128
-
destr x 159,565,446 ops/sec ±0.24% (98 runs sampled)
129
-
safeDestr x 73,624,106 ops/sec ±0.39% (95 runs sampled)
130
-
sjson:
131
-
@hapi/bourne x 9,404,463 ops/sec ±0.62% (96 runs sampled)
132
-
Fastest is destr
133
-
134
-
=== Known values ==
135
-
JSON.parse x 15,000,474 ops/sec ±0.82% (93 runs sampled)
136
-
destr x 96,977,026 ops/sec ±0.13% (101 runs sampled)
137
-
safeDestr x 47,618,310 ops/sec ±0.15% (98 runs sampled)
138
-
sjson x 11,176,069 ops/sec ±0.47% (93 runs sampled)
139
-
@hapi/bourne x 14,650,782 ops/sec ±0.64% (93 runs sampled)
140
-
Fastest is destr
141
-
142
-
=== plain string ==
143
-
JSON.parse (try-catch) x 11,775,641 ops/sec ±0.64% (95 runs sampled)
144
-
destr x 111,118,106 ops/sec ±0.53% (101 runs sampled)
145
-
safeDestr x 52,455,654 ops/sec ±0.21% (97 runs sampled)
146
-
sjson (try-catch) x 9,282,956 ops/sec ±0.47% (96 runs sampled)
147
-
@hapi/bourne x 11,547,144 ops/sec ±0.68% (96 runs sampled)
148
-
Fastest is destr
149
-
150
-
=== package.json ==
151
-
JSON.parse x 420,496 ops/sec ±0.20% (98 runs sampled)
152
-
destr x 358,257 ops/sec ±0.58% (98 runs sampled)
153
-
safeDestr x 351,278 ops/sec ±1.10% (98 runs sampled)
154
-
sjson x 358,003 ops/sec ±0.14% (102 runs sampled)
155
-
@hapi/bourne x 398,852 ops/sec ±0.32% (99 runs sampled)
156
-
Fastest is JSON.parse
157
-
158
-
=== broken object ==
159
-
JSON.parse (try-catch) x 137,788 ops/sec ±0.68% (98 runs sampled)
160
-
destr x 111,878 ops/sec ±0.50% (98 runs sampled)
161
-
safeDestr:
162
-
sjson (try-catch) x 219,924 ops/sec ±0.62% (98 runs sampled)
0 commit comments