Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BufferInputStream

Sequential reading of values from a given Uint8Array. Loosely inspired by Java's ByteArrayInputStream.

Hierarchy

  • BufferInputStream

Implements

Index

Constructors

constructor

  • Construct an input stream from a Uint8Array

    Parameters

    • buffer: Uint8Array

      The source Uint8Array.

    Returns BufferInputStream

Properties

Readonly buffer

buffer: Uint8Array

The buffer to read from

Readonly count

count: number

The number of bytes in the buffer

pos

pos: number

The current reading position

Methods

peek

  • peek(): number
  • Returns the next byte in the input stream, without extracting it.

    Returns number

    The byte that was read, or -1 if the stream is exhausted.

read

  • read(): number
  • Read one byte.

    Returns number

    The byte that was read, or -1 if the stream is exhausted.

readInt32

  • readInt32(): number
  • Read a signed, big-endian 32-bit integer.

    Returns number

    the number that has been read.

readInt64

  • readInt64(): Long
  • Read a signed, big-endian 64-bit long.

    Returns Long

    the number that has been read.

readInt8

  • readInt8(): number
  • Read a signed 8-bit integer.

    Returns number

    the number that has been read.

readMany

  • readMany(length: number): Uint8Array
  • Read a specified amount of bytes.

    If the length is greater than the remaining number of bytes, this function will read up to the last available byte in the buffer.

    throws

    will throw an OutOfBounds error if length is a negative number.

    Parameters

    • length: number

      the number of bytes you wish to read.

    Returns Uint8Array

    the bytes that have been read

readUntil

  • readUntil(delim: number): Uint8Array
  • Read until a specified byte (delimiter) is found.

    The buffer position is updated to point to just after the delimiter.

    If the delimiter can't be found, then return all bytes until the end of the buffer.

    Parameters

    • delim: number

      the delimiter byte

    Returns Uint8Array

    a buffer containing the bytes up to but not including the delimiter byte.

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.