Skip to content

Commit d4e2965

Browse files
committed
docs(json-pack): ✏️ add Bencode README
1 parent 5434477 commit d4e2965

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/json-pack/bencode/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Bencode codecs
2+
3+
Implements [Bencode][bencode] encoder and decoder.
4+
5+
[bencode]: https://en.wikipedia.org/wiki/Bencode
6+
7+
Type coercion:
8+
9+
- Strings and `Uint8Array` are encoded as Bencode byte strings, decoded as `Uint8Array`.
10+
- `Object` and `Map` are encoded as Bencode dictionaries, decoded as `Object`.
11+
- `Array` and `Set` are encoded as Bencode lists, decoded as `Array`.
12+
- `number` and `bigint` are encoded as Bencode integers, decoded as `number`.
13+
- Float `number` are rounded and encoded as Bencode integers, decoded as `number`.
14+
15+
16+
## Extensions
17+
18+
This codec extends the Bencode specification to support the following types:
19+
20+
- `null` (encoded as `n`)
21+
- `undefined` (encoded as `u`)
22+
- `boolean` (encoded as `t` for `true` and `f` for `false`)

0 commit comments

Comments
 (0)