Interfaces
FixedSizeCodec
An object that can encode and decode a value to and from a fixed-size byte array.
See Codec to learn more about creating and composing codecs.
Example
See
Type Parameters
Type Parameter | Default type | Description |
---|---|---|
TFrom | - | The type of the value to encode. |
TTo extends TFrom | TFrom | The type of the decoded value. |
TSize extends number | number | The fixed size of the encoded value in bytes. |
Properties
Property | Modifier | Type | Description |
---|---|---|---|
decode | readonly | (bytes , offset? ) => TTo | Decodes the provided byte array at the given offset (or zero) and returns the value directly. |
encode | readonly | (value ) => ReadonlyUint8Array | Encode the provided value and return the encoded bytes directly. |
fixedSize | readonly | TSize | The fixed size of the encoded value in bytes. |
read | readonly | (bytes , offset ) => [TTo , number ] | Reads the encoded value from the provided byte array at the given offset. Returns the decoded value and the offset of the next byte after the encoded value. |
write | readonly | (value , bytes , offset ) => number | Writes the encoded value into the provided byte array at the given offset. Returns the offset of the next byte after the encoded value. |