addCodecSentinel
Call Signature
Creates a Codec that writes a given Uint8Array sentinel after the encoded
value and, when decoding, continues reading until the sentinel is found.
This sets a limit on variable-size codecs and tells us when to stop decoding.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the value to encode. |
TTo | The type of the decoded value. |
Parameters
| Parameter | Type |
|---|---|
codec | FixedSizeCodec<TFrom, TTo> |
sentinel | ReadonlyUint8Array |
Returns
FixedSizeCodec<TFrom, TTo>
Example
Remarks
Note that the sentinel must not be present in the encoded data and must be present in the decoded data for this to work. If this is not the case, dedicated errors will be thrown.
Separate addEncoderSentinel and addDecoderSentinel functions are also available.
See
Call Signature
Creates a Codec that writes a given Uint8Array sentinel after the encoded
value and, when decoding, continues reading until the sentinel is found.
This sets a limit on variable-size codecs and tells us when to stop decoding.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the value to encode. |
TTo | The type of the decoded value. |
Parameters
| Parameter | Type |
|---|---|
codec | Codec<TFrom, TTo> |
sentinel | ReadonlyUint8Array |
Returns
VariableSizeCodec<TFrom, TTo>
Example
Remarks
Note that the sentinel must not be present in the encoded data and must be present in the decoded data for this to work. If this is not the case, dedicated errors will be thrown.
Separate addEncoderSentinel and addDecoderSentinel functions are also available.