Skip to main content

Class: SchemaStore<Entries>

Type Parameters

Type ParameterDefault type
Entries extends objectobject

Constructors

new SchemaStore()

new SchemaStore<Entries>(defaultMaximumArrayLength: number): SchemaStore<Entries>

Creates a new schema store

Parameters

ParameterTypeDefault valueDescription
defaultMaximumArrayLengthnumber100The default maximum array length for schemas

Returns

SchemaStore<Entries>

Defined in

schema/SchemaStore.ts:18

Properties

#schemas

private #schemas: Map<number, Schema<number, object>>

Defined in

schema/SchemaStore.ts:11


defaultMaximumArrayLength

defaultMaximumArrayLength: number

The default maximum array length for schemas

Defined in

schema/SchemaStore.ts:9

Methods

[iterator]()

[iterator](): IterableIterator<{ [K in string | number | symbol]: readonly [K & number, Entries[K]] }[keyof Entries]>

Iterates over the stores's schema entries.

Returns

IterableIterator<{ [K in string | number | symbol]: readonly [K & number, Entries[K]] }[keyof Entries]>

An iterator for the stores's schema entries

Defined in

schema/SchemaStore.ts:117


add()

add<Id, SchemaType>(schema: Schema<Id, SchemaType>): Merge<Entries, Id, Schema<Id, SchemaType>>

Adds a schema to the store

Type Parameters

Type Parameter
Id extends number
SchemaType extends object

Parameters

ParameterTypeDescription
schemaSchema<Id, SchemaType>The schema to add to the store

Returns

Merge<Entries, Id, Schema<Id, SchemaType>>

The modified store

Remarks

An error will be thrown if a schema with the same id already exists in the store.

Defined in

schema/SchemaStore.ts:32


deserialize()

deserialize(buffer: string | UnalignedUint16Array): DeserializationResult<Entries>

Deserializes a buffer

Parameters

ParameterTypeDescription
bufferstring | UnalignedUint16ArrayThe buffer to deserialize

Returns

DeserializationResult<Entries>

The resolved value, including the id of the schema used for deserialization

Defined in

schema/SchemaStore.ts:77


entries()

entries(): IterableIterator<{ [K in string | number | symbol]: readonly [K & number, Entries[K]] }[keyof Entries]>

Iterates over the stores's schema entries.

Returns

IterableIterator<{ [K in string | number | symbol]: readonly [K & number, Entries[K]] }[keyof Entries]>

An iterator for the stores's schema entries

Defined in

schema/SchemaStore.ts:108


get()

get<Id>(id: Id): Entries[Id]

Gets a schema from the store

Type Parameters

Type Parameter
Id extends number

Parameters

ParameterTypeDescription
idIdThe id of the schema to get

Returns

Entries[Id]

The schema with the given id

Remarks

An error will be thrown if a schema with the given id does not exist in the store.

Defined in

schema/SchemaStore.ts:51


keys()

keys(): IterableIterator<keyof Entries & number>

Iterates over the stores's schema identifiers.

Returns

IterableIterator<keyof Entries & number>

An iterator for the stores's schema identifiers

Defined in

schema/SchemaStore.ts:90


serialize()

serialize<Id>(id: Id, value: Readonly<UnwrapSchema<Entries[Id] & object>>): UnalignedUint16Array

Serializes a value using the schema with the given id

Type Parameters

Type Parameter
Id extends number

Parameters

ParameterTypeDescription
idIdThe id of the schema to use for serialization
valueReadonly<UnwrapSchema<Entries[Id] & object>>The value to serialize

Returns

UnalignedUint16Array

The serialized buffer

Defined in

schema/SchemaStore.ts:64


values()

values(): IterableIterator<Entries[keyof Entries & number]>

Iterates over the stores's schemas.

Returns

IterableIterator<Entries[keyof Entries & number]>

An iterator for the stores's schemas

Defined in

schema/SchemaStore.ts:99