Skip to content

RecordCodec

Defined in: packages/common/src/codecs/composite/record.ts:9

Record codec - for string-keyed objects with homogeneous values

V

VEncoded = V

new RecordCodec<V, VEncoded>(valueCodec): RecordCodec<V, VEncoded>

Defined in: packages/common/src/codecs/composite/record.ts:10

Codec<V, VEncoded>

RecordCodec<V, VEncoded>

Codec.constructor

decode(value, format): T

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

Decode a value from wire format

The wire value

WireObject<VEncoded> | null | undefined

EncodingFormat

The wire format (json or msgpack)

T

The decoded application value

Codec.decode


decodeOptional(value, format): Record<string, V> | 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

WireObject<VEncoded> | null | undefined

EncodingFormat

The wire format (json or msgpack)

Record<string, V> | undefined

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

Codec.decodeOptional


defaultValue(): Record<string, V>

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

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

Record<string, V>

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

Record<string, V> | 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): Record<string, VEncoded> | undefined

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

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

The application value

Record<string, V> | null | undefined

EncodingFormat

The wire format (json or msgpack)

Record<string, VEncoded> | 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/record.ts:49

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

Record<string, V>

The value to check

boolean

True if value equals default

Codec.isDefaultValue