ArrayInfo

View source

ExtendsTypeInfo

Describes the element type in array reflection metadata.

ArrayInfo records the registered TypeId for every array element. It describes the array type, not the values currently stored in an array, and its serial form uses the array kind discriminator.

Examples

const info = new ArrayInfo(typeid(Number))
info.getElementType() // the registered number type ID
info.serialize() // { kind: 'array', elementType: info.elementType }

Constructor


constructor(elementType: TypeId)

View source

Creates array metadata for one registered element type.

Parameters

NameDescriptionDefault
elementType

Type ID shared by every array element.

—

Properties


Methods


getElementType(): TypeId

View source

Returns the type ID recorded for each array element.

Returns

The registered element type ID.

serialize(): ArrayInfoSerial

View source

Serializes this metadata to its { kind: 'array', elementType } shape. The result contains type metadata only; array values are not serialized.

Returns

The array metadata serial.

staticserialize(value: ArrayInfo): ArrayInfoSerial

View source

Converts array metadata to a plain serial object.

Parameters

NameDescriptionDefault
value

Metadata to serialize.

—

Returns

An object with kind: 'array' and the current element type ID.

staticdeserialize(value: ArrayInfoSerial, out?: ArrayInfo): ArrayInfo

View source

Restores array metadata from a serial object.

If out is omitted, a new ArrayInfo is created. If supplied, its elementType is replaced in place and the same instance is returned. This method assigns the serial value directly and does not call ArrayInfo.validateSerial.

Parameters

NameDescriptionDefault
value

Serialized array metadata.

—
out?

Existing metadata instance to update.

...

Returns

A new or updated array metadata instance.

staticvalidateSerial(value: unknown): value is ArrayInfoSerial

View source

Checks whether a value has the serial shape for array metadata.

The value must be a non-null, non-array object with kind: 'array' and a string elementType. Additional properties are allowed.

Parameters

NameDescriptionDefault
value

Value to validate.

—

Returns

true when the value is an array metadata serial.