Kit
Type aliases

NullableCodecConfig

NullableCodecConfig<TPrefix> = object

Defines the configuration options for nullable codecs.

This configuration controls how nullable values are encoded and decoded.

By default, nullable values are prefixed with a u8 (0 = null, 1 = present). The noneValue and prefix options allow customizing this behavior.

See

Type Parameters

Type ParameterDescription
TPrefix extends NumberCodec | NumberDecoder | NumberEncoderA number codec, encoder, or decoder used as the presence prefix.

Properties

noneValue?

optional noneValue: ReadonlyUint8Array | "zeroes"

Specifies how null values are represented in the encoded data.

  • By default, null values are omitted from encoding.
  • 'zeroes': The bytes allocated for the value are filled with zeroes. This requires a fixed-size codec.
  • Custom byte array: null values are replaced with a predefined byte sequence. This results in a variable-size codec.

Default Value

No explicit noneValue is used; null values are omitted.


prefix?

optional prefix: TPrefix | null

The presence prefix used to distinguish between null and present values.

  • By default, a u8 prefix is used (0 = null, 1 = present).
  • Custom number codec: Allows defining a different number size for the prefix.
  • null: No prefix is used; noneValue (if provided) determines null. If no noneValue is set, null is identified by the absence of bytes.

Default Value

u8 prefix.

On this page