You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
621 B

// decoder.js
exports.Decoder = Decoder;
var EventLite = require("event-lite");
var DecodeBuffer = require("./decode-buffer").DecodeBuffer;
function Decoder(options) {
if (!(this instanceof Decoder)) return new Decoder(options);
DecodeBuffer.call(this, options);
}
Decoder.prototype = new DecodeBuffer();
EventLite.mixin(Decoder.prototype);
Decoder.prototype.decode = function(chunk) {
if (arguments.length) this.write(chunk);
this.flush();
};
Decoder.prototype.push = function(chunk) {
this.emit("data", chunk);
};
Decoder.prototype.end = function(chunk) {
this.decode(chunk);
this.emit("end");
};