Functions
fixDecoderSize
fixDecoderSize<
TTo
,TSize
>(decoder
,fixedBytes
):FixedSizeDecoder
<TTo
,TSize
>
Creates a fixed-size decoder from a given decoder.
The resulting decoder always reads exactly fixedBytes
bytes from the input.
If the nested decoder is also fixed-size, the bytes are truncated or padded as needed.
For more details, see fixCodecSize.
Type Parameters
Type Parameter | Description |
---|---|
TTo | The type of the decoded value. |
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
Parameter | Type | Description |
---|---|---|
decoder | Decoder <TTo > | The decoder to wrap into a fixed-size decoder. |
fixedBytes | TSize | The fixed number of bytes to read. |
Returns
FixedSizeDecoder
<TTo
, TSize
>
A FixedSizeDecoder
that ensures a consistent input size.
Example
Remarks
If you need a full codec with both encoding and decoding, use fixCodecSize.