getLiteralUnionDecoder
Call Signature
getLiteralUnionDecoder<
TVariants
>(variants
):FixedSizeDecoder
<GetTypeFromVariants
<TVariants
>,1
>
Returns a decoder for literal unions.
This decoder deserializes a numerical index into a corresponding value from a predefined set of literals.
For more details, see getLiteralUnionCodec.
Type Parameters
Type Parameter | Description |
---|---|
TVariants extends readonly Variant [] | A tuple of allowed literal values. |
Parameters
Parameter | Type | Description |
---|---|---|
variants | TVariants | The possible literal values for the union. |
Returns
FixedSizeDecoder
<GetTypeFromVariants
<TVariants
>, 1
>
A FixedSizeDecoder
or VariableSizeDecoder
for decoding literal unions.
Example
Decoding a union of string literals.
See
Call Signature
getLiteralUnionDecoder<
TVariants
,TSize
>(variants
,config
):FixedSizeDecoder
<GetTypeFromVariants
<TVariants
>,TSize
>
Returns a decoder for literal unions.
This decoder deserializes a numerical index into a corresponding value from a predefined set of literals.
For more details, see getLiteralUnionCodec.
Type Parameters
Type Parameter | Description |
---|---|
TVariants extends readonly Variant [] | A tuple of allowed literal values. |
TSize extends number | - |
Parameters
Parameter | Type | Description |
---|---|---|
variants | TVariants | The possible literal values for the union. |
config | LiteralUnionCodecConfig <NumberDecoder > & object | Configuration options for decoding the literal union. |
Returns
FixedSizeDecoder
<GetTypeFromVariants
<TVariants
>, TSize
>
A FixedSizeDecoder
or VariableSizeDecoder
for decoding literal unions.
Example
Decoding a union of string literals.
See
Call Signature
getLiteralUnionDecoder<
TVariants
>(variants
,config?
):VariableSizeDecoder
<GetTypeFromVariants
<TVariants
>>
Returns a decoder for literal unions.
This decoder deserializes a numerical index into a corresponding value from a predefined set of literals.
For more details, see getLiteralUnionCodec.
Type Parameters
Type Parameter | Description |
---|---|
TVariants extends readonly Variant [] | A tuple of allowed literal values. |
Parameters
Parameter | Type | Description |
---|---|---|
variants | TVariants | The possible literal values for the union. |
config? | LiteralUnionCodecConfig <NumberDecoder > | Configuration options for decoding the literal union. |
Returns
VariableSizeDecoder
<GetTypeFromVariants
<TVariants
>>
A FixedSizeDecoder
or VariableSizeDecoder
for decoding literal unions.
Example
Decoding a union of string literals.