Kit
Functions

getHiddenPrefixDecoder

Call Signature

getHiddenPrefixDecoder<TTo>(decoder, prefixedDecoders): FixedSizeDecoder<TTo>

Returns a decoder that skips hidden prefixed data before decoding the main value.

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

For more details, see getHiddenPrefixCodec.

Type Parameters

Type ParameterDescription
TToThe type of the main value being decoded.

Parameters

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

Returns

FixedSizeDecoder<TTo>

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

Example

Decoding a value with prefixed constants.

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

See

getHiddenPrefixCodec

Call Signature

getHiddenPrefixDecoder<TTo>(decoder, prefixedDecoders): VariableSizeDecoder<TTo>

Returns a decoder that skips hidden prefixed data before decoding the main value.

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

For more details, see getHiddenPrefixCodec.

Type Parameters

Type ParameterDescription
TToThe type of the main value being decoded.

Parameters

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

Returns

VariableSizeDecoder<TTo>

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

Example

Decoding a value with prefixed constants.

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

See

getHiddenPrefixCodec

On this page