Functions
getConstantDecoder
getConstantDecoder<
TConstant
>(constant
):FixedSizeDecoder
<void
,TConstant
["length"
]>
Returns a decoder that verifies a predefined constant byte sequence.
This decoder reads the next bytes and checks that they match the provided constant. If the bytes differ, it throws an error.
For more details, see getConstantCodec.
Type Parameters
Type Parameter | Description |
---|---|
TConstant extends ReadonlyUint8Array | The fixed byte sequence expected during decoding. |
Parameters
Parameter | Type | Description |
---|---|---|
constant | TConstant | The predefined byte array to verify. |
Returns
FixedSizeDecoder
<void
, TConstant
["length"
]>
A FixedSizeDecoder<void, N>
where N
is the length of the constant.
Example
Decoding a constant magic number.