stream-bouncer
Create a queue of streams and have the bouncer make sure they stay in line!
Example
var fs = ;var StreamBouncer = ; var bouncer = streamsPerTick: 1 poll: 1000; bouncer; var counter = 1; bouncer; bouncer; for var i = 0; i < 10; i++ bouncer;
Details
A stream module that allows you to enqueue a bunch of streams without worrying about defering the piping. Just queue up as many streams as you want and let the module take care of the piping for you!
Methods
var StreamBouncer = require('stream-bouncer');
var bouncer = new StreamBouncer();
Create a new instance of a bouncer.
Use it
bouncer;
Events
bouncer.on('start', function(str){...});
Fires when one of the streams in the queue starts, passes a stream to the callback. str is the stream.source object.
bouncer.on('close', function(str){...});
fires when one of the streams in the queue finishes, passes a stream to the callback. str is the stream.source object.
bouncer.on('count', function(count){...});
fires when the number of streams in the queue changes, passes a number to the callback.
bouncer.on('error', function(err){...});
forwards an error object to the cb.
Options
var defaultOptions = streamsPerTick: 5 //how many simultaneous streams to process per tick poll: 250 //how long to wait before process {count} # of streams in ms throttle: false // throttle the streams speed. speed: null //only required if throttling is active
example of overloading options
var bouncer = streamsPerTick: 1 poll: 1000 throttle: true speed: 2 * 1024 * 1024 //max 2 MB/s tranfer;
Install
With npm do:
npm install stream-bouncer
to get the library.
License
MIT