getArrayEncoder
Call Signature
Returns an encoder for arrays of values.
This encoder serializes arrays by encoding each element using the provided item encoder.
By default, a u32 size prefix is included to indicate the number of items in the array.
The size option can be used to modify this behaviour.
For more details, see getArrayCodec.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the elements in the array. |
Parameters
| Parameter | Type | Description |
|---|---|---|
item | Encoder<TFrom> | The encoder for each item in the array. |
config | ArrayCodecConfig<NumberEncoder> & object | Optional configuration for the size encoding strategy. |
Returns
FixedSizeEncoder<TFrom[], 0>
A VariableSizeEncoder<TFrom[]> for encoding arrays.
Example
Encoding an array of u8 numbers.
See
Call Signature
Returns an encoder for arrays of values.
This encoder serializes arrays by encoding each element using the provided item encoder.
By default, a u32 size prefix is included to indicate the number of items in the array.
The size option can be used to modify this behaviour.
For more details, see getArrayCodec.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the elements in the array. |
Parameters
| Parameter | Type | Description |
|---|---|---|
item | FixedSizeEncoder<TFrom> | The encoder for each item in the array. |
config | ArrayCodecConfig<NumberEncoder> & object | Optional configuration for the size encoding strategy. |
Returns
FixedSizeEncoder<TFrom[]>
A VariableSizeEncoder<TFrom[]> for encoding arrays.
Example
Encoding an array of u8 numbers.
See
Call Signature
Returns an encoder for arrays of values.
This encoder serializes arrays by encoding each element using the provided item encoder.
By default, a u32 size prefix is included to indicate the number of items in the array.
The size option can be used to modify this behaviour.
For more details, see getArrayCodec.
Type Parameters
| Type Parameter | Description |
|---|---|
TFrom | The type of the elements in the array. |
Parameters
| Parameter | Type | Description |
|---|---|---|
item | Encoder<TFrom> | The encoder for each item in the array. |
config? | ArrayCodecConfig<NumberEncoder> | Optional configuration for the size encoding strategy. |
Returns
VariableSizeEncoder<TFrom[]>
A VariableSizeEncoder<TFrom[]> for encoding arrays.
Example
Encoding an array of u8 numbers.