Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PooledBuffer

Package version

This class provides a buffer container which conceptually has no hard size limit. It accepts a capacity, an array of input buffers and the total length of input data. It will allocate an internal "buffer" of the capacity and fill the data in the input buffers into the internal "buffer" serially with respect to the total length. Then by calling PooledBuffer.getReadableStream(), you can get a readable stream assembled from all the data in the internal "buffer".

Hierarchy

  • PooledBuffer

Index

Constructors

Accessors

Methods

Constructors

constructor

  • new PooledBuffer(capacity: number): PooledBuffer
  • new PooledBuffer(capacity: number, buffers: Buffer[], totalLength: number): PooledBuffer
  • Creates an instance of PooledBuffer with given capacity. Internal buffers are allocated but contains no data. Users may call the PooledBuffer.fill method to fill this pooled buffer with data.

    Parameters

    • capacity: number

      Total capacity of the internal buffers

    Returns PooledBuffer

  • Creates an instance of PooledBuffer with given capacity. Internal buffers are allocated and filled with data in the input buffers serially with respect to the total length.

    Parameters

    • capacity: number

      Total capacity of the internal buffers

    • buffers: Buffer[]

      Input buffers containing the data to be filled in the pooled buffer

    • totalLength: number

      Total length of the data to be filled in.

    Returns PooledBuffer

Accessors

size

  • get size(): number

Methods

fill

  • fill(buffers: Buffer[], totalLength: number): void
  • Fill the internal buffers with data in the input buffers serially with respect to the total length and the total capacity of the internal buffers. Data copied will be shift out of the input buffers.

    Parameters

    • buffers: Buffer[]

      Input buffers containing the data to be filled in the pooled buffer

    • totalLength: number

      Total length of the data to be filled in.

    Returns void

getReadableStream

  • getReadableStream(): Readable

Generated using TypeDoc