getHiddenPrefixCodec
Call Signature
getHiddenPrefixCodec<
TFrom
,TTo
>(codec
,prefixedCodecs
):FixedSizeCodec
<TFrom
,TTo
>
Returns a codec that encodes and decodes values with a hidden prefix.
- Encoding: Prefixes the value with hidden data before encoding.
- Decoding: Skips the hidden prefix before decoding the main value.
This is useful for any implicit metadata that should be present in binary formats but omitted from the API.
Type Parameters
Type Parameter | Description |
---|---|
TFrom | The type of the main value being encoded. |
TTo | The type of the main value being decoded. |
Parameters
Parameter | Type | Description |
---|---|---|
codec | FixedSizeCodec <TFrom , TTo > | The codec for the main value. |
prefixedCodecs | readonly FixedSizeCodec <void >[] | A list of void codecs that produce the hidden prefix. |
Returns
FixedSizeCodec
<TFrom
, TTo
>
A FixedSizeCodec
or VariableSizeCodec
for encoding and decoding values with a hidden prefix.
Example
Encoding and decoding a value with prefixed constants.
Remarks
If all you need is padding zeroes before a value, consider using padLeftCodec instead.
Separate getHiddenPrefixEncoder and getHiddenPrefixDecoder functions are available.
See
Call Signature
getHiddenPrefixCodec<
TFrom
,TTo
>(codec
,prefixedCodecs
):VariableSizeCodec
<TFrom
,TTo
>
Returns a codec that encodes and decodes values with a hidden prefix.
- Encoding: Prefixes the value with hidden data before encoding.
- Decoding: Skips the hidden prefix before decoding the main value.
This is useful for any implicit metadata that should be present in binary formats but omitted from the API.
Type Parameters
Type Parameter | Description |
---|---|
TFrom | The type of the main value being encoded. |
TTo | The type of the main value being decoded. |
Parameters
Parameter | Type | Description |
---|---|---|
codec | Codec <TFrom , TTo > | The codec for the main value. |
prefixedCodecs | readonly Codec <void >[] | A list of void codecs that produce the hidden prefix. |
Returns
VariableSizeCodec
<TFrom
, TTo
>
A FixedSizeCodec
or VariableSizeCodec
for encoding and decoding values with a hidden prefix.
Example
Encoding and decoding a value with prefixed constants.
Remarks
If all you need is padding zeroes before a value, consider using padLeftCodec instead.
Separate getHiddenPrefixEncoder and getHiddenPrefixDecoder functions are available.