getPredicateDecoder
Call Signature
Returns a decoder that selects between two decoders based on a predicate.
This decoder uses a boolean predicate function on the raw bytes to determine
which of two decoders to use. If the predicate returns true, the ifTrue
decoder is used; otherwise, the ifFalse decoder is used.
Type Parameters
| Type Parameter | Description |
|---|---|
TTo | The type of the value to decode. |
TSize extends number | - |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value) => boolean | A function that returns true or false for a given byte array. |
ifTrue | FixedSizeDecoder<TTo, TSize> | The decoder to use when the predicate returns true. |
ifFalse | FixedSizeDecoder<TTo, TSize> | The decoder to use when the predicate returns false. |
Returns
FixedSizeDecoder<TTo, TSize>
A Decoder based on the provided decoders.
Example
Decoding small and large numbers based on byte length.
See
Call Signature
Returns a decoder that selects between two decoders based on a predicate.
This decoder uses a boolean predicate function on the raw bytes to determine
which of two decoders to use. If the predicate returns true, the ifTrue
decoder is used; otherwise, the ifFalse decoder is used.
Type Parameters
| Type Parameter | Description |
|---|---|
TTo | The type of the value to decode. |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value) => boolean | A function that returns true or false for a given byte array. |
ifTrue | FixedSizeDecoder<TTo> | The decoder to use when the predicate returns true. |
ifFalse | FixedSizeDecoder<TTo> | The decoder to use when the predicate returns false. |
Returns
FixedSizeDecoder<TTo>
A Decoder based on the provided decoders.
Example
Decoding small and large numbers based on byte length.
See
Call Signature
Returns a decoder that selects between two decoders based on a predicate.
This decoder uses a boolean predicate function on the raw bytes to determine
which of two decoders to use. If the predicate returns true, the ifTrue
decoder is used; otherwise, the ifFalse decoder is used.
Type Parameters
| Type Parameter | Description |
|---|---|
TTo | The type of the value to decode. |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value) => boolean | A function that returns true or false for a given byte array. |
ifTrue | VariableSizeDecoder<TTo> | The decoder to use when the predicate returns true. |
ifFalse | VariableSizeDecoder<TTo> | The decoder to use when the predicate returns false. |
Returns
VariableSizeDecoder<TTo>
A Decoder based on the provided decoders.
Example
Decoding small and large numbers based on byte length.
See
Call Signature
Returns a decoder that selects between two decoders based on a predicate.
This decoder uses a boolean predicate function on the raw bytes to determine
which of two decoders to use. If the predicate returns true, the ifTrue
decoder is used; otherwise, the ifFalse decoder is used.
Type Parameters
| Type Parameter | Description |
|---|---|
TTo | The type of the value to decode. |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value) => boolean | A function that returns true or false for a given byte array. |
ifTrue | Decoder<TTo> | The decoder to use when the predicate returns true. |
ifFalse | Decoder<TTo> | The decoder to use when the predicate returns false. |
Returns
Decoder<TTo>
A Decoder based on the provided decoders.
Example
Decoding small and large numbers based on byte length.