Dynamic Stream Throttle
Dynamically limit the speed of a Node stream
Adapted from node-stream-throttle
Usage
Installation npm i dynamic-stream-throttle
getThrottledStream
takes an object with rate parameters and returns a modified stream.Transform
object
The returned Transform
has an updateThrottleOptions
function to change the rate of throttling.
Throttle rate parameters
rateBytes
throttle the stream speed to a number of bytes per secondchunkSizeBytes
control the chunk size that is processed by the stream at each read
Example
const Throttle = ;const Readable = ; // create simple readable streamconst readableStream = { this; }; var bytesPerSecond = 1; //create a stream which throttles output to 1 byte per secondconst throttledStream = Throttle; //pipe readableStream to throttledStream, then stdoutreadableStream; //increase rate every 5 seconds;