Ratelimited streams for nodejs
A Node.js stream you can insert into a stream pipe to limit its throughput. Throughput is measured by overlapping sliding windows and buffered it the limit is exceeded. Also backpressure is used to throttle the writer.
npm install streambrake
var StreamBrake = require'streambrake'fs = require'fs';fscreateReadStream'/dev/random'pipe128000pipefscreateWriteStream'slowRandom';
Creates a readable and writable stream which will emit no more
bytesPerSecond bytes per second.
measurementsPerSecond is an optional value of how often per second
to measure throughput and emit queued data. Default is 5.
- node-brake which basically does the same, but is by substack, and thus good. I wish I had seen it before I starting writing this module.