28 lines
629 B
JavaScript
28 lines
629 B
JavaScript
// encode-buffer.js
|
|
|
|
exports.EncodeBuffer = EncodeBuffer;
|
|
|
|
var preset = require("./write-core").preset;
|
|
|
|
var FlexEncoder = require("./flex-buffer").FlexEncoder;
|
|
|
|
FlexEncoder.mixin(EncodeBuffer.prototype);
|
|
|
|
function EncodeBuffer(options) {
|
|
if (!(this instanceof EncodeBuffer)) return new EncodeBuffer(options);
|
|
|
|
if (options) {
|
|
this.options = options;
|
|
if (options.codec) {
|
|
var codec = this.codec = options.codec;
|
|
if (codec.bufferish) this.bufferish = codec.bufferish;
|
|
}
|
|
}
|
|
}
|
|
|
|
EncodeBuffer.prototype.codec = preset;
|
|
|
|
EncodeBuffer.prototype.write = function(input) {
|
|
this.codec.encode(this, input);
|
|
};
|