ArrayCodec
Defined in: packages/common/src/codecs/composite/array.ts:13
Array codec - encodes each element using the item codec
Extends
Section titled “Extends”Codec<T[],TEncoded[]>
Type Parameters
Section titled “Type Parameters”T
TEncoded
Section titled “TEncoded”TEncoded = T
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ArrayCodec<
T,TEncoded>(itemCodec):ArrayCodec<T,TEncoded>
Defined in: packages/common/src/codecs/composite/array.ts:14
Parameters
Section titled “Parameters”itemCodec
Section titled “itemCodec”Codec<T, TEncoded>
Returns
Section titled “Returns”ArrayCodec<T, TEncoded>
Overrides
Section titled “Overrides”Methods
Section titled “Methods”decode()
Section titled “decode()”decode(
value,format):T[]
Defined in: packages/common/src/codecs/codec.ts:46
Decode a value from wire format
Parameters
Section titled “Parameters”The wire value
TEncoded[] | null | undefined
format
Section titled “format”The wire format (json or msgpack)
Returns
Section titled “Returns”T[]
The decoded application value
Inherited from
Section titled “Inherited from”decodeOptional()
Section titled “decodeOptional()”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)
Parameters
Section titled “Parameters”The wire value
TEncoded[] | null | undefined
format
Section titled “format”The wire format (json or msgpack)
Returns
Section titled “Returns”T[] | undefined
The decoded application value, or undefined if wire value was undefined
Inherited from
Section titled “Inherited from”defaultValue()
Section titled “defaultValue()”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)
Returns
Section titled “Returns”T[]
Overrides
Section titled “Overrides”encode()
Section titled “encode()”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
Parameters
Section titled “Parameters”The application value
T[] | null | undefined
format
Section titled “format”The wire format (json or msgpack)
Returns
Section titled “Returns”TEncoded[]
The encoded value, or the default if it is undefined or null
Inherited from
Section titled “Inherited from”encodeOptional()
Section titled “encodeOptional()”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.
Parameters
Section titled “Parameters”The application value
T[] | null | undefined
format
Section titled “format”The wire format (json or msgpack)
Returns
Section titled “Returns”TEncoded[] | undefined
The encoded value, or undefined if it equals the default (will be omitted)
Inherited from
Section titled “Inherited from”isDefaultValue()
Section titled “isDefaultValue()”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
Parameters
Section titled “Parameters”T[]
The value to check
Returns
Section titled “Returns”boolean
True if value equals default