"use strict";module.exports=BufferWriter;var Writer=require("./writer");(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util=require("./util/minimal");function BufferWriter(){Writer.call(this)}function writeStringBuffer(r,t,e){r.length<40?util.utf8.write(r,t,e):t.utf8Write?t.utf8Write(r,e):t.write(r,e)}BufferWriter._configure=function(){BufferWriter.alloc=util._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util.Buffer&&util.Buffer.prototype instanceof Uint8Array&&"set"===util.Buffer.prototype.set.name?function(r,t,e){t.set(r,e)}:function(r,t,e){if(r.copy)r.copy(t,e,0,r.length);else for(var i=0;i<r.length;)t[e++]=r[i++]}},BufferWriter.prototype.bytes=function(r){util.isString(r)&&(r=util._Buffer_from(r,"base64"));var t=r.length>>>0;return this.uint32(t),t&&this._push(BufferWriter.writeBytesBuffer,t,r),this},BufferWriter.prototype.string=function(r){var t=util.Buffer.byteLength(r);return this.uint32(t),t&&this._push(writeStringBuffer,t,r),this},BufferWriter._configure();