Kit
Functions

getHiddenSuffixDecoder

Call Signature

getHiddenSuffixDecoder<TTo>(decoder, suffixedDecoders): FixedSizeDecoder<TTo>

Returns a decoder that skips hidden suffixed data after decoding the main value.

This decoder applies a list of void decoders after decoding the main value. The suffixed data is skipped during decoding without being exposed to the user.

For more details, see getHiddenSuffixCodec.

Type Parameters

Type ParameterDescription
TToThe type of the main value being decoded.

Parameters

ParameterTypeDescription
decoderFixedSizeDecoder<TTo>The decoder for the main value.
suffixedDecodersreadonly FixedSizeDecoder<void>[]A list of void decoders that produce the hidden suffix.

Returns

FixedSizeDecoder<TTo>

A FixedSizeDecoder or VariableSizeDecoder that decodes values while ignoring the hidden suffix.

Example

Decoding a value with suffixed constants.

const decoder = getHiddenSuffixDecoder(getUtf8Decoder(), [
  getConstantCodec(new Uint8Array([1, 2, 3])),
  getConstantCodec(new Uint8Array([4, 5, 6])),
]);
 
decoder.decode(new Uint8Array([0x48, 0x65, 0x6C, 0x6C, 0x6F, 1, 2, 3, 4, 5, 6]));
// 'Hello'

See

getHiddenSuffixCodec

Call Signature

getHiddenSuffixDecoder<TTo>(decoder, suffixedDecoders): VariableSizeDecoder<TTo>

Returns a decoder that skips hidden suffixed data after decoding the main value.

This decoder applies a list of void decoders after decoding the main value. The suffixed data is skipped during decoding without being exposed to the user.

For more details, see getHiddenSuffixCodec.

Type Parameters

Type ParameterDescription
TToThe type of the main value being decoded.

Parameters

ParameterTypeDescription
decoderDecoder<TTo>The decoder for the main value.
suffixedDecodersreadonly Decoder<void>[]A list of void decoders that produce the hidden suffix.

Returns

VariableSizeDecoder<TTo>

A FixedSizeDecoder or VariableSizeDecoder that decodes values while ignoring the hidden suffix.

Example

Decoding a value with suffixed constants.

const decoder = getHiddenSuffixDecoder(getUtf8Decoder(), [
  getConstantCodec(new Uint8Array([1, 2, 3])),
  getConstantCodec(new Uint8Array([4, 5, 6])),
]);
 
decoder.decode(new Uint8Array([0x48, 0x65, 0x6C, 0x6C, 0x6F, 1, 2, 3, 4, 5, 6]));
// 'Hello'

See

getHiddenSuffixCodec

On this page