Skip to content

ArrayModelCodec

Defined in: packages/common/src/codecs/models/array-model.ts:4

A bidirectional codec that transforms between application types and wire formats. Supports format-specific encoding (JSON vs msgpack).

  • Codec<T, unknown[] | undefined>

T extends unknown[] = unknown[]

The application/runtime type (e.g., bigint, string, Uint8Array)

new ArrayModelCodec<T>(metadata): ArrayModelCodec<T>

Defined in: packages/common/src/codecs/models/array-model.ts:7

ArrayModelMetadata | () => ArrayModelMetadata

ArrayModelCodec<T>

Codec.constructor

decode(value, format): T

Defined in: packages/common/src/codecs/models/array-model.ts:38

Decode a value from wire format

The wire value

unknown[] | null | undefined

EncodingFormat

The wire format (json or msgpack)

T

The decoded application value

Codec.decode


decodeOptional(value, format): T | undefined

Defined in: packages/common/src/codecs/models/array-model.ts:43

Decode an optional value from wire format (preserves undefined vs default distinction)

The wire value

unknown[] | null | undefined

EncodingFormat

The wire format (json or msgpack)

T | undefined

The decoded application value, or undefined if wire value was undefined

Codec.decodeOptional


defaultValue(): T

Defined in: packages/common/src/codecs/models/array-model.ts:18

The default value for this type (used to determine if a value should be omitted during encoding)

T

Codec.defaultValue


encode(value, format): unknown[] | undefined

Defined in: packages/common/src/codecs/models/array-model.ts:28

Encode a value, always returning the value regardless of if it is default

The application value

T | null | undefined

EncodingFormat

The wire format (json or msgpack)

unknown[] | undefined

The encoded value, or the default if it is undefined or null

Codec.encode


encodeOptional(value, format): unknown[] | undefined

Defined in: packages/common/src/codecs/models/array-model.ts:33

Encode a value, omitting it if set to the default value.

The application value

T | null | undefined

EncodingFormat

The wire format (json or msgpack)

unknown[] | undefined

The encoded value, or undefined if it equals the default (will be omitted)

Codec.encodeOptional


isDefaultValue(value): boolean

Defined in: packages/common/src/codecs/models/array-model.ts:23

Check if a value equals the default value (determines if it should be omitted during encoding) Override this method for custom default comparison logic, otherwise defaults to default value equality

T

The value to check

boolean

True if value equals default

Codec.isDefaultValue