Kit
Functions

padLeftDecoder

padLeftDecoder<TDecoder>(decoder, offset): TDecoder

Adds left padding to the given decoder, shifting the decoding position forward by offset bytes whilst increasing the size of the decoder accordingly.

For more details, see padLeftCodec.

Type Parameters

Type Parameter
TDecoder extends AnyDecoder

Parameters

ParameterTypeDescription
decoderTDecoderThe decoder to pad.
offsetnumberThe number of padding bytes to skip before decoding.

Returns

TDecoder

A new decoder with left padding applied.

Example

const decoder = padLeftDecoder(getU16Decoder(), 2);
const value = decoder.decode(new Uint8Array([0, 0, 0x12, 0x34])); // 0xffff (reads from offset 2)

See

On this page