// This is a minified version of the code at https://git.eusv.net/tgpholly/bufferStuff/releases/tag/1.5.0 + FunkyArray
classBrowserBuffer{constructor(dataOrSize){if(typeofdataOrSize==="number"){this.buffer=newUint8Array(dataOrSize)}elseif(typeofdataOrSize==="object"){this.buffer=newUint8Array(dataOrSize)}else{this.buffer=newUint8Array(0)}this.dataView=newDataView(this.buffer.buffer)}staticallocUnsafe(size){returnthis.alloc(size)}staticallocUnsafeSlow(size){returnthis.alloc(size)}staticalloc(size){returnnewBrowserBuffer(size)}staticconcat(buffers,totalLength){letjoinedArrays;if(totalLength!==undefined){joinedArrays=newUint8Array(totalLength)}else{letarraysLength=0;for(constbufferofbuffers){arraysLength+=buffer.length}joinedArrays=newUint8Array(arraysLength)}letoffset=0;for(constbufferofbuffers){joinedArrays.set(buffer.buffer,offset);offset+=buffer.length}returnnewBrowserBuffer(joinedArrays)}staticfrom(data){if(typeofdata==="string"){thrownewError("BrowserBuffer does not currently support creating buffers from strings.")}returnnewBrowserBuffer(data)}staticof(){}staticisBuffer(){}staticisEncoding(){}staticbyteLength(){}staticcopyBytesFrom(){}staticcompare(){}getlength(){returnthis.buffer.length}checkRanged(value,valueName,lowRange,highRange){if(value<lowRange||value>highRange){thrownewError(`The value of "${valueName}" is out of range. It must be >= ${lowRange} and <= ${highRange}. Received ${value}`)}}checkValue(value,low,high){this.checkRanged(value,"value",low,high)}checkOffset(offset){if(offset){this.checkRanged(offset,"offset",0,this.buffer.length-1)}}writeInt8(value,offset){this.checkValue(value,-128,127);this.checkOffset(offset);this.dataView.setInt8(offset,value);returnthis}writeUInt8(value,offset){this.checkValue(value,0,255);this.checkOffset(offset);this.dataView.setUint8(offset,value);returnthis}writeInt16LE(value,offset){this.checkValue(value,-32768,32767);this.checkOffset(offset);this.dataView.setInt16(offset,value,true);returnthis}writeUInt16LE(value,offset){this.checkValue(value,0,65535);this.checkOffset(offset);this.dataView.setUint16(offset,value,true);returnthis}writeInt32LE(value,offset){this.checkValue(value,-2147483648,2147483647);this.checkOffset(offset);this.dataView.setInt32(offset,value,true);returnthis}writeUInt32LE(value,offset){this.checkValue(value,0,4294967295);this.checkOffset(offset);this.dataView.setUint32(offset,value,true);returnthis}writeBigInt64LE(value,offset){if(typeofvalue==="number"){value=BigInt(value)}this.checkValue(value,-9223372036854775808n,9223372036854775808n);this.checkOffset(offset);this.dataView.setBigInt64(offset,value,true);returnthis}writeBigUint64LE(value,offset){if(typeofvalue==="number"){value=BigInt(value)}this.checkValue(value,0n,18446744073709551616n);this.checkOffset(offset);this.dataView.setBigUint64(offset,value,true);returnthis}writeFloatLE(value,offset){this.checkOffset(offset);this.dataView.setFloat32(offset,value,true);returnthis}writeDoubleLE(value,offset){this.checkOffset(offset);this.dataView.setFloat64(offset,value,true);returnthis}writeInt16BE(value,offset){this.checkValue(value,-32768,32767);this.checkOffset(offset);this.dataView.setInt16(offset,value,false);returnthis}writeUInt16BE(value,offset){this.checkValue(value,0,65535);this.checkOffset(offset);this.dataView.setUint16(offset,value,false);returnthis}writeInt32BE(value,offset){this.checkValue(value,-2147483648,2147483647);this.checkOffset(offset);this.dataView.setInt32(offset,value,false);returnthis}writeUInt32BE(value,offset){this.checkValue(value,0,4294967295);this.checkOffset(offset);this.dataView.setUint32(offset,value,false);returnthis}writeBigInt64BE(value,offset){if(typeofvalue==="number"){value=BigInt(value)}this.checkValue(value,-(2n**63n),2n**63n);this.checkOffset(offset);this.dataView.setBigInt64(offset,value,false);returnthis}writeBigUint64BE(value,offset){if(typeofvalue==="number"){value=BigInt(value)}this.checkValue(value,0n,2n**64n);this.checkOffset(offset);this.dataView.setBigUint64(offset,value,false);returnthis}writeFloatBE(value,offset){this.checkOffset(offset);this.dataView.setFloat32(offset,value,false);returnthis}writeDouble