write-limiter
A node.js stream implementation that takes a stream and throttles the writes in a time-based fashion.
Install
npm install write-limiter
Usage
var Limiter = ;var limiter = 500;// orvar otherLimiter = interval: 500 objectMode: true
Constructor(Number|Object): The constructor takes either a single number
argument or an object
with an interval
property. Passing an object
allows for passing along node.js Stream
arguments to the underlying through stream parent class.
The provided number
or interval
property represents how long, in milliseconds, to wait between writes.
Example
Using write-limiter
to limit jpegs coming from an mjpeg-consumer stream to, at-most, 5 frames per second:
var Limiter = ; var request = ;var MjpegConsumer = ;var FileOnWrite = ; var writer = path: './video' ext: '.jpg';var consumer = ; var limiter = 200; ;