GT2/GT2-iOS/node_modules/stream-counter/index.js

17 lines
364 B
JavaScript
Raw Normal View History

2018-02-12 17:26:06 +00:00
module.exports = ByteCounter;
var Writable = require('readable-stream').Writable;
var util = require('util');
util.inherits(ByteCounter, Writable);
function ByteCounter(options) {
Writable.call(this, options);
this.bytes = 0;
}
ByteCounter.prototype._write = function(chunk, encoding, cb) {
this.bytes += chunk.length;
this.emit('progress');
cb();
};