415gotit
This commit is contained in:
26
node_modules/msgpack-lite/lib/encoder.js
generated
vendored
Normal file
26
node_modules/msgpack-lite/lib/encoder.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// encoder.js
|
||||
|
||||
exports.Encoder = Encoder;
|
||||
|
||||
var EventLite = require("event-lite");
|
||||
var EncodeBuffer = require("./encode-buffer").EncodeBuffer;
|
||||
|
||||
function Encoder(options) {
|
||||
if (!(this instanceof Encoder)) return new Encoder(options);
|
||||
EncodeBuffer.call(this, options);
|
||||
}
|
||||
|
||||
Encoder.prototype = new EncodeBuffer();
|
||||
|
||||
EventLite.mixin(Encoder.prototype);
|
||||
|
||||
Encoder.prototype.encode = function(chunk) {
|
||||
this.write(chunk);
|
||||
this.emit("data", this.read());
|
||||
};
|
||||
|
||||
Encoder.prototype.end = function(chunk) {
|
||||
if (arguments.length) this.encode(chunk);
|
||||
this.flush();
|
||||
this.emit("end");
|
||||
};
|
||||
Reference in New Issue
Block a user