ArrayLikeCodecSize

type ArrayLikeCodecSize<TPrefix> = 
  | ArrayLikeCodecSentinelSize
  | TPrefix
  | number
  | "remainder";

Defines the possible size strategies for array-like codecs (array, map, and set).

The size of the collection can be determined using one of the following approaches:

  • A NumberCodec, NumberDecoder, or NumberEncoder to store a size prefix.
  • A fixed number of items, enforcing an exact length.
  • The string "remainder", which infers the number of items by consuming the rest of the available bytes.
  • An ArrayLikeCodecSentinelSize object, which ends the collection when the bytes at the next item position match a constant sentinel.

Type Parameters

Type ParameterDescription
TPrefix extends | NumberCodec | NumberDecoder | NumberEncoderA number codec, decoder, or encoder used for size prefixing.

On this page