Functions
getConstantEncoder
getConstantEncoder<
TConstant
>(constant
):FixedSizeEncoder
<void
,TConstant
["length"
]>
Returns an encoder that always writes a predefined constant byte sequence.
This encoder ensures that encoding always produces the specified byte array, ignoring any input values.
For more details, see getConstantCodec.
Type Parameters
Type Parameter | Description |
---|---|
TConstant extends ReadonlyUint8Array | The fixed byte sequence that will be written during encoding. |
Parameters
Parameter | Type | Description |
---|---|---|
constant | TConstant | The predefined byte array to encode. |
Returns
FixedSizeEncoder
<void
, TConstant
["length"
]>
A FixedSizeEncoder<void, N>
where N
is the length of the constant.
Example
Encoding a constant magic number.