Skip to content

Commit 1604610

Browse files
committed
update README
1 parent ffc179a commit 1604610

File tree

2 files changed

+35
-40
lines changed

2 files changed

+35
-40
lines changed

README.md

+33-37
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,23 @@ flowchart LR
1111
val <--> pures <--> str;
1212
```
1313

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"]` |
2723

2824
## Features
2925

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**
3531

3632
## Installation
3733

@@ -139,31 +135,31 @@ You may have noticed this in previous example about built-in class instance. Som
139135

140136
These are supported builtin adapters.
141137

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`
148144

149145
The implementation of those built-in adapters are at `src/seriall/builtin/adapters.ts`. You can also implement adapter for your custom Class.
150146

151147
## Limitations
152148

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:
156152

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+
```
161157

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.
164160

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.
167163

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.

test/tutorial.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { assert } from '@std/assert/assert';
44
import * as seriall from '@/mod.ts';
55

66
Deno.test(function examples() {
7-
console.log(`| Value | Pures | String (JSON Format) |`);
8-
console.log(`|-|-|-|`);
7+
console.log(`| Value | Serialized |`);
8+
console.log(`|-|-|`);
99
Object.entries({
1010
'true': true,
1111
'12138': 12138,
@@ -18,7 +18,6 @@ Deno.test(function examples() {
1818
[
1919
key,
2020
seriall.stringify(value).replace(/"(\w)":/g, '$1:'),
21-
seriall.stringify(value),
2221
].map((s) => '`' + s + '`')
2322
).map((s) => console.log('|', s.join(' | '), '|'));
2423
});

0 commit comments

Comments
 (0)