Skip to main content
Module

x/binary_reader/binary_reader.ts>BinaryReader

A Deno module and helper class that provides an easy way to read different types from a binary array buffer.
Latest
class BinaryReader
import { BinaryReader } from "https://deno.land/x/binary_reader@v0.1.6/binary_reader.ts";

Constructors

new
BinaryReader(buffer: Uint8Array)

Properties

private
dataView: DataView
readonly
position: number

Returns the current position in the buffer.

Methods

readBigInt64(littleEndian?: boolean): bigint

Reads a signed 64-bit integer (long long) from the current position in the buffer.

readBigUint64(littleEndian?: boolean): bigint

Reads an unsigned 64-bit integer (unsigned long long) from the current position in the buffer.

readBytes(length: number): Uint8Array

Reads length unsigned 8-bit integers from the current position in the buffer.

readChar(): string

Reads a single utf8 encoded character from the current position in the buffer.

readFloat32(littleEndian?: boolean): number

Reads a signed 32-bit float (float) from the current position in the buffer.

readFloat64(littleEndian?: boolean): number

Reads a signed 64-bit float (double) from the current position in the buffer.

readInt16(littleEndian?: boolean): number

Reads a signed 16-bit integer (short) from the current position in the buffer.

readInt32(littleEndian?: boolean): number

Reads a signed 32-bit integer (long) from the current position in the buffer.

readInt8(): number

Reads a signed 8-bit integer (byte) from the current position in the buffer.

readString(length: number): string

Reads a utf8 encoded string from the current position in the buffer.

readUint16(littleEndian?: boolean): number

Reads an unsigned 16-bit integer (unsigned short) from the current position in the buffer.

readUint32(littleEndian?: boolean): number

Reads an unsigned 32-bit integer (unsigned long) from the current position in the buffer.

readUint8(): number

Reads an unsigned 8-bit integer (byte) from the current position in the buffer.

rewind(numBytes: number): void

Rewinds the buffer/DataView byteOffset by numBytes bytes.

seek(position: number): void

Moves the buffer/DataView byteOffset to the specified position.