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,KAAK,CAAC,OAAQ,MAAO,MAAO,EAAO,MAAO,IACrD,KAAK,KAAO,EACL,IACT,EAEA,UAAU,UAAU,OAAS,WAC3B,OAAO,KAAK,GACd,EAEA,UAAU,UAAU,OAAS,WAC3B,IAAI,EAAM,IAAI,OAAO,KAAK,KACtB,EAAS,EA+Bb,OA9BA,KAAK,MAAM,SAAQ,SAAS,GAC1B,GAAG,EAAK,OACN,EAAK,OAAO,KAAK,EAAK,EAAQ,GAC9B,GAAU,EAAK,OAAO,YACjB,GAAiB,SAAd,EAAK,MAAkB,CAE/B,IAAI,EAAI,KAAK,IAAI,EAAK,OAClB,EAAwB,GAAnB,EAAK,OAAS,GACnB,EAAI,KAAK,KAAK,KAAK,IAAI,GAAK,KAAK,KACjC,EAAI,GAAK,GAAK,GAIlB,EAAI,KAAa,GAAK,EAAQ,EAAI,EAClC,EAAI,MAAkB,EAAJ,IAAU,EAAQ,EAAI,MACxC,EAAI,KAAY,EAChB,EAAI,KAAY,EAChB,GAAU,CACZ,MAGE,IAFA,IAAI,EAAsB,QAAhB,EAAK,OACX,EAAK,EAAM,CAAqB,GAAlB,EAAK,MAAQ,IAAS,GAAM,CAAE,EAAG,GAC3C,EAAE,EAAG,GAAI,EAAM,GAAK,EAAI,EAAiB,EAAb,EAAK,MAAW,GAAK,EAAG,GAExD,EAAI,KADH,GAAK,GACoD,IAA1C,KAAK,MAAM,EAAK,MAAQ,KAAK,IAAI,EAAG,IAEnC,EAAK,OAAS,EAAK,GAI5C,IACO,CACT,EAEA,UAAU,UAAU,MAAQ,SAAS,GACnC,EAAO,MAAM,KAAK,SACpB","file":"/npm/bufferput@0.1.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/bufferput@0.1.3/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","function BufferPut () {\n  this.words = [];\n  this.len = 0;\n};\nmodule.exports = BufferPut;\n\nBufferPut.prototype.put = function(buf) {\n  this.words.push({buffer: buf});\n  this.len += buf.length;\n  return this;\n};\n\nBufferPut.prototype.insert = function(bufferput) {\n  this.words = this.words.concat(bufferput.words);\n  this.len += bufferput.len;\n}\n\nBufferPut.prototype.word8 = function(x) {\n  this.words.push({bytes: 1, value: x});\n  this.len += 1;\n  return this;\n};\n\nBufferPut.prototype.floatle = function(x) {\n  this.words.push({bytes: 'float', endian: 'little', value: x});\n  this.len += 4;\n  return this;\n};\n\nBufferPut.prototype.varint = function(i) {\n  if(i < 0xFD) {\n    this.word8(i);\n  } else if(i <= 1<<16) {\n    this.word8(0xFD);\n    this.word16le(i);\n  } else if(i <= 1<<32) {\n    this.word8(0xFE);\n    this.word32le(i);\n  } else {\n    this.word8(0xFF);\n    this.word64le(i);\n  }\n};\n\n[8, 16, 24, 32, 64].forEach(function(bits) {\n  BufferPut.prototype['word'+bits+'be'] = function(x) {\n    this.words.push({endian: 'big', bytes: bits / 8, value: x});\n    this.len += bits / 8;\n    return this;\n  };\n\n  BufferPut.prototype['word'+bits+'le'] = function(x) {\n    this.words.push({endian: 'little', bytes: bits / 8, value: x});\n    this.len += bits / 8;\n    return this;\n  };\n});\n\nBufferPut.prototype.pad = function(bytes) {\n  this.words.push({endian: 'big', bytes: bytes, value: 0});\n  this.len += bytes;\n  return this;\n};\n\nBufferPut.prototype.length = function() {\n  return this.len;\n};\n\nBufferPut.prototype.buffer = function () {\n  var buf = new Buffer(this.len);\n  var offset = 0;\n  this.words.forEach(function(word) {\n    if(word.buffer) {\n      word.buffer.copy(buf, offset, 0);\n      offset += word.buffer.length;\n    } else if(word.bytes == 'float') {\n      // s * f * 2^e\n      var v = Math.abs(word.value);\n      var s = (word.value >= 0) * 1;\n      var e = Math.ceil(Math.log(v) / Math.LN2);\n      var f = v / (1 << e);\n\n      // s:1, e:7, f:23\n      // [seeeeeee][efffffff][ffffffff][ffffffff]\n      buf[offset++] = (s << 7) & ~~(e / 2);\n      buf[offset++] = ((e & 1) << 7) & ~~(f / (1 << 16));\n      buf[offset++] = 0;\n      buf[offset++] = 0;\n      offset += 4;\n    } else {\n      var big = word.endian === 'big';\n      var ix = big ? [ (word.bytes - 1) * 8, -8 ] : [ 0, 8 ];\n      for(var i=ix[0]; big ? i >= 0 : i < word.bytes * 8; i += ix[1]) {\n        if(i >= 32) {\n          buf[offset++] = Math.floor(word.value / Math.pow(2, i)) & 0xff;\n        } else {\n          buf[offset++] = (word.value >> i) & 0xff;\n        }\n      }\n    }\n  });\n  return buf;\n};\n\nBufferPut.prototype.write = function(stream) {\n  stream.write(this.buffer());\n};\n"]}