Class BinaryStream

Represents a binary stream for reading and writing data.

Constructors

Properties

Accessors

Methods

Constructors

  • Creates a new BinaryStream instance.

    Parameters

    • buffer: Uint8Array | number[]

      The initial buffer for the stream.

    • Optional offset: number

      The initial offset for the stream.

    Returns BinaryStream

  • Parameters

    Returns BinaryStream

  • Parameters

    • size: number

    Returns BinaryStream

  • Returns BinaryStream

Properties

offset: number
readBigUInt64: ((offset?) => bigint)

Reads an unsigned 64-bit big-endian integer from the binary stream.

Type declaration

    • (offset?): bigint
    • Parameters

      • Optional offset: number

      Returns bigint

Returns

The unsigned 64-bit big-endian integer read from the binary stream.

readBoolean: ((offset?) => boolean)

Reads a boolean value.

Type declaration

    • (offset?): boolean
    • Parameters

      • Optional offset: number

      Returns boolean

Returns

boolean value.

readByte: ((offset?) => number)

Reads an unsigned/signed byte.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

        The optional offset to read from.

      Returns number

Returns

The read byte.

readDouble: ((offset?) => number)

Reads an 8-byte floating-point number in big-endian format from the binary stream.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The 8-byte floating-point number read from the binary stream.

readDoubleBE: ((offset?) => number)

Reads an 8-byte floating-point number in big-endian format from the binary stream.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The 8-byte floating-point number read from the binary stream.

readDoubleLE: ((offset?) => number)

Reads an 8-byte floating-point number in little-endian format from the binary stream.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The 8-byte floating-point number read from the binary stream.

readFloat: ((offset?) => number)

Reads a 32-bit floating point number in big-endian format from the binary stream.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The 32-bit floating point number read from the binary stream.

readFloat32: ((offset?) => number)

Reads a 32-bit floating point number in big-endian format from the binary stream.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The 32-bit floating point number read from the binary stream.

readFloat64: ((offset?) => number)

Reads an 8-byte floating-point number in big-endian format from the binary stream.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The 8-byte floating-point number read from the binary stream.

readFloatBE: ((offset?) => number)

Reads a 32-bit floating point number in big-endian format from the binary stream.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The 32-bit floating point number read from the binary stream.

readFloatLE: ((offset?) => number)

Reads a 32-bit floating-point number in little-endian format from the binary stream.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The 32-bit floating-point number read from the binary stream.

readInt: ((offset?) => number)

Reads a 32-bit signed big-endian number

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

readInt16: ((offset?) => number)

Reads a 16-bit signed big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 16-bit signed big-endian number.

readInt32: ((offset?) => number)

Reads a 32-bit signed big-endian number

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

readIntBE: ((offset?) => number)

Reads a 32-bit signed big-endian number

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

readIntLE: ((offset?) => number)

Reads a 32-bit signed little-endian number

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

readLong: ((offset?) => bigint)

Reads an unsigned 64-bit big-endian integer from the binary stream.

Type declaration

    • (offset?): bigint
    • Parameters

      • Optional offset: number

      Returns bigint

Returns

The unsigned 64-bit big-endian integer read from the binary stream.

readLongBE: ((offset?) => bigint)

Reads an unsigned 64-bit big-endian integer from the binary stream.

Type declaration

    • (offset?): bigint
    • Parameters

      • Optional offset: number

      Returns bigint

Returns

The unsigned 64-bit big-endian integer read from the binary stream.

readLongLE: ((offset?) => bigint)

Reads an unsigned 64-bit little-endian integer from the binary stream.

Type declaration

    • (offset?): bigint
    • Parameters

      • Optional offset: number

      Returns bigint

Returns

The unsigned 64-bit little-endian integer read from the binary stream.

readShort: ((offset?) => number)

Reads a 16-bit signed big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 16-bit signed big-endian number.

readShortBE: ((offset?) => number)

Reads a 16-bit signed big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 16-bit signed big-endian number.

readShortLE: ((offset?) => number)

Reads a 16-bit signed little-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 16-bit signed little-endian number.

readTriad: ((offset?) => number)

Reads a 3-byte big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 3-byte big-endian number.

readUInt: ((offset?) => number)

Reads a 32-bit unsigned big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 32-bit unsigned big-endian number.

