PrimitiveType<K, T> Interface
Package: @esfx/struct-type
Represents a primitive type.
Declaration
export interface PrimitiveType<K extends string = string, T extends number | bigint | boolean = number | bigint | boolean>
Properties
[InitType]
Declaration
[InitType]: number | bigint | boolean;
Property Value
number | bigint | boolean
[RuntimeType]
Declaration
[RuntimeType]: T;
Property Value
T
name
The name of the primitive type.
Declaration
readonly name: K;
Property Value
K
SIZE
The size, in bytes, of the primitive type.
Declaration
readonly SIZE: number;
Property Value
Methods
read(buffer, byteOffset, byteOrder)
Reads a primitive value from the buffer.
Declaration
read(buffer: ArrayBufferLike, byteOffset: number, byteOrder?: Endianness): T;
Parameters
- buffer
- ArrayBufferLike
The ArrayBuffer
or SharedArrayBuffer
from which to read the value.
- byteOrder
- Endianness
The endianness to use when reading the value. If unspecified, the native byte order will be used.
Returns
T
write(buffer, byteOffset, value, byteOrder)
Writes a primitive value to a buffer.
Declaration
write(buffer: ArrayBufferLike, byteOffset: number, value: T, byteOrder?: Endianness): void;
Parameters
- buffer
- ArrayBufferLike
The ArrayBuffer
or SharedArrayBuffer
into which to write the value.
- value
- T
The value to write.
- byteOrder
- Endianness
The endianness to use when writing the value. If unspecified, the native byte order will be used.
Returns
void