getEnumEncoder
Call Signature
Returns an encoder for enums.
This encoder serializes enums as 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<NumberEncoder>, "size"> | Configuration options for encoding the enum. |
Returns
FixedSizeEncoder<GetEnumFrom<TEnum>, 1>
A FixedSizeEncoder or VariableSizeEncoder for encoding enums.
Example
Encoding enum values.
See
Call Signature
Returns an encoder for enums.
This encoder serializes enums as 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<NumberEncoder> & object | Configuration options for encoding the enum. |
Returns
FixedSizeEncoder<GetEnumFrom<TEnum>, TSize>
A FixedSizeEncoder or VariableSizeEncoder for encoding enums.
Example
Encoding enum values.
See
Call Signature
Returns an encoder for enums.
This encoder serializes enums as 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<NumberEncoder> | Configuration options for encoding the enum. |
Returns
VariableSizeEncoder<GetEnumFrom<TEnum>>
A FixedSizeEncoder or VariableSizeEncoder for encoding enums.
Example
Encoding enum values.