readUInt16: ((offset?) => number)

Reads a 16-bit unsigned big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 16-bit unsigned big-endian number.

readUInt32: ((offset?) => number)

Reads a 32-bit unsigned big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 32-bit unsigned big-endian number.

readUIntBE: ((offset?) => number)

Reads a 32-bit unsigned big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 32-bit unsigned big-endian number.

readUIntLE: ((offset?) => number)

Reads a 32-bit unsigned little-endian number

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

readUShort: ((offset?) => number)

Reads a 16-bit unsigned big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 16-bit unsigned big-endian number.

readUShortBE: ((offset?) => number)

Reads a 16-bit unsigned big-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 16-bit unsigned big-endian number.

readUShortLE: ((offset?) => number)

Reads a 16-bit unsigned little-endian number.

Type declaration

    • (offset?): number
    • Parameters

      • Optional offset: number

      Returns number

Returns

The read 16-bit unsigned little-endian number.

view: DataView
writeBigUInt64: ((v, offset?) => this)

Writes an unsigned 64-bit big-endian integer to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: bigint
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeBoolean: ((v, offset?) => this)

Writes a boolean value.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: boolean
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeByte: ((v, offset?) => this)

Writes an unsigned/signed byte.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number

        The byte to write.

      • Optional offset: number

        The optional offset to write at.

      Returns this

Returns

The updated BinaryStream instance.

writeDouble: ((v, offset?) => this)

Writes an 8-byte floating-point number in big-endian format to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeDoubleBE: ((v, offset?) => this)

Writes an 8-byte floating-point number in big-endian format to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeDoubleLE: ((v, offset?) => this)

Writes an 8-byte floating-point number in little-endian format to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeFloat: ((v, offset?) => this)

Writes a 32-bit floating-point number in big-endian format to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeFloat32: ((v, offset?) => this)

Writes a 32-bit floating-point number in big-endian format to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeFloat64: ((v, offset?) => this)

Writes an 8-byte floating-point number in big-endian format to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeFloatBE: ((v, offset?) => this)

Writes a 32-bit floating-point number in big-endian format to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeFloatLE: ((v, offset?) => this)

Writes a 32-bit floating-point number in little-endian format to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeInt: ((v, offset?) => this)

Writes a 32-bit signed big-endian number

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

writeInt16: ((v, offset?) => this)

Writes a 16-bit signed big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeInt32: ((v, offset?) => this)

Writes a 32-bit signed big-endian number

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

writeIntBE: ((v, offset?) => this)

Writes a 32-bit signed big-endian number

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

writeIntLE: ((v) => this)

Writes a 32-bit signed little-endian number

Type declaration

    • (v): this
    • Parameters

      • v: number

      Returns this

writeLong: ((v, offset?) => this)

Writes an unsigned 64-bit big-endian integer to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: bigint
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeLongBE: ((v, offset?) => this)

Writes an unsigned 64-bit big-endian integer to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: bigint
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeLongLE: ((v, offset?) => this)

Writes an unsigned 64-bit little-endian integer to the binary stream.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: bigint
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeShort: ((v, offset?) => this)

Writes a 16-bit signed big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeShortBE: ((v, offset?) => this)

Writes a 16-bit signed big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeShortLE: ((v, offset?) => this)

Writes a 16-bit signed little-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeTriad: ((v, offset?) => this)

Writes a 3-byte big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeUInt: ((v, offset?) => this)

Writes a 32-bit unsigned big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeUInt16: ((v, offset?) => this)

Writes a 16-bit unsigned big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeUInt32: ((v, offset?) => this)

Writes a 32-bit unsigned big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeUIntBE: ((v, offset?) => this)

Writes a 32-bit unsigned big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeUIntLE: ((v, offset?) => this)

Writes a 32-bit unsigned little-endian number

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

writeUShort: ((v, offset?) => this)

Writes a 16-bit unsigned big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeUShortBE: ((v, offset?) => this)

Writes a 16-bit unsigned big-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

writeUShortLE: ((v, offset?) => this)

Writes a 16-bit unsigned little-endian number.

Type declaration

    • (v, offset?): this
    • Parameters

      • v: number
      • Optional offset: number

      Returns this

Returns

The updated BinaryStream instance.

