getEnumDecoder
Call Signature
getEnumDecoder<
TEnum
>(constructor
,config?
):FixedSizeDecoder
<GetEnumTo
<TEnum
>,1
>
Returns a decoder for enums.
This decoder deserializes enums from a numerical discriminator. By default, the discriminator is based on the positional index of the enum variants.
For more details, see getEnumCodec.
Type Parameters
Type Parameter | Description |
---|---|
TEnum extends EnumLookupObject | The TypeScript enum or object mapping enum keys to values. |
Parameters
Parameter | Type | Description |
---|---|---|
constructor | TEnum | The constructor of the enum. |
config? | Omit <EnumCodecConfig <NumberDecoder >, "size" > | Configuration options for decoding the enum. |
Returns
FixedSizeDecoder
<GetEnumTo
<TEnum
>, 1
>
A FixedSizeDecoder
or VariableSizeDecoder
for decoding enums.
Example
Decoding enum values.
See
Call Signature
getEnumDecoder<
TEnum
,TSize
>(constructor
,config
):FixedSizeDecoder
<GetEnumTo
<TEnum
>,TSize
>
Returns a decoder for enums.
This decoder deserializes enums from a numerical discriminator. By default, the discriminator is based on the positional index of the enum variants.
For more details, see getEnumCodec.
Type Parameters
Type Parameter | Description |
---|---|
TEnum extends EnumLookupObject | The TypeScript enum or object mapping enum keys to values. |
TSize extends number | - |
Parameters
Parameter | Type | Description |
---|---|---|
constructor | TEnum | The constructor of the enum. |
config | EnumCodecConfig <NumberDecoder > & object | Configuration options for decoding the enum. |
Returns
FixedSizeDecoder
<GetEnumTo
<TEnum
>, TSize
>
A FixedSizeDecoder
or VariableSizeDecoder
for decoding enums.
Example
Decoding enum values.
See
Call Signature
getEnumDecoder<
TEnum
>(constructor
,config?
):VariableSizeDecoder
<GetEnumTo
<TEnum
>>
Returns a decoder for enums.
This decoder deserializes enums from a numerical discriminator. By default, the discriminator is based on the positional index of the enum variants.
For more details, see getEnumCodec.
Type Parameters
Type Parameter | Description |
---|---|
TEnum extends EnumLookupObject | The TypeScript enum or object mapping enum keys to values. |
Parameters
Parameter | Type | Description |
---|---|---|
constructor | TEnum | The constructor of the enum. |
config? | EnumCodecConfig <NumberDecoder > | Configuration options for decoding the enum. |
Returns
VariableSizeDecoder
<GetEnumTo
<TEnum
>>
A FixedSizeDecoder
or VariableSizeDecoder
for decoding enums.
Example
Decoding enum values.