Skip to content

Commit 78837ef

Browse files
committed
doc
1 parent 36633f8 commit 78837ef

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

src/Encoder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class Encoder<ContextType = undefined> {
110110
}
111111
} else {
112112
if (object >= -0x20) {
113-
// nagative fixint
113+
// negative fixint
114114
this.writeU8(0xe0 | (object + 0x20));
115115
} else if (object >= -0x80) {
116116
// int 8

src/decode.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,32 @@ export type DecodeOptions<ContextType = undefined> = Readonly<
88

99
/**
1010
* Maximum string length.
11-
* Default to 4_294_967_295 (UINT32_MAX).
11+
*
12+
* Defaults to 4_294_967_295 (UINT32_MAX).
1213
*/
1314
maxStrLength: number;
1415
/**
1516
* Maximum binary length.
16-
* Default to 4_294_967_295 (UINT32_MAX).
17+
*
18+
* Defaults to 4_294_967_295 (UINT32_MAX).
1719
*/
1820
maxBinLength: number;
1921
/**
2022
* Maximum array length.
21-
* Default to 4_294_967_295 (UINT32_MAX).
23+
*
24+
* Defaults to 4_294_967_295 (UINT32_MAX).
2225
*/
2326
maxArrayLength: number;
2427
/**
2528
* Maximum map length.
26-
* Default to 4_294_967_295 (UINT32_MAX).
29+
*
30+
* Defaults to 4_294_967_295 (UINT32_MAX).
2731
*/
2832
maxMapLength: number;
2933
/**
3034
* Maximum extension length.
31-
* Default to 4_294_967_295 (UINT32_MAX).
35+
*
36+
* Defaults to 4_294_967_295 (UINT32_MAX).
3237
*/
3338
maxExtLength: number;
3439
}>

src/encode.ts

+24-4
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,50 @@ import type { ContextOf, SplitUndefined } from "./context";
55
export type EncodeOptions<ContextType = undefined> = Partial<
66
Readonly<{
77
extensionCodec: ExtensionCodecType<ContextType>;
8+
9+
/**
10+
* The maximum depth in nested objects and arrays.
11+
*
12+
* Defaults to 100.
13+
*/
814
maxDepth: number;
15+
16+
/**
17+
* The initial size of the internal buffer.
18+
*
19+
* Defaults to 2048.
20+
*/
921
initialBufferSize: number;
10-
sortKeys: boolean;
1122

23+
/**
24+
* If `true`, the keys of an object is sorted. In other words, the encoded
25+
* binary is canonical and thus comparable to another encoded binary.
26+
*
27+
* Defaults to `false`. If enabled, it spends more time in encoding objects.
28+
*/
29+
sortKeys: boolean;
1230
/**
1331
* If `true`, non-integer numbers are encoded in float32, not in float64 (the default).
1432
*
1533
* Only use it if precisions don't matter.
34+
*
35+
* Defaults to `false`.
1636
*/
1737
forceFloat32: boolean;
1838

1939
/**
2040
* If `true`, an object property with `undefined` value are ignored.
2141
* e.g. `{ foo: undefined }` will be encoded as `{}`, as `JSON.stringify()` does.
2242
*
23-
* The default is `false`. Note that it needs more time to encode.
43+
* Defaults to `false`. If enabled, it spends more time in encoding objects.
2444
*/
2545
ignoreUndefined: boolean;
2646

2747
/**
28-
* If `true`, integer numbers are encoded as floating point,
48+
* If `true`, integer numbers are encoded as floating point numbers,
2949
* with the `forceFloat32` option taken into account.
3050
*
31-
* The default is `false`.
51+
* Defaults to `false`.
3252
*/
3353
forceIntegerToFloat: boolean;
3454
}>

0 commit comments

Comments
 (0)