Accessors

  • get buffer(): Uint8Array
  • Gets a copy of the underlying ArrayBuffer as a Uint8Array.

    Returns Uint8Array

    A copy of the ArrayBuffer.

  • get length(): number
  • Gets the size of the buffer.

    Returns number

    The size of the buffer.

Methods

  • Creates a Blob from the buffer.

    Parameters

    • Optional type: string

      The MIME type of the Blob.

    Returns Blob

    The created Blob object.

  • Checks if the current stream is equal to another stream or Uint8Array.

    Parameters

    Returns boolean

    True if the streams are equal, false otherwise.

  • Checks if the current offset has reached the end of the binary stream.

    Returns boolean

    A boolean indicating whether the end of the stream has been reached.

  • Flips the binary stream by resetting the offset to 0.

    Returns this

    The updated BinaryStream instance.

  • Gets the underlying DataView of the stream.

    Returns DataView

    The DataView object.

  • Gets the amount of remaining bytes that can be read.

    Returns number

    The number of remaining bytes.

  • Increases the offset of the stream and returns the start and end offsets.

    Parameters

    • length: number

      The length to increase the offset by.

    • Optional offset: number

      The optional offset to set.

    Returns {
        end: number;
        start: number;
    }

    An object containing the start and end offsets.

    • end: number
    • start: number
  • Reads a set of bytes from the buffer.

    Parameters

    • length: number

      The number of bytes to read.

    • Optional offset: number

      The optional offset to read from.

    Returns Uint8Array

    A Uint8Array containing the read bytes.

    Throws

    RangeError if the read operation exceeds the buffer length.

  • Reads an Internet address from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns InternetAddress

    An object representing the Internet address, including the address, port, and version.

  • Reads an unsigned 64-bit big-endian integer from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns bigint

    The unsigned 64-bit big-endian integer read from the binary stream.

  • Reads an unsigned 64-bit little-endian integer from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns bigint

    The unsigned 64-bit little-endian integer read from the binary stream.

  • Reads a boolean value.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns boolean

    boolean value.

  • Reads a 32-bit floating point number in big-endian format from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The 32-bit floating point number read from the binary stream.

  • Reads a 32-bit floating-point number in little-endian format from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The 32-bit floating-point number read from the binary stream.

  • Reads an 8-byte floating-point number in big-endian format from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from. If not provided, the current offset will be used.

    Returns number

    The 8-byte floating-point number read from the binary stream.

  • Reads an 8-byte floating-point number in little-endian format from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The 8-byte floating-point number read from the binary stream.

  • Reads a 16-bit signed big-endian number.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read 16-bit signed big-endian number.

  • Reads a 16-bit signed little-endian number.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read 16-bit signed little-endian number.

  • Reads a 32-bit signed big-endian number

    Parameters

    • Optional offset: number

    Returns number

  • Reads a 32-bit signed little-endian number

    Parameters

    • Optional offset: number

    Returns number

  • Reads a signed 8-bit number.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read signed 8-bit number.

  • Reads the remaining amount of bytes.

    Returns Uint8Array

    A Uint8Array containing the remaining bytes.

  • Reads a string from the buffer

    Parameters

    • Optional offset: number

    Returns string

  • Reads a 3-byte big-endian number.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read 3-byte big-endian number.

  • Reads a 3-byte little-endian number.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read 3-byte little-endian number.

  • Reads a 16-bit unsigned big-endian number.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read 16-bit unsigned big-endian number.

  • Reads a 16-bit unsigned little-endian number.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read 16-bit unsigned little-endian number.

  • Reads a 32-bit unsigned big-endian number.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read 32-bit unsigned big-endian number.

  • Reads a 32-bit unsigned little-endian number

    Parameters

    • Optional offset: number

    Returns number

  • Reads an unsigned 8-bit number.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read unsigned 8-bit number.

  • Reads an unsigned variable-length integer from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The unsigned variable-length integer read from the stream.

  • Reads an unsigned variable-length long integer from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns bigint

    The unsigned variable-length long integer read from the stream.

  • Reads a variable-length integer from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns number

    The read variable-length integer.

  • Reads a variable-length long integer from the binary stream.

    Parameters

    • Optional offset: number

      The optional offset to read from.

    Returns bigint

    The read long integer value.

  • Resets the stream's buffer.

    Returns this

    The updated BinaryStream instance.

  • Resizes the buffer of the stream.

    Parameters

    • size: number

      The new size of the buffer.

    • Optional canShrink: boolean

      Whether the buffer can be shrunk.

    Returns this

    The updated BinaryStream instance.

  • Sets the buffer and/or offset of the stream.

    Parameters

    • buffer: Uint8Array | number[]

      The buffer to set.

    • Optional offset: number

      The optional offset to set.

    Returns this

    The updated BinaryStream instance.

  • Splits the binary stream into chunks of the specified number of bytes.

    Parameters

    • bytes: number

      The number of bytes in each chunk.

    Returns Uint8Array[]

    An array of Uint8Array chunks.

  • Converts the binary stream to a string.

    Parameters

    • Optional encoding: string

      The encoding to use.

    Returns string

    The string representation of the binary stream.

  • Writes data to the stream's buffer.

    Parameters

    • buffer: Uint8Array | number[]

      The data to write.

    • Optional offset: number

      The optional offset to write the data at.

    Returns this

    The updated BinaryStream instance.

  • Writes an Internet address to the binary stream.

    Parameters

    • address: InternetAddress

      The Internet address to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes an unsigned 64-bit big-endian integer to the binary stream.

    Parameters

    • v: bigint

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Writes an unsigned 64-bit little-endian integer to the binary stream.

    Parameters

    • v: bigint

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Writes a boolean value.

    Parameters

    • v: boolean

      The boolean value to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes a 32-bit floating-point number in big-endian format to the binary stream.

    Parameters

    • v: number

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Writes a 32-bit floating-point number in little-endian format to the binary stream.

    Parameters

    • v: number

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Writes an 8-byte floating-point number in big-endian format to the binary stream.

    Parameters

    • v: number

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Writes an 8-byte floating-point number in little-endian format to the binary stream.

    Parameters

    • v: number

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Writes a 16-bit signed big-endian number.

    Parameters

    • v: number

      The 16-bit signed big-endian number to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes a 16-bit signed little-endian number.

    Parameters

    • v: number

      The 16-bit signed little-endian number to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes a 32-bit signed big-endian number

    Parameters

    • v: number
    • Optional offset: number

    Returns this

  • Writes a 32-bit signed little-endian number

    Parameters

    • v: number

    Returns this

  • Writes a signed 8-bit number.

    Parameters

    • v: number

      The signed 8-bit number to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes a string to the buffer

    Parameters

    • str: string
    • Optional offset: number

    Returns this

  • Writes a 3-byte big-endian number.

    Parameters

    • v: number

      The 3-byte big-endian number to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes a 3-byte little-endian number.

    Parameters

    • v: number

      The 3-byte little-endian number to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes a 16-bit unsigned big-endian number.

    Parameters

    • v: number

      The 16-bit unsigned big-endian number to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes a 16-bit unsigned little-endian number.

    Parameters

    • v: number

      The 16-bit unsigned little-endian number to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes a 32-bit unsigned big-endian number.

    Parameters

    • v: number

      The 32-bit unsigned big-endian number to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes a 32-bit unsigned little-endian number

    Parameters

    • v: number
    • Optional offset: number

    Returns this

  • Writes an unsigned 8-bit number.

    Parameters

    • v: number

      The unsigned 8-bit number to write.

    • Optional offset: number

      The optional offset to write at.

    Returns this

    The updated BinaryStream instance.

  • Writes an unsigned variable-length integer to the binary stream.

    Parameters

    • v: number

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Writes an unsigned variable-length long integer to the binary stream.

    Parameters

    • v: bigint

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Writes a variable-length integer to the binary stream.

    Parameters

    • v: number

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Writes a variable-length long integer to the binary stream.

    Parameters

    • v: bigint

      The value to write.

    • Optional offset: number

      The optional offset at which to write the value.

    Returns this

    The updated BinaryStream instance.

  • Creates a new BinaryStream from the specified buffer.

    Parameters

    Returns BinaryStream

    The created BinaryStream instance.

  • Creates a new BinaryStream from the specified string.

    Parameters

    • str: string

      The string to create the BinaryStream from.

    • encoding: "utf8" | "hex" | "binary" | "latin1"

      The encoding to use.

    Returns BinaryStream

    The created BinaryStream instance.