Class: Schema<Id, Entries>
Type Parameters
| Type Parameter | Default type |
|---|---|
Id extends number | number |
Entries extends object | object |
Constructors
new Schema()
new Schema<
Id,Entries>(id:Id):Schema<Id,Entries>
Creates a new schema.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | Id | The id of the schema |
Returns
Schema<Id, Entries>
Defined in
Properties
#bitSize
private#bitSize:null|number=0
Defined in
#id
privatereadonly#id:Id
Defined in
#types
privatereadonly#types:Map<string,IType<any,null|number>>
Defined in
Accessors
bitSize
Get Signature
get bitSize():
null|number
The total bit size of the schema.
Remarks
If any of the entries have a bit size of null, the bit size of the
schema will also be null.
Returns
null | number
Defined in
id
Get Signature
get id():
Id
The id of the schema.
Returns
Id
Defined in
Methods
[iterator]()
[iterator]():
IterableIterator<{ [K in string | number | symbol]: readonly [K, Entries[K]] }[keyofEntries]>
Iterates over the schema's property entries
Returns
IterableIterator<{ [K in string | number | symbol]: readonly [K, Entries[K]] }[keyof Entries]>
An iterator for the schema's property entries
Defined in
#addType()
private#addType<EntryName,ValueType,ValueBitSize>(name:EntryName,type:IType<ValueType,ValueBitSize>):Merge<Id,Entries,EntryName,IType<ValueType,ValueBitSize>>
Type Parameters
| Type Parameter |
|---|
EntryName extends string |
ValueType |
ValueBitSize extends null | number |
Parameters
| Parameter | Type |
|---|---|
name | EntryName |
type | IType<ValueType, ValueBitSize> |
Returns
Merge<Id, Entries, EntryName, IType<ValueType, ValueBitSize>>
Defined in
array()
array<
Name,ValueType,ValueBitSize>(name:Name,type:IType<ValueType,ValueBitSize>):Merge<Id,Entries,Name,IType<ValueType[],null>>
Adds an array property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
ValueType |
ValueBitSize extends null | number |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
type | IType<ValueType, ValueBitSize> | The type of the entry in the array |
Returns
Merge<Id, Entries, Name, IType<ValueType[], null>>
The modified schema
Seealso
Schema.fixedLengthArray for a fixed length array
Defined in
bigInt32()
bigInt32<
Name>(name:Name):Merge<Id,Entries,Name,IType<bigint,32>>
Adds a 32-bit big integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<bigint, 32>>
The modified schema
Remarks
The range of values is from -2_147_483_648n to 2_147_483_647n, inclusive.
Defined in
bigInt64()
bigInt64<
Name>(name:Name):Merge<Id,Entries,Name,IType<bigint,64>>
Adds a 64-bit big integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<bigint, 64>>
The modified schema
Remarks
The range of values is from -9_223_372_036_854_775_808n to 9_223_372_036_854_775_807n, inclusive.
Defined in
bigUint32()
bigUint32<
Name>(name:Name):Merge<Id,Entries,Name,IType<bigint,32>>
Adds a 32-bit big integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<bigint, 32>>
The modified schema
Remarks
The range of values is from 0n to 4_294_967_295n, inclusive.
Defined in
bigUint64()
bigUint64<
Name>(name:Name):Merge<Id,Entries,Name,IType<bigint,64>>
Adds a 64-bit big integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<bigint, 64>>
The modified schema
Remarks
The range of values is from 0n to 18_446_744_073_709_551_615n, inclusive.
Defined in
bit()
bit<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,1>>
Adds a bit property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 1>>
The modified schema
Defined in
boolean()
boolean<
Name>(name:Name):Merge<Id,Entries,Name,IType<boolean,1>>
Adds a boolean property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<boolean, 1>>
The modified schema
Defined in
deserialize()
deserialize(
buffer:UnalignedUint16Array,pointer:PointerLike):UnwrapSchemaEntries<Entries>
Deserialize a value from a buffer.
Parameters
| Parameter | Type | Description |
|---|---|---|
buffer | UnalignedUint16Array | The buffer to deserialize |
pointer | PointerLike | The pointer to where the buffer should be read from |
Returns
UnwrapSchemaEntries<Entries>
The deserialized value
Remarks
Unlike Schema.serialize, this method does not read the schema's ID from the buffer, that is reserved for the SchemaStore.
Defined in
entries()
entries():
IterableIterator<{ [K in string | number | symbol]: readonly [K, Entries[K]] }[keyofEntries]>
Iterates over the schema's property entries
Returns
IterableIterator<{ [K in string | number | symbol]: readonly [K, Entries[K]] }[keyof Entries]>
An iterator for the schema's property entries
Defined in
fixedLengthArray()
fixedLengthArray<
Name,ValueType,ValueBitSize>(name:Name,type:IType<ValueType,ValueBitSize>,length:number):Merge<Id,Entries,Name,IType<ValueType[],ValueBitSizeextendsnull?null:number>>
Adds a fixed length array property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
ValueType |
ValueBitSize extends null | number |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
type | IType<ValueType, ValueBitSize> | The type of the entry in the array |
length | number | The length of the array |
Returns
Merge<Id, Entries, Name, IType<ValueType[], ValueBitSize extends null ? null : number>>
The modified schema
Seealso
Schema.array for a dynamic length array
Defined in
float32()
float32<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,32>>
Adds a 32-bit floating point number property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 32>>
The modified schema
Remarks
The range of values is from -3.4028234663852886e+38 to 3.4028234663852886e+38, inclusive.
Defined in
float64()
float64<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,64>>
Adds a 64-bit floating point number property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 64>>
The modified schema
Remarks
The range of values is from -1.7976931348623157e+308 to 1.7976931348623157e+308, inclusive.
Defined in
get()
get<
Name>(name:Name):Entries[Name]
Get a property from the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Entries[Name]
The specified property
Remarks
If the property does not exist, an error will be thrown.
Defined in
int16()
int16<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,16>>
Adds a 16-bit integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 16>>
The modified schema
Remarks
The range of values is from -32768 to 32767, inclusive.
Defined in
int2()
int2<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,2>>
Adds a 2-bit integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 2>>
The modified schema
Remarks
The range of values is from -2 to 1, inclusive.
Defined in
int32()
int32<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,32>>
Adds a 32-bit integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 32>>
The modified schema
Remarks
The range of values is from -2_147_483_648 to 2_147_483_647, inclusive.
Defined in
int4()
int4<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,4>>
Adds a 4-bit integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 4>>
The modified schema
Remarks
The range of values is from -8 to 7, inclusive.
Defined in
int64()
int64<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,64>>
Adds a 64-bit integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 64>>
The modified schema
Remarks
The range of values is from -9_223_372_036_854_775_808 to 9_223_372_036_854_775_807, inclusive.
However, it may run into precision issues past the range of -9_007_199_254_740_991 to 9_007_199_254_740_991
Defined in
int8()
int8<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,8>>
Adds a 8-bit integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 8>>
The modified schema
Remarks
The range of values is from -128 to 127, inclusive.
Defined in
keys()
keys():
IterableIterator<keyofEntries&string>
Iterates over the schema's property names.
Returns
IterableIterator<keyof Entries & string>
An iterator for the schema's property names
Defined in
serialize()
serialize(
buffer:UnalignedUint16Array,value:Readonly<UnwrapSchemaEntries<Entries>>):void
Serialize a value into a buffer.
Parameters
| Parameter | Type | Description |
|---|---|---|
buffer | UnalignedUint16Array | The buffer to serialize |
value | Readonly<UnwrapSchemaEntries<Entries>> | The value to serialize into the buffer |
Returns
void
Remarks
The schema's ID is written to the buffer first, followed by each property in the schema.
Defined in
snowflake()
snowflake<
Name>(name:Name):Merge<Id,Entries,Name,IType<bigint,64>>
Adds a 64-bit big integer property to the schema, similar to Schema.bigUint64.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<bigint, 64>>
The modified schema
Remarks
The range of values is from 0n to 18_446_744_073_709_551_615n, inclusive.
Defined in
string()
string<
Name>(name:Name):Merge<Id,Entries,Name,IType<string,null>>
Adds a string property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<string, null>>
The modified schema
Defined in
uint16()
uint16<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,16>>
Adds a 16-bit unsigned integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 16>>
The modified schema
Remarks
The range of values is from 0 to 65535, inclusive.
Defined in
uint2()
uint2<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,2>>
Adds a 2-bit unsigned integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 2>>
The modified schema
Remarks
The range of values is from 0 to 3, inclusive.
Defined in
uint32()
uint32<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,32>>
Adds a 32-bit unsigned integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 32>>
The modified schema
Remarks
The range of values is from 0 to 4_294_967_295, inclusive.
Defined in
uint4()
uint4<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,4>>
Adds a 4-bit unsigned integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 4>>
The modified schema
Remarks
The range of values is from 0 to 15, inclusive.
Defined in
uint64()
uint64<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,64>>
Adds a 64-bit unsigned integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 64>>
The modified schema
Remarks
The range of values is from 0 to 18_446_744_073_709_551_615, inclusive.
However, it may run into precision issues past 9_007_199_254_740_991
Defined in
uint8()
uint8<
Name>(name:Name):Merge<Id,Entries,Name,IType<number,8>>
Adds a 8-bit unsigned integer property to the schema.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
name | Name | The name of the property |
Returns
Merge<Id, Entries, Name, IType<number, 8>>
The modified schema
Remarks
The range of values is from 0 to 255, inclusive.
Defined in
values()
values():
IterableIterator<{ [K in string | number | symbol]: Entries[K] }[keyofEntries]>
Iterates over the schema's property values
Returns
IterableIterator<{ [K in string | number | symbol]: Entries[K] }[keyof Entries]>
An iterator for the schema's property values