Options
All
  • Public
  • Public/Protected
  • All
Menu

A "writable" interface, sufficient to be able to write type and value bytes. Implemented by GrowableBuffer, as well as AppendableStream (a wrapper around a writable stream). All methods can be chained, e.g.

let gb = new GrowableBuffer
gb
  .add(1).add(2)
  .addAll(new Uint8Array([3, 4, 5]))
  .pause()
    .add(0)
    .reset()
  .resume()
console.log(new Uint8Array(gb.toBuffer())) //Uint8Array [ 1, 2, 3, 4, 5 ]

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Readonly Abstract length

length: number

The number of bytes that have been written

Methods

Abstract add

Abstract addAll

  • Adds a contiguous set of bytes after the end of the written data

    Parameters

    • buffer: ArrayBuffer | Uint8Array

      The bytes to add. The byte at position i in buffer will be written to position this.length + i.

    Returns AppendableBuffer

Abstract pause

  • Pauses the writing process, i.e. bytes added are not written to the underlying output until resume is next called and can be cancelled from being written by calling reset.

    If called multiple times, resume and reset only act on bytes added since the most recent pause. Example:

    let gb = new GrowableBuffer
    gb
      .pause()
        .add(1).add(2).add(3)
        .pause()
          .add(4).add(5).add(6)
          .reset() //cancels [4, 5, 6]
        .resume() //resumes []
      .resume() //resumes [1, 2, 3]
    console.log(new Uint8Array(gb.toBuffer())) //Uint8Array [ 1, 2, 3 ]
    

    Returns AppendableBuffer

Abstract reset

Abstract resume

Generated using TypeDoc