@@ -11,27 +11,23 @@ flowchart LR
11
11
val <--> pures <--> str;
12
12
```
13
13
14
- | Value | Pures | String (JSON Format) |
15
- | ------------------- | -------------------------------------------------------- | ------------------------------------------------------------------ |
16
- | ` 12138 ` | ` [12138] ` | ` [12138] ` |
17
- | ` true ` | ` [true] ` | ` [true] ` |
18
- | ` 16n ` | ` [{T:3,V:"16"}] ` | ` [{"T":3,"V":"16"}] ` |
19
- | ` [80, 'http'] ` | ` [[1,2],80,"http"] ` | ` [[1,2],80,"http"] ` |
20
- | ` Math ` | ` [{T:7,K:"Math"}] ` | ` [{"T":7,"K":"Math"}] ` |
21
- | ` new Set() ` | ` [{T:8,N:"Set",V:1},[]] ` | ` [{"T":8,"N":"Set","V":1},[]] ` |
22
- | ` { name: 'Steve' } ` | ` [{T:6,C:1,P:[["name",2,{}]]},{T:7,K:"Object"},"Steve"] ` | ` [{"T":6,"C":1,"P":[["name",2,{}]]},{"T":7,"K":"Object"},"Steve"] ` |
23
-
24
- - ** Value** - It can be any value, but for some special type of values, you may need to specify some extra information to make it work.
25
- - ** Pures** - It can be directly converted to JSON string, then converted back and remain unchanged.
26
- - ** String** - A string in JSON format.
14
+ | Value | Serialized |
15
+ | ------------------- | -------------------------------------------------------- |
16
+ | ` 12138 ` | ` [12138] ` |
17
+ | ` true ` | ` [true] ` |
18
+ | ` 16n ` | ` [{T:3,V:"16"}] ` |
19
+ | ` [80, 'http'] ` | ` [[1,2],80,"http"] ` |
20
+ | ` Math ` | ` [{T:7,K:"Math"}] ` |
21
+ | ` new Set() ` | ` [{T:8,N:"Set",V:1},[]] ` |
22
+ | ` { name: 'Steve' } ` | ` [{T:6,C:1,P:[["name",2,{}]]},{T:7,K:"Object"},"Steve"] ` |
27
23
28
24
## Features
29
25
30
- - ** Supports built-in types** (e.g., ` Map ` , ` Date ` , ` ArrayBuffer ` , ` Uint8Array ` )
31
- - ** Supports circular references**
32
- - ** Serializable custom class instances**
33
- - ** Deep cloning capability**
34
- - ** Lightweight & dependency-free**
26
+ - ** Supports built-in types** (e.g., ` Map ` , ` Date ` , ` ArrayBuffer ` , ` Uint8Array ` )
27
+ - ** Supports circular references**
28
+ - ** Serializable custom class instances**
29
+ - ** Deep cloning capability**
30
+ - ** Lightweight & dependency-free**
35
31
36
32
## Installation
37
33
@@ -139,31 +135,31 @@ You may have noticed this in previous example about built-in class instance. Som
139
135
140
136
These are supported builtin adapters.
141
137
142
- - ` Number ` ` String ` ` Boolean `
143
- - ` Map ` ` Set `
144
- - ` Date ` ` RegExp ` ` URL ` ` URLSearchParams ` ` URLPattern `
145
- - ` ArrayBuffer ` ` DataView `
146
- - ` Uint8Array ` ` Uint8ClampedArray ` ` Int8Array ` ` Uint16Array ` ` Int16Array ` ` Uint32Array ` ` Int32Array ` ` Float16Array ` ` Float32Array ` ` Float64Array ` ` BigUint64Array ` ` BigInt64Array `
147
- - ` ImageData ` ` ByteLengthQueuingStrategy ` ` Headers `
138
+ - ` Number ` ` String ` ` Boolean `
139
+ - ` Map ` ` Set `
140
+ - ` Date ` ` RegExp ` ` URL ` ` URLSearchParams ` ` URLPattern `
141
+ - ` ArrayBuffer ` ` DataView `
142
+ - ` Uint8Array ` ` Uint8ClampedArray ` ` Int8Array ` ` Uint16Array ` ` Int16Array ` ` Uint32Array ` ` Int32Array ` ` Float16Array ` ` Float32Array ` ` Float64Array ` ` BigUint64Array ` ` BigInt64Array `
143
+ - ` ImageData ` ` ByteLengthQueuingStrategy ` ` Headers `
148
144
149
145
The implementation of those built-in adapters are at ` src/seriall/builtin/adapters.ts ` . You can also implement adapter for your custom Class.
150
146
151
147
## Limitations
152
148
153
- - ** Added properties on special instances** \
154
- Manually added properties to arrays or any class instances with adapters (e.g., ` Map ` , ` Date ` , ` ArrayBuffer ` ) will be ** silently dropped** .\
155
- Example:
149
+ - ** Added properties on special instances** \
150
+ Manually added properties to arrays or any class instances with adapters (e.g., ` Map ` , ` Date ` , ` ArrayBuffer ` ) will be ** silently dropped** .\
151
+ Example:
156
152
157
- ``` ts
158
- const arr = [1 , 2 ];
159
- arr .customProp = ' value' ; // ❌ Won't survive serialization
160
- ```
153
+ ``` ts
154
+ const arr = [1 , 2 ];
155
+ arr .customProp = ' value' ; // ❌ Won't survive serialization
156
+ ```
161
157
162
- - ** No field filtering** \
163
- All string-keyed own properties are serialized by default. Custom selection of serializable fields is not supported.
158
+ - ** No field filtering ** \
159
+ All string - keyed own properties are serialized by default . Custom selection of serializable fields is not supported .
164
160
165
- - ** Symbol-keyed properties** \
166
- Properties with ` Symbol ` keys will be ** ignored** during serialization.
161
+ - ** Symbol - keyed properties ** \
162
+ Properties with ` Symbol ` keys will be ** ignored ** during serialization .
167
163
168
- - ** JavaScript/TypeScript only** \
169
- Currently lacks cross-language support. Serialized data can only be deserialized in JavaScript/TypeScript environments.
164
+ - ** JavaScript / TypeScript only ** \
165
+ Currently lacks cross - language support . Serialized data can only be deserialized in JavaScript / TypeScript environments .
0 commit comments