mirror of
https://github.com/voson-wang/toon.git
synced 2026-01-29 15:24:10 +08:00
docs: update decode example
This commit is contained in:
14
README.md
14
README.md
@@ -844,9 +844,11 @@ A JavaScript value (object, array, or primitive) representing the parsed TOON da
|
|||||||
```ts
|
```ts
|
||||||
import { decode } from '@byjohann/toon'
|
import { decode } from '@byjohann/toon'
|
||||||
|
|
||||||
const toon = `items[2]{sku,qty,price}:
|
const toon = `
|
||||||
|
items[2]{sku,qty,price}:
|
||||||
A1,2,9.99
|
A1,2,9.99
|
||||||
B2,1,14.5`
|
B2,1,14.5
|
||||||
|
`
|
||||||
|
|
||||||
const data = decode(toon)
|
const data = decode(toon)
|
||||||
// {
|
// {
|
||||||
@@ -861,10 +863,10 @@ const data = decode(toon)
|
|||||||
|
|
||||||
By default, the decoder validates input strictly:
|
By default, the decoder validates input strictly:
|
||||||
|
|
||||||
- **Invalid escape sequences** – Throws on `"\x"`, unterminated strings
|
- **Invalid escape sequences**: Throws on `"\x"`, unterminated strings.
|
||||||
- **Syntax errors** – Throws on missing colons, malformed headers
|
- **Syntax errors**: Throws on missing colons, malformed headers.
|
||||||
- **Array length mismatches** – Throws when declared length doesn't match actual count
|
- **Array length mismatches**: Throws when declared length doesn't match actual count.
|
||||||
- **Delimiter mismatches** – Throws when row delimiters don't match header
|
- **Delimiter mismatches**: Throws when row delimiters don't match header.
|
||||||
|
|
||||||
## Notes and Limitations
|
## Notes and Limitations
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user