1 | /**
|
2 | * @group TLV8
|
3 | */
|
4 | export type TLVEncodable = Buffer | number | string;
|
5 | /**
|
6 | * @group TLV8
|
7 | */
|
8 | export declare function encode(type: number, data: TLVEncodable | TLVEncodable[], ...args: any[]): Buffer;
|
9 | /**
|
10 | * This method is the legacy way of decoding tlv data.
|
11 | * It will not properly decode multiple list of the same id.
|
12 | * Should the decoder encounter multiple instances of the same id, it will just concatenate the buffer data.
|
13 | *
|
14 | * @param buffer - TLV8 data
|
15 | *
|
16 | * Note: Please use {@link decodeWithLists} which properly decodes list elements.
|
17 | *
|
18 | * @group TLV8
|
19 | */
|
20 | export declare function decode(buffer: Buffer): Record<number, Buffer>;
|
21 | /**
|
22 | * Decode a buffer coding TLV8 encoded entries.
|
23 | *
|
24 | * This method decodes multiple entries split by a TLV delimiter properly into Buffer arrays.
|
25 | * It properly reassembles tlv entries if they were split across multiple entries due to exceeding the max tlv entry size of 255 bytes.
|
26 | * @param buffer - The Buffer containing TLV8 encoded data.
|
27 | *
|
28 | * @group TLV8
|
29 | */
|
30 | export declare function decodeWithLists(buffer: Buffer): Record<number, Buffer | Buffer[]>;
|
31 | /**
|
32 | * This method can be used to parse a TLV8 encoded list that was concatenated.
|
33 | *
|
34 | * If you are thinking about using this method, try to refactor the code to use {@link decodeWithLists} instead of {@link decode}.
|
35 | * The single reason of this method's existence are the shortcomings {@link decode}, as it concatenates multiple tlv8 list entries
|
36 | * into a single Buffer.
|
37 | * This method can be used to undo that, by specifying the concatenated buffer and the tlv id of the element that should
|
38 | * mark the beginning of a new tlv8 list entry.
|
39 | *
|
40 | * @param data - The concatenated tlv8 list entries (probably output of {@link decode}).
|
41 | * @param entryStartId - The tlv id that marks the beginning of a new tlv8 entry.
|
42 | *
|
43 | * @group TLV8
|
44 | */
|
45 | export declare function decodeList(data: Buffer, entryStartId: number): Record<number, Buffer>[];
|
46 | /**
|
47 | * @group TLV8
|
48 | */
|
49 | export declare function readUInt64LE(buffer: Buffer, offset?: number): number;
|
50 | /**
|
51 | * `writeUint32LE`
|
52 | * @group TLV8
|
53 | */
|
54 | export declare function writeUInt32(value: number): Buffer;
|
55 | /**
|
56 | * `readUInt32LE`
|
57 | * @group TLV8
|
58 | */
|
59 | export declare function readUInt32(buffer: Buffer): number;
|
60 | /**
|
61 | * @group TLV8
|
62 | */
|
63 | export declare function writeFloat32LE(value: number): Buffer;
|
64 | /**
|
65 | * `writeUInt16LE`
|
66 | * @group TLV8
|
67 | */
|
68 | export declare function writeUInt16(value: number): Buffer;
|
69 | /**
|
70 | * `readUInt16LE`
|
71 | * @group TLV8
|
72 | */
|
73 | export declare function readUInt16(buffer: Buffer): number;
|
74 | /**
|
75 | * Reads variable size unsigned integer {@link writeVariableUIntLE}.
|
76 | * @param buffer - The buffer to read from. It must have exactly the size of the given integer.
|
77 | * @group TLV8
|
78 | */
|
79 | export declare function readVariableUIntLE(buffer: Buffer): number;
|
80 | /**
|
81 | * Writes variable size unsigned integer.
|
82 | * Either:
|
83 | * - `UInt8`
|
84 | * - `UInt16LE`
|
85 | * - `UInt32LE`
|
86 | * @param number
|
87 | * @group TLV8
|
88 | */
|
89 | export declare function writeVariableUIntLE(number: number): Buffer;
|
90 | //# sourceMappingURL=tlv.d.ts.map |
\ | No newline at end of file |