reverseEncoder
Reverses the bytes of a fixed-size encoder.
Given a FixedSizeEncoder, this function returns a new FixedSizeEncoder that
reverses the bytes within the fixed-size byte array when encoding.
This can be useful to modify endianness or for other byte-order transformations.
For more details, see reverseCodec.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the value to encode. |
TSize extends number | The fixed size of the encoded value in bytes. |
Parameters
| Parameter | Type | Description |
|---|---|---|
encoder | FixedSizeEncoder<TFrom, TSize> | The fixed-size encoder to reverse. |
Returns
FixedSizeEncoder<TFrom, TSize>
A new encoder that writes bytes in reverse order.
Example
Encoding a u16 value in reverse order.