Options
All
  • Public
  • Public/Protected
  • All
Menu

  subscribe now with sterfive to access the online-user manual

a BinaryStream can be use to perform sequential read or write inside a buffer. The BinaryStream maintains a cursor up to date as the caller operates on the stream using the various read/write methods. It uses the Little Endian It uses the Little Endian convention.

data can either be:

  • a Buffer , in this case the BinaryStream operates on this Buffer
  • null , in this case a BinaryStream with 1024 bytes is created
  • any data , in this case the object is converted into a binary buffer.

example:

var stream = new BinaryStream(32)
param

Hierarchy

  • BinaryStream

Index

Constructors

constructor

  • Parameters

    • data: number | Buffer

    Returns BinaryStream

Properties

length

length: number

the current position inside the buffer

Methods

readArrayBuffer

  • readArrayBuffer(length: number): Uint8Array
  • method

    readArrayBuffer

    Parameters

    • length: number

    Returns Uint8Array

readByte

  • readByte(): number
  • read a single signed byte (8 bits) from the stream.

    Returns number

    the value read

readByteStream

  • readByteStream(): Buffer
  • read a byte stream to the stream. The method reads the length of the byte array from the stream as a 32 bits integer before reading the byte stream.

    Returns Buffer

readDouble

  • readDouble(): number
  • read a single 64-bit floating point number from the stream.

    Returns number

readFloat

  • readFloat(): number
  • read a single 32-bit floating point number from the stream.

    Returns number

readInt16

  • readInt16(): number
  • read a single signed 16-bit integer from the stream.

    Returns number

readInt8

  • readInt8(): number
  • Returns number

readInteger

  • readInteger(): number
  • read a single signed 32-bit integer from the stream.

    Returns number

readString

  • readString(): string
  • Returns string

readUInt16

  • readUInt16(): number
  • read a single unsigned 16-bit integer from the stream.

    Returns number

readUInt32

  • readUInt32(): number
  • read a single unsigned 32-bit integer from the stream.

    Returns number

readUInt8

  • readUInt8(): number
  • read a single unsigned byte (8 bits) from the stream.

    Returns number

rewind

  • rewind(): void
  • set the cursor to the begining of the stream

    method

    BinaryStream.rewind

    Returns void

writeArrayBuffer

  • writeArrayBuffer(arrayBuf: ArrayBuffer, offset?: number, length?: number): void
  • Parameters

    • arrayBuf: ArrayBuffer

      a buffer or byte array write

    • Optional offset: number

      the offset position (default =0)

    • Optional length: number

      the number of byte to write

    Returns void

writeByteStream

  • writeByteStream(buf: Buffer): void
  • write a byte stream to the stream. The method writes the length of the byte array into the stream as a 32 bits integer before the byte stream.

    Parameters

    • buf: Buffer

      the buffer to write.

    Returns void

writeDouble

  • writeDouble(value: number): void
  • write a single 64 bit floating number to the stream.

    Parameters

    • value: number

      the value to write

    Returns void

writeFloat

  • writeFloat(value: number): void
  • write a single 32 bit floating number to the stream.

    Parameters

    • value: number

      the value to write

    Returns void

writeInt16

  • writeInt16(value: number): void
  • write a single 16 bit signed integer to the stream.

    Parameters

    • value: number

      the value to write

    Returns void

writeInt8

  • writeInt8(value: number): void
  • write a single signed byte (8 bits) to the stream. value must be in the range of [-127,128]

    Parameters

    • value: number

      the value to write

    Returns void

writeInteger

  • writeInteger(value: number): void
  • write a single 32 bit signed integer to the stream.

    Parameters

    • value: number

      the value to write

    Returns void

writeString

  • writeString(value: string): void
  • Parameters

    • value: string

    Returns void

writeUInt16

  • writeUInt16(value: number): void
  • write a single 16 bit unsigned integer to the stream.

    Parameters

    • value: number

      the value to write

    Returns void

writeUInt32

  • writeUInt32(value: number): void
  • write a single 32 bit unsigned integer to the stream.

    Parameters

    • value: number

      the value to write

    Returns void

writeUInt8

  • writeUInt8(value: number): void
  • write a single unsigned byte (8 bits) to the stream.

    Parameters

    • value: number

      the value to write

    Returns void

Generated using TypeDoc