Kit
Functions

padRightDecoder

padRightDecoder<TDecoder>(decoder, offset): TDecoder

Adds right padding to the given decoder, extending the post-offset by offset bytes whilst increasing the size of the decoder accordingly.

For more details, see padRightCodec.

Type Parameters

Type Parameter
TDecoder extends AnyDecoder

Parameters

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

Returns

TDecoder

A new decoder with right padding applied.

Example

const decoder = padRightDecoder(getU16Decoder(), 2);
const value = decoder.decode(new Uint8Array([0x12, 0x34, 0, 0])); // 0xffff (ignores trailing bytes)

See

On this page