Kit
Functions

getU16Decoder

getU16Decoder(config): FixedSizeDecoder<number, 2>

Returns a decoder for 16-bit unsigned integers (u16).

This decoder deserializes u16 values from two bytes in little-endian format by default. You may specify big-endian storage using the endian option.

For more details, see getU16Codec.

Parameters

ParameterTypeDescription
configNumberCodecConfigOptional settings for endianness.

Returns

FixedSizeDecoder<number, 2>

A FixedSizeDecoder<number, 2> for decoding u16 values.

Example

Decoding a u16 value.

const decoder = getU16Decoder();
const value = decoder.decode(new Uint8Array([0x2a, 0x00])); // 42

See

getU16Codec

On this page