Functions
padLeftCodec
padLeftCodec<
TCodec
>(codec
,offset
):TCodec
Adds left padding to the given codec, shifting the encoding and decoding positions
forward by offset
bytes whilst increasing the size of the codec accordingly.
This ensures that values are read and written at a later position in the byte array, while the padding bytes remain unused.
Type Parameters
Type Parameter |
---|
TCodec extends AnyCodec |
Parameters
Parameter | Type | Description |
---|---|---|
codec | TCodec | The codec to pad. |
offset | number | The number of padding bytes to add before encoding and decoding. |
Returns
TCodec
A new codec with left padding applied.
Example
Remarks
If you only need to apply padding for encoding, use padLeftEncoder. If you only need to apply padding for decoding, use padLeftDecoder.