Creates an instance of BufferScheduler.
A Node.js Readable stream
Buffer size of every maintained buffer
How many buffers can be allocated
An async function scheduled to be triggered when a buffer fully filled with stream data
Concurrency of executing outgoingHandlers (>0)
[Optional] Encoding of Readable stream when it's a string stream
Start the scheduler, will return error when stream of any of the outgoingHandlers returns error.
Generated using TypeDoc
This class accepts a Node.js Readable stream as input, and keeps reading data from the stream into the internal buffer structure, until it reaches maxBuffers. Every available buffer will try to trigger outgoingHandler.
The internal buffer structure includes an incoming buffer array, and a outgoing buffer array. The incoming buffer array includes the "empty" buffers can be filled with new incoming data. The outgoing array includes the filled buffers to be handled by outgoingHandler. Every above buffer size is defined by parameter bufferSize.
NUM_OF_ALL_BUFFERS = BUFFERS_IN_INCOMING + BUFFERS_IN_OUTGOING + BUFFERS_UNDER_HANDLING
NUM_OF_ALL_BUFFERS lesser than or equal to maxBuffers
PERFORMANCE IMPROVEMENT TIPS: