Class: BinaryReader#

Reads primitive types from a packed 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#

  • BinaryReader

Constructors#

constructor#

new BinaryReader(binaryString: string): BinaryReader

Parameters:#

NameType
binaryStringstring

Returns: BinaryReader

Defined in: system/binaryreader.ts:32

Properties#

data#

• Readonly data: string

Defined in: system/binaryreader.ts:31

Methods#

read#

read(fmt: string, size: number): any

Parameters:#

NameType
fmtstring
sizenumber

Returns: any

Defined in: system/binaryreader.ts:38


readDouble#

readDouble(): number

Returns: number

Defined in: system/binaryreader.ts:47


readFloat#

readFloat(): number

Returns: number

Defined in: system/binaryreader.ts:51


readInt16#

readInt16(): number

Returns: number

Defined in: system/binaryreader.ts:55


readInt32#

readInt32(): number

Returns: number

Defined in: system/binaryreader.ts:59


readInt8#

readInt8(): number

Returns: number

Defined in: system/binaryreader.ts:63


readString#

readString(): string

Returns: string

Defined in: system/binaryreader.ts:67


readUInt16#

readUInt16(): number

Returns: number

Defined in: system/binaryreader.ts:73


readUInt32#

readUInt32(): number

Returns: number

Defined in: system/binaryreader.ts:77


readUInt8#

readUInt8(): number

Returns: number

Defined in: system/binaryreader.ts:81