Kit
Functions

getSetDecoder

Call Signature

getSetDecoder<TTo>(item, config): FixedSizeDecoder<Set<TTo>, 0>

Returns a decoder for sets of items.

This decoder deserializes a Set<T> from a byte array by decoding each item using the provided item decoder. The number of items is determined by a u32 size prefix by default.

For more details, see getSetCodec.

Type Parameters

Type ParameterDescription
TToThe type of the items in the set after decoding.

Parameters

ParameterTypeDescription
itemDecoder<TTo>The decoder to use for each set item.
configSetCodecConfig<NumberDecoder> & objectOptional configuration specifying the size strategy.

Returns

FixedSizeDecoder<Set<TTo>, 0>

A Decoder<Set<TTo>> for decoding sets of items.

Example

Decoding a set of u8 numbers.

const decoder = getSetDecoder(getU8Decoder());
const value = decoder.decode(new Uint8Array([0x03, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03]));
// new Set([1, 2, 3])

See

getSetCodec

Call Signature

getSetDecoder<TTo>(item, config): FixedSizeDecoder<Set<TTo>>

Returns a decoder for sets of items.

This decoder deserializes a Set<T> from a byte array by decoding each item using the provided item decoder. The number of items is determined by a u32 size prefix by default.

For more details, see getSetCodec.

Type Parameters

Type ParameterDescription
TToThe type of the items in the set after decoding.

Parameters

ParameterTypeDescription
itemFixedSizeDecoder<TTo>The decoder to use for each set item.
configSetCodecConfig<NumberDecoder> & objectOptional configuration specifying the size strategy.

Returns

FixedSizeDecoder<Set<TTo>>

A Decoder<Set<TTo>> for decoding sets of items.

Example

Decoding a set of u8 numbers.

const decoder = getSetDecoder(getU8Decoder());
const value = decoder.decode(new Uint8Array([0x03, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03]));
// new Set([1, 2, 3])

See

getSetCodec

Call Signature

getSetDecoder<TTo>(item, config?): VariableSizeDecoder<Set<TTo>>

Returns a decoder for sets of items.

This decoder deserializes a Set<T> from a byte array by decoding each item using the provided item decoder. The number of items is determined by a u32 size prefix by default.

For more details, see getSetCodec.

Type Parameters

Type ParameterDescription
TToThe type of the items in the set after decoding.

Parameters

ParameterTypeDescription
itemDecoder<TTo>The decoder to use for each set item.
config?SetCodecConfig<NumberDecoder>Optional configuration specifying the size strategy.

Returns

VariableSizeDecoder<Set<TTo>>

A Decoder<Set<TTo>> for decoding sets of items.

Example

Decoding a set of u8 numbers.

const decoder = getSetDecoder(getU8Decoder());
const value = decoder.decode(new Uint8Array([0x03, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03]));
// new Set([1, 2, 3])

See

getSetCodec

On this page