brake
throttle a stream with backpressure
example
Take a bulk readable stream stream and throttle it down to 10 bytes per second:
var Readable = Readable;var brake = ;var bulk = ;bulk {};bulk;bulk;bulk;
There's also a brake
command as part of this package:
$ brake 30 readme.markdown | pv > /dev/null
1.53kB 0:00:51 [30.3B/s] [ <=> ]
methods
var brake =
var b = brake(rate, opts)
Return a transform stream b
that applies
backpressure when more data than the rate allows is written.
-
opts.rate
- how many bytes to emit for each interval of lengthperiod
-
opts.period
- How often to check the output length in milliseconds. Default value: 1000.
If opts
is a number, its value will be used for the opts.period
.
usage
usage:
brake OPTIONS [rate] {file | -}
brake OPTIONS [rate] [period] {file | -}
brake OPTIONS {file | -}
OPTIONS:
-r, --rate How many bytes to emit for each interval of length `period`
-p, --period How often to check the output length in milliseconds.
default value: 1000
install
To get the library, with npm do:
npm install brake
To get the command, with npm do:
npm install -g brake
license
MIT