Skip to content

Commit e2c026c

Browse files
committed
Update README
1 parent 254d12e commit e2c026c

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

README.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# teleport-javascript
22

3-
A super light (0.9K) and fast JavaScript object (de)serialization that includes undefined, bigint, regex, etc.",
3+
A super light and fast JavaScript object (de)serialization that includes undefined, bigint, regex, etc.",
44

55
### Installation
66
```console
@@ -15,23 +15,27 @@ import {parse, stringify} from 'teleport-javascript/esm';
1515
// CJS
1616
const {parse, stringify} = require('teleport-javascript/cjs');
1717

18-
const a = [{}];
19-
a[0].a = a;
20-
a.push(a);
21-
a[0].b = new Map([[Symbol('s'), new Set([1, /a-z/, -Infinity])]]);
22-
a[0].c = undefined;
18+
const obj = {
19+
key: 'value',
20+
undefined: undefined,
21+
regex: /a-z/gi,
22+
set: new Set([-Infinity, NaN, Infinity]),
23+
bigint: 900719925474099123n
24+
};
25+
obj.circular = obj;
2326

24-
const stringified = stringify(a);
25-
// '[["1","0"],{"a":"0","b":"_0","c":"_1"},["M;[[\\"1\\"],[\\"_0\\",\\"_1\\"],[\\"s;s\\",\\"S;[[1,\\\\\\"_0\\\\\\",\\\\\\"_1\\\\\\"],[\\\\\\"R;/a-z/\\\\\\",\\\\\\"n;-Infinity\\\\\\"]]\\"]]","u"]]'
27+
const stringified = stringify(obj);
28+
// '[{"key":"1","undefined":"_0","regex":"_1","set":"_2","bigint":"_3","circular":"0"},"value",["u","R;/a-z/gi","S;[[\\"_0\\",\\"_1\\",\\"_2\\"],[\\"n;-Infinity\\",\\"n;NaN\\",\\"n;Infinity\\"]]","b;900719925474099123"]]'
2629

2730
const parsed = parse(stringified);
28-
// [
29-
// {
30-
// a: [ [Circular], [Circular] ],
31-
// b: Map { Symbol(s) => Set { 1, /a-z/, -Infinity } },
32-
// c: undefined
33-
// }
34-
// ]
31+
// {
32+
// key: 'value',
33+
// undefined: undefined,
34+
// regex: /a-z/gi,
35+
// set: Set { -Infinity, NaN, Infinity },
36+
// bigint: 900719925474099123n,
37+
// circular: [Circular]
38+
// }
3539
```
3640

3741
### Supported Data Types
@@ -42,6 +46,15 @@ const parsed = parse(stringified);
4246
* Null
4347
* Undefined
4448
* Array
49+
- Int8Array
50+
- Uint8Array
51+
- Uint8ClampedArray
52+
- Int16Array
53+
- Uint16Array
54+
- Int32Array
55+
- Uint32Array
56+
- Float32Array
57+
- Float64Array
4558
* Symbol
4659
* Object _(including circular reference)_
4760
- RegExp

0 commit comments

Comments
 (0)