offsetDecoder
offsetDecoder<
TDecoder
>(decoder
,config
):TDecoder
Moves the offset of a given decoder before and/or after decoding.
This function allows a decoder to read its input from a different offset than the one originally provided. It supports both pre-offset adjustments (before decoding) and post-offset adjustments (after decoding).
The pre-offset function determines where decoding should start, while the post-offset function adjusts where the next decoder should continue reading.
For more details, see offsetCodec.
Type Parameters
Type Parameter |
---|
TDecoder extends AnyDecoder |
Parameters
Parameter | Type | Description |
---|---|---|
decoder | TDecoder | The decoder to adjust. |
config | OffsetConfig | An object specifying how the offset should be modified. |
Returns
TDecoder
A new decoder with adjusted offsets.
Examples
Moving the pre-offset forward by 2 bytes.
Moving the post-offset forward by 2 bytes.
Using wrapBytes
to read from the last 4 bytes of an array.
Remarks
If you need both encoding and decoding offsets to be adjusted, use offsetCodec.