debounce-stream
This stream takes in events of data and only passes the event on once in a given interval.
Once the interval is over, it outputs the last value that was passed in
Installing
npm install --save debounce-stream
API
DebounceStream(interval,[options])
Arguments
interval
(Number): Interval for how frequently to output data[options]
(Object): Options that get passed to a stream constructor (In case you want objectMode
)
Returns
(DuplexStream): Pipe stuff into it, and it'll come out debounced
Example
var DebounceStream = require("debounce-stream");
var IntervalStream = require("interval-stream");
var StreamArray = require("stream-array");
var stdout = require("stdout")();
var data = ["foo\n", "bar\n", "bazz\n", "fizz\n"];
data = data.concat(data).concat(data);
StreamArray(data)
.pipe(IntervalStream(1000))
.pipe(DebounceStream(2000))
.pipe(stdout);