Kit
Functions

getHiddenSuffixEncoder

Call Signature

getHiddenSuffixEncoder<TFrom>(encoder, suffixedEncoders): FixedSizeEncoder<TFrom>

Returns an encoder that appends hidden data after the encoded value.

This encoder applies a list of void encoders after encoding the main value. The suffixed data is encoded after the main value without being exposed to the user.

For more details, see getHiddenSuffixCodec.

Type Parameters

Type ParameterDescription
TFromThe type of the main value being encoded.

Parameters

ParameterTypeDescription
encoderFixedSizeEncoder<TFrom>The encoder for the main value.
suffixedEncodersreadonly FixedSizeEncoder<void>[]A list of void encoders that produce the hidden suffix.

Returns

FixedSizeEncoder<TFrom>

A FixedSizeEncoder or VariableSizeEncoder that encodes the value with a hidden suffix.

Example

Suffixing a value with constants.

const encoder = getHiddenSuffixEncoder(getUtf8Encoder(), [
  getConstantCodec(new Uint8Array([1, 2, 3])),
  getConstantCodec(new Uint8Array([4, 5, 6])),
]);
 
encoder.encode('Hello');
// 0x48656c6c6f010203040506
//   |         |     └-- Our second hidden suffix.
//   |         └-- Our first hidden suffix.
//   └-- Our encoded value ("Hello").

See

getHiddenSuffixCodec

Call Signature

getHiddenSuffixEncoder<TFrom>(encoder, suffixedEncoders): VariableSizeEncoder<TFrom>

Returns an encoder that appends hidden data after the encoded value.

This encoder applies a list of void encoders after encoding the main value. The suffixed data is encoded after the main value without being exposed to the user.

For more details, see getHiddenSuffixCodec.

Type Parameters

Type ParameterDescription
TFromThe type of the main value being encoded.

Parameters

ParameterTypeDescription
encoderEncoder<TFrom>The encoder for the main value.
suffixedEncodersreadonly Encoder<void>[]A list of void encoders that produce the hidden suffix.

Returns

VariableSizeEncoder<TFrom>

A FixedSizeEncoder or VariableSizeEncoder that encodes the value with a hidden suffix.

Example

Suffixing a value with constants.

const encoder = getHiddenSuffixEncoder(getUtf8Encoder(), [
  getConstantCodec(new Uint8Array([1, 2, 3])),
  getConstantCodec(new Uint8Array([4, 5, 6])),
]);
 
encoder.encode('Hello');
// 0x48656c6c6f010203040506
//   |         |     └-- Our second hidden suffix.
//   |         └-- Our first hidden suffix.
//   └-- Our encoded value ("Hello").

See

getHiddenSuffixCodec

On this page