compound-ex4
Version:
Compound-ex4 - MVC framework for NodeJS (ExpressJs 4 version), fork compoundjs(https://github.com/1602/compound)
17 lines (13 loc) • 364 B
JavaScript
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();
};