getPredicateEncoder
Call Signature
Returns an encoder that selects between two encoders based on a predicate.
This encoder uses a boolean predicate function to determine which of two
encoders to use for a given value. If the predicate returns true, the
ifTrue encoder is used; otherwise, the ifFalse encoder is used.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the value to encode. |
TSize extends number | - |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value) => boolean | A function that returns true or false for a given value. |
ifTrue | FixedSizeEncoder<TFrom, TSize> | The encoder to use when the predicate returns true. |
ifFalse | FixedSizeEncoder<TFrom, TSize> | The encoder to use when the predicate returns false. |
Returns
FixedSizeEncoder<TFrom, TSize>
An Encoder based on the provided encoders.
Example
Encoding small and large numbers differently.
See
Call Signature
Returns an encoder that selects between two encoders based on a predicate.
This encoder uses a boolean predicate function to determine which of two
encoders to use for a given value. If the predicate returns true, the
ifTrue encoder is used; otherwise, the ifFalse encoder is used.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the value to encode. |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value) => boolean | A function that returns true or false for a given value. |
ifTrue | FixedSizeEncoder<TFrom> | The encoder to use when the predicate returns true. |
ifFalse | FixedSizeEncoder<TFrom> | The encoder to use when the predicate returns false. |
Returns
FixedSizeEncoder<TFrom>
An Encoder based on the provided encoders.
Example
Encoding small and large numbers differently.
See
Call Signature
Returns an encoder that selects between two encoders based on a predicate.
This encoder uses a boolean predicate function to determine which of two
encoders to use for a given value. If the predicate returns true, the
ifTrue encoder is used; otherwise, the ifFalse encoder is used.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the value to encode. |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value) => boolean | A function that returns true or false for a given value. |
ifTrue | VariableSizeEncoder<TFrom> | The encoder to use when the predicate returns true. |
ifFalse | VariableSizeEncoder<TFrom> | The encoder to use when the predicate returns false. |
Returns
VariableSizeEncoder<TFrom>
An Encoder based on the provided encoders.
Example
Encoding small and large numbers differently.
See
Call Signature
Returns an encoder that selects between two encoders based on a predicate.
This encoder uses a boolean predicate function to determine which of two
encoders to use for a given value. If the predicate returns true, the
ifTrue encoder is used; otherwise, the ifFalse encoder is used.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the value to encode. |
Parameters
| Parameter | Type | Description |
|---|---|---|
predicate | (value) => boolean | A function that returns true or false for a given value. |
ifTrue | Encoder<TFrom> | The encoder to use when the predicate returns true. |
ifFalse | Encoder<TFrom> | The encoder to use when the predicate returns false. |
Returns
Encoder<TFrom>
An Encoder based on the provided encoders.
Example
Encoding small and large numbers differently.