Class: BinaryWriter#

Packs primitive types into a binary string.

example

// Write the values
const writer = new BinaryWriter();
writer.writeUInt8(5);
writer.writeUInt8(32);
writer.writeUInt8(78);
writer.writeUInt8(200);
writer.writeUInt32(12345678);
writer.writeString("hello");
writer.writeUInt16(45000);
// Read the values
const binaryString = writer.toString();
const reader = new BinaryReader(binaryString);
const values: any[] = [];
values[0] = reader.readUInt8(); // 5
values[1] = reader.readUInt8(); // 32
values[2] = reader.readUInt8(); // 78
values[3] = reader.readUInt8(); // 200
values[4] = reader.readUInt32(); // 12345678
values[5] = reader.readString(); // hello
values[6] = reader.readUInt16(); // 45000

Hierarchy#

  • BinaryWriter

Constructors#

constructor#

new BinaryWriter(): BinaryWriter

Returns: BinaryWriter

Properties#

values#

• Readonly values: (string | number)[]

Defined in: system/binarywriter.ts:31

Methods#

toString#

toString(): string

Returns: string

Defined in: system/binarywriter.ts:34


writeDouble#

writeDouble(value: number): void

Parameters:#

NameType
valuenumber

Returns: void

Defined in: system/binarywriter.ts:38


writeFloat#

writeFloat(value: number): void

Parameters:#

NameType
valuenumber

Returns: void

Defined in: system/binarywriter.ts:43


writeInt16#

writeInt16(value: number): void

Parameters:#

NameType
valuenumber

Returns: void

Defined in: system/binarywriter.ts:48


writeInt32#

writeInt32(value: number): void

Parameters:#

NameType
valuenumber

Returns: void

Defined in: system/binarywriter.ts:53


writeInt8#

writeInt8(value: number): void

Parameters:#

NameType
valuenumber

Returns: void

Defined in: system/binarywriter.ts:58


writeString#

writeString(value: string): void

Parameters:#

NameType
valuestring

Returns: void

Defined in: system/binarywriter.ts:63


writeUInt16#

writeUInt16(value: number): void

Parameters:#

NameType
valuenumber

Returns: void

Defined in: system/binarywriter.ts:68


writeUInt32#

writeUInt32(value: number): void

Parameters:#

NameType
valuenumber

Returns: void

Defined in: system/binarywriter.ts:73


writeUInt8#

writeUInt8(value: number): void

Parameters:#

NameType
valuenumber

Returns: void

Defined in: system/binarywriter.ts:78