28 lines
623 B
JavaScript
28 lines
623 B
JavaScript
// decode-buffer.js
|
|
|
|
exports.DecodeBuffer = DecodeBuffer;
|
|
|
|
var preset = require("./read-core").preset;
|
|
|
|
var FlexDecoder = require("./flex-buffer").FlexDecoder;
|
|
|
|
FlexDecoder.mixin(DecodeBuffer.prototype);
|
|
|
|
function DecodeBuffer(options) {
|
|
if (!(this instanceof DecodeBuffer)) return new DecodeBuffer(options);
|
|
|
|
if (options) {
|
|
this.options = options;
|
|
if (options.codec) {
|
|
var codec = this.codec = options.codec;
|
|
if (codec.bufferish) this.bufferish = codec.bufferish;
|
|
}
|
|
}
|
|
}
|
|
|
|
DecodeBuffer.prototype.codec = preset;
|
|
|
|
DecodeBuffer.prototype.fetch = function() {
|
|
return this.codec.decode(this);
|
|
};
|