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