Skip to content

ArrayCodec

Defined in: packages/common/src/codecs/composite/array.ts:13

Array codec - encodes each element using the item codec

T

TEncoded = T

new ArrayCodec<T, TEncoded>(itemCodec): ArrayCodec<T, TEncoded>

Defined in: packages/common/src/codecs/composite/array.ts:14

Codec<T, TEncoded>

ArrayCodec<T, TEncoded>

Codec.constructor

decode(value, format): T[]

Defined in: packages/common/src/codecs/codec.ts:46

Decode a value from wire format

The wire value

TEncoded[] | 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/codec.ts:60

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

The wire value

TEncoded[] | 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/composite/array.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): TEncoded[]

Defined in: packages/common/src/codecs/codec.ts:23

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)

TEncoded[]

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

Codec.encode


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

Defined in: packages/common/src/codecs/codec.ts:34

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

The application value

T[] | null | undefined

EncodingFormat

The wire format (json or msgpack)

TEncoded[] | 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/composite/array.ts:30

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