Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BinaryReader

Reader for binary data. Supports reading single bits, bytes, characters and strings and more.

Hierarchy

  • BinaryReader

Index

Constructors

constructor

  • new BinaryReader(data: ArrayLike<number>, offset?: number, size?: number): BinaryReader
  • Creates a new binary reader for the given data.

    Parameters

    • data: ArrayLike<number>

      The data array to read from.

    • Default value offset: number = 0

      Optional start offset. Defaults to 0.

    • Default value size: number = data.length

      Optional maximum number of bytes to read from data array. Defaults to size of data array.

    Returns BinaryReader

Methods

getBitIndex

  • getBitIndex(): number

getByteIndex

  • getByteIndex(): number
  • Returns the current byte index.

    Returns number

    The current byte index.

hasData

  • hasData(): boolean
  • Checks if there is more data to read. If this method returns false then there is no more data and the next read operation results in an errors.

    Returns boolean

    True if there is still data to read, false if not.

readBit

  • readBit(): number

readChar

  • readChar(): string
  • Reads a single character and returns it.

    Returns string

    The read character.

readString

  • readString(len: number): string
  • Reads a string with the given length and returns it.

    Parameters

    • len: number

    Returns string

    The read string.

readUint16

  • readUint16(): number
  • Reads an unsigned 16 bit value and returns it.

    Returns number

    The read value.

readUint32

  • readUint32(): number
  • Reads an unsigned 32 bit value and returns it.

    Returns number

    The read value.

readUint8

  • readUint8(): number
  • Reads an unsigned 8 bit value (byte) and returns it.

    Returns number

    The read value.

readUint8s

  • readUint8s(len: number): number[]
  • Reads the specified number of unsigned 8 bit values and returns it.

    Parameters

    • len: number

      The number of bytes to read.

    Returns number[]

    The read bytes.

sync

  • sync(): void
  • Synchronizes the reader so it points to a full byte if it currently doesn't.

    Returns void

Generated using TypeDoc