Kit
Functions

padRightEncoder

padRightEncoder<TEncoder>(encoder, offset): TEncoder

Adds right padding to the given encoder, extending the encoded value by offset bytes whilst increasing the size of the encoder accordingly.

For more details, see padRightCodec.

Type Parameters

Type Parameter
TEncoder extends AnyEncoder

Parameters

ParameterTypeDescription
encoderTEncoderThe encoder to pad.
offsetnumberThe number of padding bytes to add after encoding.

Returns

TEncoder

A new encoder with right padding applied.

Example

const encoder = padRightEncoder(getU16Encoder(), 2);
const bytes = encoder.encode(0xffff); // 0xffff0000 (two extra bytes added at the end)

See

On this page