Kit
Interfaces

FixedSizeDecoder

An object that can decode a fixed-size byte array into a value of type TTo.

See Decoder to learn more about creating and composing decoders.

Example

const decoder: FixedSizeDecoder<number, 4>;
const value = decoder.decode(bytes);
const size = decoder.fixedSize; // 4

See

Type Parameters

Type ParameterDefault typeDescription
TTo-The type of the decoded value.
TSize extends numbernumberThe fixed size of the encoded value in bytes.

Properties

PropertyModifierTypeDescription
decodereadonly(bytes, offset?) => TToDecodes the provided byte array at the given offset (or zero) and returns the value directly.
fixedSizereadonlyTSizeThe fixed size of the encoded value in bytes.
readreadonly(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.

On this page