UNPKG

406 BJavaScriptView Raw
1// https://github.com/andrewrk/node-stream-counter
2
3module.exports = ByteCounter;
4
5var Writable = require('stream').Writable;
6var util = require('util');
7
8util.inherits(ByteCounter, Writable);
9function ByteCounter(options) {
10 Writable.call(this, options);
11 this.bytes = 0;
12}
13
14ByteCounter.prototype._write = function(chunk, encoding, cb) {
15 this.bytes += chunk.length;
16 this.emit('progress');
17 cb();
18};
\No newline at end of file