0.0.2 • Published 9 years ago

stream-bandwidth v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Stream bandwidth

This modules is useful to get the stream bandwidth over the time

How to use it

You just use it as a PassThrough stream and listen 2 events progress and done

var rs = fs.createReadStream('/dev/zero');
var ws = fs.createWriteStream('/dev/null');

var bw = new Bandwidth();

bw.on('done', function(data) {
    console.log(data);
})

bw.on('progress', function(data) {
    console.log(data);
})

rs.pipe(bw).pipe(ws);

Events

progress

This event is called every second with an Object with the number of bytes that was passed through the stream in the last second

{
    "bytes": 123456
}

done

This event is called when all the data is flushed with an object with the total bytes that was passed through the stream

{
    "total_bytes": 123456
}

License

MIT