Skip to content

Commit 60b3f81

Browse files
committedJun 12, 2023
chore: update readme
1 parent ecf2029 commit 60b3f81

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed
 

‎README.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,20 @@ console.log(destr('{ "deno": "yay" }'));
4444

4545
## Why?
4646

47-
### ✅Type Safe
47+
### Type Safe
4848

49-
```js
50-
const obj = JSON.parse("..."); // obj type is any
49+
```ts
50+
const obj = JSON.parse("{}"); // obj type is any
5151

52-
const obj = destr("..."); // obj type is unknown by default
52+
const obj = destr("{}"); // obj type is unknown by default
5353

54-
const obj = destr < MyInterface > "..."; // obj is well-typed
54+
const obj = destr<MyInterface>("{}"); // obj is well-typed
5555
```
5656

5757
### ✅ Fast fallback to input if is not string
5858

59+
> 🚀 Up to 500 faster than `JSON.parse`!
60+
5961
```js
6062
// Uncaught SyntaxError: Unexpected token u in JSON at position 0
6163
JSON.parse();
@@ -66,6 +68,8 @@ destr();
6668

6769
### ✅ Fast lookup for known string values
6870

71+
> 🚀 Up to 900 times faster than `JSON.parse`!
72+
6973
```js
7074
// Uncaught SyntaxError: Unexpected token T in JSON at position 0
7175
JSON.parse("TRUE");
@@ -76,6 +80,8 @@ destr("TRUE");
7680

7781
### ✅ Fallback to original value if parse fails (empty or any plain string)
7882

83+
> 🚀 Up to 900 times faster than `JSON.parse`!
84+
7985
```js
8086
// Uncaught SyntaxError: Unexpected token s in JSON at position 0
8187
JSON.parse("salam");
@@ -84,6 +90,8 @@ JSON.parse("salam");
8490
destr("salam");
8591
```
8692

93+
**Note:** This fails in safe/strict mode with `safeDestr`.
94+
8795
### ✅ Avoid prototype pollution
8896

8997
```js

0 commit comments

Comments
 (0)
Please sign in to comment.