transformDecoder
Call Signature
transformDecoder<
TOldTo
,TNewTo
,TSize
>(decoder
,map
):FixedSizeDecoder
<TNewTo
,TSize
>
Transforms a decoder by mapping its output values.
This function takes an existing Decoder<A>
and returns a Decoder<B>
, allowing values of type A
to be converted into values of type B
after decoding. The transformation is applied via the map
function.
This is useful for post-processing, type conversions, or enriching decoded data.
For more details, see transformCodec.
Type Parameters
Type Parameter | Description |
---|---|
TOldTo | The original type returned by the decoder. |
TNewTo | The new type that will be transformed after decoding. |
TSize extends number | - |
Parameters
Parameter | Type | Description |
---|---|---|
decoder | FixedSizeDecoder <TOldTo , TSize > | The decoder to transform. |
map | (value , bytes , offset ) => TNewTo | A function that converts values of TOldTo into TNewTo after decoding. |
Returns
FixedSizeDecoder
<TNewTo
, TSize
>
A new decoder that decodes into TNewTo
.
Example
Decoding a stored u32
length into a string of 'x'
characters.
See
Call Signature
transformDecoder<
TOldTo
,TNewTo
>(decoder
,map
):VariableSizeDecoder
<TNewTo
>
Transforms a decoder by mapping its output values.
This function takes an existing Decoder<A>
and returns a Decoder<B>
, allowing values of type A
to be converted into values of type B
after decoding. The transformation is applied via the map
function.
This is useful for post-processing, type conversions, or enriching decoded data.
For more details, see transformCodec.
Type Parameters
Type Parameter | Description |
---|---|
TOldTo | The original type returned by the decoder. |
TNewTo | The new type that will be transformed after decoding. |
Parameters
Parameter | Type | Description |
---|---|---|
decoder | VariableSizeDecoder <TOldTo > | The decoder to transform. |
map | (value , bytes , offset ) => TNewTo | A function that converts values of TOldTo into TNewTo after decoding. |
Returns
VariableSizeDecoder
<TNewTo
>
A new decoder that decodes into TNewTo
.
Example
Decoding a stored u32
length into a string of 'x'
characters.
See
Call Signature
transformDecoder<
TOldTo
,TNewTo
>(decoder
,map
):Decoder
<TNewTo
>
Transforms a decoder by mapping its output values.
This function takes an existing Decoder<A>
and returns a Decoder<B>
, allowing values of type A
to be converted into values of type B
after decoding. The transformation is applied via the map
function.
This is useful for post-processing, type conversions, or enriching decoded data.
For more details, see transformCodec.
Type Parameters
Type Parameter | Description |
---|---|
TOldTo | The original type returned by the decoder. |
TNewTo | The new type that will be transformed after decoding. |
Parameters
Parameter | Type | Description |
---|---|---|
decoder | Decoder <TOldTo > | The decoder to transform. |
map | (value , bytes , offset ) => TNewTo | A function that converts values of TOldTo into TNewTo after decoding. |
Returns
Decoder
<TNewTo
>
A new decoder that decodes into TNewTo
.
Example
Decoding a stored u32
length into a string of 'x'
characters.