Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bytebuffer

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bytebuffer - npm Package Compare versions

Comparing version 1.3.5 to 1.3.6

86

ByteBuffer.min.js

@@ -7,44 +7,44 @@ /*

function l(r){throw r;}var m=!0,n=null,p=!1;
(function(r){function t(g,r){function c(a,b){a="undefined"!=typeof a?parseInt(a,10):c.DEFAULT_CAPACITY;1>a&&(a=c.DEFAULT_CAPACITY);this.array=3==arguments.length&&arguments[2]===m?n:new ArrayBuffer(a);this.view=this.array!=n?new DataView(this.array):n;this.offset=0;this.markedOffset=-1;this.length=0;this.littleEndian="undefined"!=typeof b?!!b:p}var s=r&&"function"==typeof r.Buffer&&"function"==typeof r.Buffer.isBuffer?r.Buffer:n;c.DEFAULT_CAPACITY=16;c.LITTLE_ENDIAN=m;c.BIG_ENDIAN=p;c.Long=g;c.allocate=
function(a,b){return new c(a,b)};c.wrap=function(a,b){if("string"==typeof a)return(new c).writeUTF8String(a).flip();s&&s.isBuffer(a)&&(a=new Uint8Array(a));a.array?a=a.array:a.buffer&&(a=a.buffer);a instanceof ArrayBuffer||l(Error("Cannot wrap buffer of type "+typeof a));var d=new c(0,b,m);d.array=a;d.view=new DataView(d.array);d.offset=0;d.length=a.byteLength;return d};c.prototype.LE=function(){this.littleEndian=m;return this};c.prototype.BE=function(){this.littleEndian=p;return this};c.prototype.resize=
function(a){if(1>a)return p;this.array==n&&(this.array=new ArrayBuffer(a),this.view=new DataView(this.array));if(this.array.byteLength<a){var b=new Uint8Array(this.array);a=new ArrayBuffer(a);(new Uint8Array(a)).set(b);this.array=a;this.view=new DataView(a);return m}return p};c.prototype.slice=function(a,b){this.array==n&&l(Error(this+" cannot be sliced: Already destroyed"));b<=a&&l(Error(this+" cannot be sliced: End ("+b+") is less than begin ("+a+")"));(0>a||a>this.array.byteLength||1>b||b>this.array.byteLength)&&
l(Error(this+" cannot be sliced: Index out of bounds (0-"+this.array.byteLength+" -> "+a+"-"+b+")"));var d=this.clone();d.offset=a;d.length=b;return d};c.prototype.sliceAndCompact=function(a,b){return c.wrap(this.slice(a,b).toArrayBuffer(m))};c.prototype.ensureCapacity=function(a){return this.array==n?this.resize(a):this.array.byteLength<a?this.resize(2*this.array.byteLength>=a?2*this.array.byteLength:a):p};c.prototype.flip=function(){this.length=this.array==n?0:this.offset;this.offset=0;return this};
c.prototype.mark=function(a){this.array==n&&l(Error(this+" cannot be marked: Already destroyed"));a="undefined"!=typeof a?parseInt(a,10):this.offset;(0>a||a>this.array.byteLength)&&l(Error(this+" cannot be marked: Offset to mark is less than 0 or bigger than the capacity ("+this.array.byteLength+"): "+a));this.markedOffset=a;return this};c.prototype.reset=function(){0<=this.markedOffset?(this.offset=this.markedOffset,this.markedOffset=-1):this.length=this.offset=0;return this};c.prototype.clone=function(){var a=
new c(-1,this.littleEndian,m);a.array=this.array;a.view=this.view;a.offset=this.offset;a.length=this.length;return a};c.prototype.copy=function(){if(this.array==n)return this.clone();var a=new c(this.array.byteLength,this.littleEndian),b=new Uint8Array(this.array);(new Uint8Array(a.array)).set(b);a.offset=this.offset;a.length=this.length;return a};c.prototype.remaining=function(){return this.array==n?0:this.length-this.offset};c.prototype.capacity=function(){return this.array!=n?this.array.byteLength:
0};c.prototype.compact=function(){this.array==n&&l(Error(this+" cannot be compacted: Already destroyed"));this.offset>this.length&&this.flip();this.offset==this.length&&l(Error(this+" cannot be compacted: Offset ("+this.offset+") is equal to its length ("+this.length+")"));if(0==this.offset&&this.length==this.array.byteLength)return this;var a=new Uint8Array(this.array),b=new ArrayBuffer(this.length-this.offset);(new Uint8Array(b)).set(a.subarray(this.offset,this.length));this.array=b;this.offset=
0;this.length=this.array.byteLength;return this};c.prototype.destroy=function(){if(this.array!=n)return this.view=this.array=n,this.length=this.offset=0,this};c.prototype.reverse=function(){this.array==n&&l(Error(this+" cannot be reversed: Already destroyed"));Array.prototype.reverse.call(new Uint8Array(this.array));var a=this.offset;this.offset=this.array.byteLength-this.length;this.length=this.array.byteLength-a;return this};c.prototype.append=function(a,b){a instanceof c||(a=c.wrap(a));a.array==
n&&l(Error(a+" cannot be appended to "+this+": Already destroyed"));var d=a.length-a.offset;if(0==d)return this;0>d&&(a=a.clone().flip(),d=a.length-a.offset);b="undefined"!=typeof b?b:(this.offset+=d)-d;this.ensureCapacity(b+d);d=new Uint8Array(a.array);(new Uint8Array(this.array)).set(d.subarray(a.offset,a.length),b);return this};c.prototype.prepend=function(a,b){a instanceof c||(a=c.wrap(a));a.array==n&&l(a+" cannot be prepended to "+this+": Already destroyed");var d=a.length-a.offset;if(0==d)return this;
0>d&&(a=a.clone().flip(),d=a.length-a.offset);var f="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;var e=d-b;0<e?(this.ensureCapacity(this.length+e),this.append(this,d),this.offset+=e,this.length+=e,this.append(a,0)):this.append(a,b-d);f&&(this.offset-=d);return this};c.prototype.writeInt8=function(a,b){b="undefined"!=typeof b?b:(this.offset+=1)-1;this.ensureCapacity(b+1);this.view.setInt8(b,a);return this};c.prototype.readInt8=function(a){a="undefined"!=typeof a?a:(this.offset+=1)-1;
a>=this.array.byteLength&&l(Error("Cannot read int8 from "+this+": Capacity overflow"));return this.view.getInt8(a)};c.prototype.writeByte=c.prototype.writeInt8;c.prototype.readByte=c.prototype.readInt8;c.prototype.writeUint8=function(a,b){b="undefined"!=typeof b?b:(this.offset+=1)-1;this.ensureCapacity(b+1);this.view.setUint8(b,a);return this};c.prototype.readUint8=function(a){a="undefined"!=typeof a?a:(this.offset+=1)-1;a>=this.array.byteLength&&l("Cannot read uint8 from "+this+": Capacity overflow");
return this.view.getUint8(a)};c.prototype.writeInt16=function(a,b){b="undefined"!=typeof b?b:(this.offset+=2)-2;this.ensureCapacity(b+2);this.view.setInt16(b,a,this.littleEndian);return this};c.prototype.readInt16=function(a){a="undefined"!=typeof a?a:(this.offset+=2)-2;a+2>this.array.byteLength&&l(Error("Cannot read int16 from "+this+": Capacity overflow"));return this.view.getInt16(a,this.littleEndian)};c.prototype.writeShort=c.prototype.writeInt16;c.prototype.readShort=c.prototype.readInt16;c.prototype.writeUint16=
function(a,b){b="undefined"!=typeof b?b:(this.offset+=2)-2;this.ensureCapacity(b+2);this.view.setUint16(b,a,this.littleEndian);return this};c.prototype.readUint16=function(a){a="undefined"!=typeof a?a:(this.offset+=2)-2;a+2>this.array.b&&l(Error("Cannot read int16 from "+this+": Capacity overflow"));return this.view.getUint16(a,this.littleEndian)};c.prototype.writeInt32=function(a,b){b="undefined"!=typeof b?b:(this.offset+=4)-4;this.ensureCapacity(b+4);this.view.setInt32(b,a,this.littleEndian);return this};
c.prototype.readInt32=function(a){a="undefined"!=typeof a?a:(this.offset+=4)-4;a+4>this.array.byteLength&&l(Error("Cannot read int32 from "+this+": Capacity overflow"));return this.view.getInt32(a,this.littleEndian)};c.prototype.writeInt=c.prototype.writeInt32;c.prototype.readInt=c.prototype.readInt32;c.prototype.writeUint32=function(a,b){b="undefined"!=typeof b?b:(this.offset+=4)-4;this.ensureCapacity(b+4);this.view.setUint32(b,a,this.littleEndian);return this};c.prototype.readUint32=function(a){a=
"undefined"!=typeof a?a:(this.offset+=4)-4;a+4>this.array.byteLength&&l(Error("Cannot read uint32 from "+this+": Capacity overflow"));return this.view.getUint32(a,this.littleEndian)};c.prototype.writeFloat32=function(a,b){b="undefined"!=typeof b?b:(this.offset+=4)-4;this.ensureCapacity(b+4);this.view.setFloat32(b,a,this.littleEndian);return this};c.prototype.readFloat32=function(a){a="undefined"!=typeof a?a:(this.offset+=4)-4;(this.array==n||a+4>this.array.byteLength)&&l(Error("Cannot read float32 from "+
this+": Capacity overflow"));return this.view.getFloat32(a,this.littleEndian)};c.prototype.writeFloat=c.prototype.writeFloat32;c.prototype.readFloat=c.prototype.readFloat32;c.prototype.writeFloat64=function(a,b){b="undefined"!=typeof b?b:(this.offset+=8)-8;this.ensureCapacity(b+8);this.view.setFloat64(b,a,this.littleEndian);return this};c.prototype.readFloat64=function(a){a="undefined"!=typeof a?a:(this.offset+=8)-8;(this.array==n||a+8>this.array.byteLength)&&l(Error("Cannot read float64 from "+this+
": Capacity overflow"));return this.view.getFloat64(a,this.littleEndian)};c.prototype.writeDouble=c.prototype.writeFloat64;c.prototype.readDouble=c.prototype.readFloat64;c.prototype.writeInt64=function(a,b){g||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));b="undefined"!=typeof b?b:(this.offset+=8)-8;"object"==typeof a&&a instanceof g||(a=g.fromNumber(a,p));this.ensureCapacity(b+8);this.littleEndian?(this.view.setInt32(b,a.getLowBits(),
m),this.view.setInt32(b+4,a.getHighBits(),m)):(this.view.setInt32(b,a.getHighBits(),p),this.view.setInt32(b+4,a.getLowBits(),p));return this};c.prototype.readInt64=function(a){g||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));a="undefined"!=typeof a?a:(this.offset+=8)-8;if(this.array==n||a+8>this.array.byteLength)this.offset-=8,l(Error("Cannot read int64 from "+this+": Capacity overflow"));return this.littleEndian?g.fromBits(this.view.getInt32(a,
m),this.view.getInt32(a+4,m),p):g.fromBits(this.view.getInt32(a+4,p),this.view.getInt32(a,p),p)};c.prototype.writeUint64=function(a,b){g||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));b="undefined"!=typeof b?b:(this.offset+=8)-8;"object"==typeof a&&a instanceof g||(a=g.fromNumber(a,m));this.ensureCapacity(b+8);this.littleEndian?(this.view.setUint32(b,a.getLowBitsUnsigned(),m),this.view.setUint32(b+4,a.getHighBitsUnsigned(),
m)):(this.view.setUint32(b,a.getHighBitsUnsigned(),p),this.view.setUint32(b+4,a.getLowBitsUnsigned(),p));return this};c.prototype.readUint64=function(a){g||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));a="undefined"!=typeof a?a:(this.offset+=8)-8;if(this.array==n||a+8>this.array.byteLength)this.offset-=8,l(Error("Cannot read int64 from "+this+": Capacity overflow"));return this.littleEndian?g.fromBits(this.view.getUint32(a,
m),this.view.getUint32(a+4,m),m):g.fromBits(this.view.getUint32(a+4,p),this.view.getUint32(a,p),m)};c.prototype.writeLong=c.prototype.writeInt64;c.prototype.readLong=c.prototype.readInt64;c.MAX_VARINT32_BYTES=5;c.prototype.writeVarint32=function(a,b){var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;a>>>=0;this.ensureCapacity(b+c.calculateVarint32(a));var f=new Uint8Array(this.array),e=0;f[b]=a|128;128<=a?(f[b+1]=a>>7|128,16384<=a?(f[b+2]=a>>14|128,2097152<=a?(f[b+3]=a>>21|128,268435456<=
a?(f[b+4]=a>>28&127,e=5):(f[b+3]&=127,e=4)):(f[b+2]&=127,e=3)):(f[b+1]&=127,e=2)):(f[b]&=127,e=1);return d?(this.offset+=e,this):e};c.prototype.readVarint32=function(a){var b="undefined"==typeof a;a="undefined"!=typeof a?a:this.offset;var d=new Uint8Array(this.array),c=0,e,k=0;do e=d[a+c],k|=(e&127)<<7*c>>>0,++c;while(e&128);k|=0;return b?(this.offset+=c,k):{value:k,length:c}};c.prototype.writeZigZagVarint32=function(a,b){return this.writeVarint32(c.zigZagEncode32(a),b)};c.prototype.readZigZagVarint32=
function(a){a=this.readVarint32(a);return"object"==typeof a?(a.value=c.zigZagDecode32(a.value),a):c.zigZagDecode32(a)};c.MAX_VARINT64_BYTES=10;c.prototype.writeVarint64=function(a,b){g||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;"object"==typeof a&&a instanceof g||(a=g.fromNumber(a,p));var f=a.toInt()>>>0,e=a.shiftRightUnsigned(28).toInt()>>>0,k=a.shiftRightUnsigned(56).toInt()>>>
0,q=c.calculateVarint64(a);this.ensureCapacity(b+q);var h=new Uint8Array(this.array);switch(q){case 10:h[b+9]=k>>>7|128;case 9:h[b+8]=k|128;case 8:h[b+7]=e>>>21|128;case 7:h[b+6]=e>>>14|128;case 6:h[b+5]=e>>>7|128;case 5:h[b+4]=e|128;case 4:h[b+3]=f>>>21|128;case 3:h[b+2]=f>>>14|128;case 2:h[b+1]=f>>>7|128;case 1:h[b+0]=f|128}h[b+q-1]&=127;return d?(this.offset+=q,this):q};c.prototype.readVarint64=function(a){g||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));
var b="undefined"==typeof a,d=a="undefined"!=typeof a?a:this.offset,c=new Uint8Array(this.array),e,k=0,q=0,h;h=c[a++];e=h&127;h&128&&(h=c[a++],e|=(h&127)<<7,h&128&&(h=c[a++],e|=(h&127)<<14,h&128&&(h=c[a++],e|=(h&127)<<21,h&128&&(h=c[a++],k=h&127,h&128&&(h=c[a++],k|=(h&127)<<7,h&128&&(h=c[a++],k|=(h&127)<<14,h&128&&(h=c[a++],k|=(h&127)<<21,h&128&&(h=c[a++],q=h&127,h&128&&(h=c[a++],q|=(h&127)<<7,h&128&&l(Error("Data must be corrupt: Buffer overrun")))))))))));c=g.from28Bits(e,k,q,p);return b?(this.offset=
a,c):{value:c,length:a-d}};c.prototype.writeZigZagVarint64=function(a,b){return this.writeVarint64(c.zigZagEncode64(a),b)};c.prototype.readZigZagVarint64=function(a){a=this.readVarint64(a);return"object"==typeof a&&!(a instanceof g)?(a.value=c.zigZagDecode64(a.value),a):c.zigZagDecode64(a)};c.prototype.writeVarint=c.prototype.writeVarint32;c.prototype.readVarint=c.prototype.readVarint32;c.prototype.writeZigZagVarint=c.prototype.writeZigZagVarint32;c.prototype.readZigZagVarint=c.prototype.readZigZagVarint32;
c.calculateVarint32=function(a){a>>>=0;return 128>a?1:16384>a?2:2097152>a?3:268435456>a?4:5};c.calculateVarint64=function(a){g||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));"object"==typeof a&&a instanceof g||(a=g.fromNumber(a,p));var b=a.toInt()>>>0,d=a.shiftRightUnsigned(28).toInt()>>>0;a=a.shiftRightUnsigned(56).toInt()>>>0;return 0==a?0==d?16384>b?128>b?1:2:2097152>b?3:4:16384>d?128>d?5:6:2097152>d?7:8:128>a?9:10};c.zigZagEncode32=
function(a){return((a|=0)<<1^a>>31)>>>0};c.zigZagDecode32=function(a){return a>>>1^-(a&1)|0};c.zigZagEncode64=function(a){g||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));"object"==typeof a&&a instanceof g?a.unsigned&&(a=a.toSigned()):a=g.fromNumber(a,p);return a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()};c.zigZagDecode64=function(a){g||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));
"object"==typeof a&&a instanceof g?a.unsigned||(a=a.toUnsigned()):a=g.fromNumber(a,m);return a.shiftRightUnsigned(1).xor(a.and(g.ONE).toSigned().negate()).toSigned()};c.decodeUTF8Char=function(a,b){var d=a.readUint8(b),c,e,k,q,h,g=b;0==(d&128)?(c=d,b+=1):192==(d&224)?(c=a.readUint8(b+1),c=(d&31)<<6|c&63,b+=2):224==(d&240)?(c=a.readUint8(b+1),e=a.readUint8(b+2),c=(d&15)<<12|(c&63)<<6|e&63,b+=3):240==(d&248)?(c=a.readUint8(b+1),e=a.readUint8(b+2),k=a.readUint8(b+3),c=(d&7)<<18|(c&63)<<12|(e&63)<<6|
k&63,b+=4):248==(d&252)?(c=a.readUint8(b+1),e=a.readUint8(b+2),k=a.readUint8(b+3),q=a.readUint8(b+4),c=(d&3)<<24|(c&63)<<18|(e&63)<<12|(k&63)<<6|q&63,b+=5):252==(d&254)?(c=a.readUint8(b+1),e=a.readUint8(b+2),k=a.readUint8(b+3),q=a.readUint8(b+4),h=a.readUint8(b+5),c=(d&1)<<30|(c&63)<<24|(e&63)<<18|(k&63)<<12|(q&63)<<6|h&63,b+=6):l(Error("Cannot decode UTF8 character at offset "+b+": charCode (0x"+d.toString(16)+") is invalid"));return{"char":c,length:b-g}};c.encodeUTF8Char=function(a,b,c){var f=c;
0>a&&l(Error("Cannot encode UTF8 character: charCode ("+a+") is negative"));128>a?(b.writeUint8(a&127,c),c+=1):2048>a?(b.writeUint8(a>>6&31|192,c).writeUint8(a&63|128,c+1),c+=2):65536>a?(b.writeUint8(a>>12&15|224,c).writeUint8(a>>6&63|128,c+1).writeUint8(a&63|128,c+2),c+=3):2097152>a?(b.writeUint8(a>>18&7|240,c).writeUint8(a>>12&63|128,c+1).writeUint8(a>>6&63|128,c+2).writeUint8(a&63|128,c+3),c+=4):67108864>a?(b.writeUint8(a>>24&3|248,c).writeUint8(a>>18&63|128,c+1).writeUint8(a>>12&63|128,c+2).writeUint8(a>>
6&63|128,c+3).writeUint8(a&63|128,c+4),c+=5):2147483648>a?(b.writeUint8(a>>30&1|252,c).writeUint8(a>>24&63|128,c+1).writeUint8(a>>18&63|128,c+2).writeUint8(a>>12&63|128,c+3).writeUint8(a>>6&63|128,c+4).writeUint8(a&63|128,c+5),c+=6):l(Error("Cannot encode UTF8 character: charCode (0x"+a.toString(16)+") is too large (>= 0x80000000)"));return c-f};c.calculateUTF8Char=function(a){0>a&&l(Error("Cannot calculate length of UTF8 character: charCode ("+a+") is negative"));if(128>a)return 1;if(2048>a)return 2;
if(65536>a)return 3;if(2097152>a)return 4;if(67108864>a)return 5;if(2147483648>a)return 6;l(Error("Cannot calculate length of UTF8 character: charCode (0x"+a.toString(16)+") is too large (>= 0x80000000)"))};c.a=function(a){a=""+a;for(var b=0,d=0;d<a.length;d++)b+=c.calculateUTF8Char(a.charCodeAt(d));return b};c.prototype.writeUTF8String=function(a,b){var d="undefined"==typeof b,f=b="undefined"!=typeof b?b:this.offset,e=c.a(a);this.ensureCapacity(b+e);for(e=0;e<a.length;e++)b+=c.encodeUTF8Char(a.charCodeAt(e),
this,b);return d?(this.offset=b,this):b-f};c.prototype.readUTF8String=function(a,b){var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;for(var f,e="",k=b,g=0;g<a;g++)f=c.decodeUTF8Char(this,b),b+=f.length,e+=String.fromCharCode(f["char"]);return d?(this.offset=b,e):{string:e,length:b-k}};c.prototype.readUTF8StringBytes=function(a,b){var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;var f,e="",k=b;for(a=b+a;b<a;)f=c.decodeUTF8Char(this,b),b+=f.length,e+=String.fromCharCode(f["char"]);
b!=a&&l(Error("Actual string length differs from the specified: "+((b>a?"+":"")+b-a)+" bytes"));return d?(this.offset=b,e):{string:e,length:b-k}};c.prototype.writeLString=function(a,b){a=""+a;var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;var f=c.encodeUTF8Char(a.length,this,b),f=f+this.writeUTF8String(a,b+f);return d?(this.offset+=f,this):f};c.prototype.readLString=function(a){var b="undefined"==typeof a;a="undefined"!=typeof a?a:this.offset;var d=c.decodeUTF8Char(this,a);a=this.readUTF8String(d["char"],
a+d.length);return b?(this.offset+=d.length+a.length,a.string):{string:a.string,length:d.length+a.length}};c.prototype.writeVString=function(a,b){a=""+a;var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;var f=this.writeVarint32(c.a(a),b),f=f+this.writeUTF8String(a,b+f);return d?(this.offset+=f,this):f};c.prototype.readVString=function(a){var b="undefined"==typeof a;a="undefined"!=typeof a?a:this.offset;var c=this.readVarint32(a);a=this.readUTF8StringBytes(c.value,a+c.length);return b?
(this.offset+=c.length+a.length,a.string):{string:a.string,length:c.length+a.length}};c.prototype.writeCString=function(a,b){var c="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;var f=this.writeUTF8String(""+a,b);this.writeUint8(0,b+f);return c?(this.offset+=f+1,this):f+1};c.prototype.readCString=function(a){var b="undefined"==typeof a;a="undefined"!=typeof a?a:this.offset;var d,f="",e=a;do d=c.decodeUTF8Char(this,a),a+=d.length,0!=d["char"]&&(f+=String.fromCharCode(d["char"]));while(0!=
d["char"]);return b?(this.offset=a,f):{string:f,length:a-e}};c.prototype.writeJSON=function(a,b,c){c="function"==typeof c?c:JSON.stringify;return this.writeLString(c(a),b)};c.prototype.readJSON=function(a,b){b="function"==typeof b?b:JSON.parse;var c=this.readLString(a);return"string"==typeof c?b(c):{data:b(c.string),length:c.length}};c.prototype.printDebug=function(a){for(var b=(this.array!=n?"ByteBuffer(offset="+this.offset+",markedOffset="+this.markedOffset+",length="+this.length+",capacity="+this.array.byteLength+
")":"ByteBuffer(DESTROYED)")+"\n-------------------------------------------------------------------\n",c=this.toHex(16,m),f=this.toASCII(16,m),e=0;e<c.length;e++)b+=c[e]+" "+f[e]+"\n";if(a===m)return b;"function"==typeof a?a(b):console.log(b)};c.prototype.toHex=function(a,b){if(this.array==n)return"DESTROYED";b=!!b;a="undefined"!=typeof a?parseInt(a,10):16;1>a&&(a=16);for(var c="",f=[],e=new Uint8Array(this.array),c=0==this.offset&&0==this.length?c+"|":0==this.length?c+">":0==this.offset?c+"<":c+
" ",k=0;k<this.array.byteLength;k++){0<k&&0==k%a&&(f.push(c),c=" ");var g=e[k],g=g.toString(16).toUpperCase();2>g.length&&(g="0"+g);c+=g;c=k+1==this.offset&&k+1==this.length?c+"|":k+1==this.offset?c+"<":k+1==this.length?c+">":c+" "}if(b)for(;c.length<3*a+1;)c+=" ";f.push(c);return b?f:f.join("\n")};c.prototype.toASCII=function(a,b){if(this.array==n)return"";b=!!b;a="undefined"!=typeof a?parseInt(a,10):16;1>a&&(a=16);for(var c="",f=[],e=new Uint8Array(this.array),k=0;k<this.array.byteLength;k++){0<
k&&0==k%a&&(f.push(c),c="");var g=e[k],g=32<g&&127>g?String.fromCharCode(g):".",c=c+g}f.push(c);return b?f:f.join("\n")+"\n"};c.prototype.toString=function(){return this.array==n?"ByteBuffer(DESTROYED)":"ByteBuffer(offset="+this.offset+",markedOffset="+this.markedOffset+",length="+this.length+",capacity="+this.array.byteLength+")"};c.prototype.toArrayBuffer=function(a){var b=this.clone();b.offset>b.length&&b.flip();var c=p;if(0<b.offset||b.length<b.array.byteLength)b.compact(),c=m;return a&&!c?b.copy().array:
b.array};c.prototype.toBuffer=function(){if(s){var a=this.offset,b=this.length;if(a>b)var c=a,a=b,b=c;c=new Uint8Array(this.array);return new s(c.subarray(a,b))}l(Error("Conversion to Buffer is available under node.js only"))};c.extend=function(a,b){"string"==typeof a&&"function"==typeof b?c.prototype[a]=b:l(Error("Cannot extend prototype with "+a+"="+b+" (exptected string and function)"))};return c}"undefined"!=typeof module&&module.exports?module.exports=t(require("long"),require("buffer")):"undefined"!=
typeof define&&define.amd?define("ByteBuffer",["Math/Long"],function(g){return t(g)}):(r.dcodeIO||(r.dcodeIO={}),r.dcodeIO.ByteBuffer=t(dcodeIO.Long))})(this);
(function(r){function t(h,r){function c(a,b){a="undefined"!=typeof a?parseInt(a,10):c.DEFAULT_CAPACITY;1>a&&(a=c.DEFAULT_CAPACITY);this.array=3==arguments.length&&arguments[2]===m?n:new ArrayBuffer(a);this.view=this.array!=n?new DataView(this.array):n;this.offset=0;this.markedOffset=-1;this.length=0;this.littleEndian="undefined"!=typeof b?!!b:p}var s=r&&"function"==typeof r.Buffer&&"function"==typeof r.Buffer.isBuffer?r.Buffer:n;c.DEFAULT_CAPACITY=16;c.LITTLE_ENDIAN=m;c.BIG_ENDIAN=p;c.Long=h;c.allocate=
function(a,b){return new c(a,b)};c.wrap=function(a,b){if("string"==typeof a)return(new c).writeUTF8String(a).flip();var d;if(s&&s.isBuffer(a)){d=(new Uint8Array(a)).buffer;if(d===a){d=a;for(var e=new ArrayBuffer(d.length),f=new Uint8Array(e),g=0;g<d.length;++g)f[g]=d[g];d=e}a=d}a.array?a=a.array:a.buffer&&(a=a.buffer);a instanceof ArrayBuffer||l(Error("Cannot wrap buffer of type "+typeof a+", "+a.constructor.name));d=new c(0,b,m);d.array=a;d.view=new DataView(d.array);d.offset=0;d.length=a.byteLength;
return d};c.prototype.LE=function(){this.littleEndian=m;return this};c.prototype.BE=function(){this.littleEndian=p;return this};c.prototype.resize=function(a){if(1>a)return p;this.array==n&&(this.array=new ArrayBuffer(a),this.view=new DataView(this.array));if(this.array.byteLength<a){var b=new Uint8Array(this.array);a=new ArrayBuffer(a);(new Uint8Array(a)).set(b);this.array=a;this.view=new DataView(a);return m}return p};c.prototype.slice=function(a,b){this.array==n&&l(Error(this+" cannot be sliced: Already destroyed"));
b<=a&&l(Error(this+" cannot be sliced: End ("+b+") is less than begin ("+a+")"));(0>a||a>this.array.byteLength||1>b||b>this.array.byteLength)&&l(Error(this+" cannot be sliced: Index out of bounds (0-"+this.array.byteLength+" -> "+a+"-"+b+")"));var d=this.clone();d.offset=a;d.length=b;return d};c.prototype.sliceAndCompact=function(a,b){return c.wrap(this.slice(a,b).toArrayBuffer(m))};c.prototype.ensureCapacity=function(a){return this.array==n?this.resize(a):this.array.byteLength<a?this.resize(2*this.array.byteLength>=
a?2*this.array.byteLength:a):p};c.prototype.flip=function(){this.length=this.array==n?0:this.offset;this.offset=0;return this};c.prototype.mark=function(a){this.array==n&&l(Error(this+" cannot be marked: Already destroyed"));a="undefined"!=typeof a?parseInt(a,10):this.offset;(0>a||a>this.array.byteLength)&&l(Error(this+" cannot be marked: Offset to mark is less than 0 or bigger than the capacity ("+this.array.byteLength+"): "+a));this.markedOffset=a;return this};c.prototype.reset=function(){0<=this.markedOffset?
(this.offset=this.markedOffset,this.markedOffset=-1):this.length=this.offset=0;return this};c.prototype.clone=function(){var a=new c(-1,this.littleEndian,m);a.array=this.array;a.view=this.view;a.offset=this.offset;a.length=this.length;return a};c.prototype.copy=function(){if(this.array==n)return this.clone();var a=new c(this.array.byteLength,this.littleEndian),b=new Uint8Array(this.array);(new Uint8Array(a.array)).set(b);a.offset=this.offset;a.length=this.length;return a};c.prototype.remaining=function(){return this.array==
n?0:this.length-this.offset};c.prototype.capacity=function(){return this.array!=n?this.array.byteLength:0};c.prototype.compact=function(){this.array==n&&l(Error(this+" cannot be compacted: Already destroyed"));this.offset>this.length&&this.flip();this.offset==this.length&&l(Error(this+" cannot be compacted: Offset ("+this.offset+") is equal to its length ("+this.length+")"));if(0==this.offset&&this.length==this.array.byteLength)return this;var a=new Uint8Array(this.array),b=new ArrayBuffer(this.length-
this.offset);(new Uint8Array(b)).set(a.subarray(this.offset,this.length));this.array=b;this.offset=0;this.length=this.array.byteLength;return this};c.prototype.destroy=function(){if(this.array!=n)return this.view=this.array=n,this.length=this.offset=0,this};c.prototype.reverse=function(){this.array==n&&l(Error(this+" cannot be reversed: Already destroyed"));Array.prototype.reverse.call(new Uint8Array(this.array));var a=this.offset;this.offset=this.array.byteLength-this.length;this.length=this.array.byteLength-
a;return this};c.prototype.append=function(a,b){a instanceof c||(a=c.wrap(a));a.array==n&&l(Error(a+" cannot be appended to "+this+": Already destroyed"));var d=a.length-a.offset;if(0==d)return this;0>d&&(a=a.clone().flip(),d=a.length-a.offset);b="undefined"!=typeof b?b:(this.offset+=d)-d;this.ensureCapacity(b+d);d=new Uint8Array(a.array);(new Uint8Array(this.array)).set(d.subarray(a.offset,a.length),b);return this};c.prototype.prepend=function(a,b){a instanceof c||(a=c.wrap(a));a.array==n&&l(a+" cannot be prepended to "+
this+": Already destroyed");var d=a.length-a.offset;if(0==d)return this;0>d&&(a=a.clone().flip(),d=a.length-a.offset);var e="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;var f=d-b;0<f?(this.ensureCapacity(this.length+f),this.append(this,d),this.offset+=f,this.length+=f,this.append(a,0)):this.append(a,b-d);e&&(this.offset-=d);return this};c.prototype.writeInt8=function(a,b){b="undefined"!=typeof b?b:(this.offset+=1)-1;this.ensureCapacity(b+1);this.view.setInt8(b,a);return this};c.prototype.readInt8=
function(a){a="undefined"!=typeof a?a:(this.offset+=1)-1;a>=this.array.byteLength&&l(Error("Cannot read int8 from "+this+" at "+a+": Capacity overflow"));return this.view.getInt8(a)};c.prototype.writeByte=c.prototype.writeInt8;c.prototype.readByte=c.prototype.readInt8;c.prototype.writeUint8=function(a,b){b="undefined"!=typeof b?b:(this.offset+=1)-1;this.ensureCapacity(b+1);this.view.setUint8(b,a);return this};c.prototype.readUint8=function(a){a="undefined"!=typeof a?a:(this.offset+=1)-1;a+1>this.array.byteLength&&
l("Cannot read uint8 from "+this+" at "+a+": Capacity overflow");return this.view.getUint8(a)};c.prototype.writeInt16=function(a,b){b="undefined"!=typeof b?b:(this.offset+=2)-2;this.ensureCapacity(b+2);this.view.setInt16(b,a,this.littleEndian);return this};c.prototype.readInt16=function(a){a="undefined"!=typeof a?a:(this.offset+=2)-2;a+2>this.array.byteLength&&l(Error("Cannot read int16 from "+this+" at "+a+": Capacity overflow"));return this.view.getInt16(a,this.littleEndian)};c.prototype.writeShort=
c.prototype.writeInt16;c.prototype.readShort=c.prototype.readInt16;c.prototype.writeUint16=function(a,b){b="undefined"!=typeof b?b:(this.offset+=2)-2;this.ensureCapacity(b+2);this.view.setUint16(b,a,this.littleEndian);return this};c.prototype.readUint16=function(a){a="undefined"!=typeof a?a:(this.offset+=2)-2;a+2>this.array.b&&l(Error("Cannot read int16 from "+this+" at "+a+": Capacity overflow"));return this.view.getUint16(a,this.littleEndian)};c.prototype.writeInt32=function(a,b){b="undefined"!=
typeof b?b:(this.offset+=4)-4;this.ensureCapacity(b+4);this.view.setInt32(b,a,this.littleEndian);return this};c.prototype.readInt32=function(a){a="undefined"!=typeof a?a:(this.offset+=4)-4;a+4>this.array.byteLength&&l(Error("Cannot read int32 from "+this+" at "+a+": Capacity overflow"));return this.view.getInt32(a,this.littleEndian)};c.prototype.writeInt=c.prototype.writeInt32;c.prototype.readInt=c.prototype.readInt32;c.prototype.writeUint32=function(a,b){b="undefined"!=typeof b?b:(this.offset+=4)-
4;this.ensureCapacity(b+4);this.view.setUint32(b,a,this.littleEndian);return this};c.prototype.readUint32=function(a){a="undefined"!=typeof a?a:(this.offset+=4)-4;a+4>this.array.byteLength&&l(Error("Cannot read uint32 from "+this+" at "+a+": Capacity overflow"));return this.view.getUint32(a,this.littleEndian)};c.prototype.writeFloat32=function(a,b){b="undefined"!=typeof b?b:(this.offset+=4)-4;this.ensureCapacity(b+4);this.view.setFloat32(b,a,this.littleEndian);return this};c.prototype.readFloat32=
function(a){a="undefined"!=typeof a?a:(this.offset+=4)-4;(this.array==n||a+4>this.array.byteLength)&&l(Error("Cannot read float32 from "+this+" at "+a+": Capacity overflow"));return this.view.getFloat32(a,this.littleEndian)};c.prototype.writeFloat=c.prototype.writeFloat32;c.prototype.readFloat=c.prototype.readFloat32;c.prototype.writeFloat64=function(a,b){b="undefined"!=typeof b?b:(this.offset+=8)-8;this.ensureCapacity(b+8);this.view.setFloat64(b,a,this.littleEndian);return this};c.prototype.readFloat64=
function(a){a="undefined"!=typeof a?a:(this.offset+=8)-8;(this.array==n||a+8>this.array.byteLength)&&l(Error("Cannot read float64 from "+this+" at "+a+": Capacity overflow"));return this.view.getFloat64(a,this.littleEndian)};c.prototype.writeDouble=c.prototype.writeFloat64;c.prototype.readDouble=c.prototype.readFloat64;c.prototype.writeInt64=function(a,b){h||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));b="undefined"!=typeof b?
b:(this.offset+=8)-8;"object"==typeof a&&a instanceof h||(a=h.fromNumber(a,p));this.ensureCapacity(b+8);this.littleEndian?(this.view.setInt32(b,a.getLowBits(),m),this.view.setInt32(b+4,a.getHighBits(),m)):(this.view.setInt32(b,a.getHighBits(),p),this.view.setInt32(b+4,a.getLowBits(),p));return this};c.prototype.readInt64=function(a){h||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));a="undefined"!=typeof a?a:(this.offset+=8)-
8;if(this.array==n||a+8>this.array.byteLength)this.offset-=8,l(Error("Cannot read int64 from "+this+" at "+a+": Capacity overflow"));return this.littleEndian?h.fromBits(this.view.getInt32(a,m),this.view.getInt32(a+4,m),p):h.fromBits(this.view.getInt32(a+4,p),this.view.getInt32(a,p),p)};c.prototype.writeUint64=function(a,b){h||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));b="undefined"!=typeof b?b:(this.offset+=8)-8;"object"==
typeof a&&a instanceof h||(a=h.fromNumber(a,m));this.ensureCapacity(b+8);this.littleEndian?(this.view.setUint32(b,a.getLowBitsUnsigned(),m),this.view.setUint32(b+4,a.getHighBitsUnsigned(),m)):(this.view.setUint32(b,a.getHighBitsUnsigned(),p),this.view.setUint32(b+4,a.getLowBitsUnsigned(),p));return this};c.prototype.readUint64=function(a){h||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));a="undefined"!=typeof a?a:(this.offset+=
8)-8;if(this.array==n||a+8>this.array.byteLength)this.offset-=8,l(Error("Cannot read int64 from "+this+" at "+a+": Capacity overflow"));return this.littleEndian?h.fromBits(this.view.getUint32(a,m),this.view.getUint32(a+4,m),m):h.fromBits(this.view.getUint32(a+4,p),this.view.getUint32(a,p),m)};c.prototype.writeLong=c.prototype.writeInt64;c.prototype.readLong=c.prototype.readInt64;c.MAX_VARINT32_BYTES=5;c.prototype.writeVarint32=function(a,b){var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;
a>>>=0;this.ensureCapacity(b+c.calculateVarint32(a));var e=new Uint8Array(this.array),f=0;e[b]=a|128;128<=a?(e[b+1]=a>>7|128,16384<=a?(e[b+2]=a>>14|128,2097152<=a?(e[b+3]=a>>21|128,268435456<=a?(e[b+4]=a>>28&127,f=5):(e[b+3]&=127,f=4)):(e[b+2]&=127,f=3)):(e[b+1]&=127,f=2)):(e[b]&=127,f=1);return d?(this.offset+=f,this):f};c.prototype.readVarint32=function(a){var b="undefined"==typeof a;a="undefined"!=typeof a?a:this.offset;var d=new Uint8Array(this.array),c=0,f,g=0;do f=d[a+c],g|=(f&127)<<7*c>>>0,
++c;while(f&128);g|=0;return b?(this.offset+=c,g):{value:g,length:c}};c.prototype.writeZigZagVarint32=function(a,b){return this.writeVarint32(c.zigZagEncode32(a),b)};c.prototype.readZigZagVarint32=function(a){a=this.readVarint32(a);return"object"==typeof a?(a.value=c.zigZagDecode32(a.value),a):c.zigZagDecode32(a)};c.MAX_VARINT64_BYTES=10;c.prototype.writeVarint64=function(a,b){h||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));
var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;"object"==typeof a&&a instanceof h||(a=h.fromNumber(a,p));var e=a.toInt()>>>0,f=a.shiftRightUnsigned(28).toInt()>>>0,g=a.shiftRightUnsigned(56).toInt()>>>0,q=c.calculateVarint64(a);this.ensureCapacity(b+q);var k=new Uint8Array(this.array);switch(q){case 10:k[b+9]=g>>>7|128;case 9:k[b+8]=g|128;case 8:k[b+7]=f>>>21|128;case 7:k[b+6]=f>>>14|128;case 6:k[b+5]=f>>>7|128;case 5:k[b+4]=f|128;case 4:k[b+3]=e>>>21|128;case 3:k[b+2]=e>>>14|128;
case 2:k[b+1]=e>>>7|128;case 1:k[b+0]=e|128}k[b+q-1]&=127;return d?(this.offset+=q,this):q};c.prototype.readVarint64=function(a){h||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));var b="undefined"==typeof a,d=a="undefined"!=typeof a?a:this.offset,c=new Uint8Array(this.array),f,g=0,q=0,k;k=c[a++];f=k&127;k&128&&(k=c[a++],f|=(k&127)<<7,k&128&&(k=c[a++],f|=(k&127)<<14,k&128&&(k=c[a++],f|=(k&127)<<21,k&128&&(k=c[a++],g=k&127,k&
128&&(k=c[a++],g|=(k&127)<<7,k&128&&(k=c[a++],g|=(k&127)<<14,k&128&&(k=c[a++],g|=(k&127)<<21,k&128&&(k=c[a++],q=k&127,k&128&&(k=c[a++],q|=(k&127)<<7,k&128&&l(Error("Data must be corrupt: Buffer overrun")))))))))));c=h.from28Bits(f,g,q,p);return b?(this.offset=a,c):{value:c,length:a-d}};c.prototype.writeZigZagVarint64=function(a,b){return this.writeVarint64(c.zigZagEncode64(a),b)};c.prototype.readZigZagVarint64=function(a){a=this.readVarint64(a);return"object"==typeof a&&!(a instanceof h)?(a.value=
c.zigZagDecode64(a.value),a):c.zigZagDecode64(a)};c.prototype.writeVarint=c.prototype.writeVarint32;c.prototype.readVarint=c.prototype.readVarint32;c.prototype.writeZigZagVarint=c.prototype.writeZigZagVarint32;c.prototype.readZigZagVarint=c.prototype.readZigZagVarint32;c.calculateVarint32=function(a){a>>>=0;return 128>a?1:16384>a?2:2097152>a?3:268435456>a?4:5};c.calculateVarint64=function(a){h||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));
"object"==typeof a&&a instanceof h||(a=h.fromNumber(a,p));var b=a.toInt()>>>0,d=a.shiftRightUnsigned(28).toInt()>>>0;a=a.shiftRightUnsigned(56).toInt()>>>0;return 0==a?0==d?16384>b?128>b?1:2:2097152>b?3:4:16384>d?128>d?5:6:2097152>d?7:8:128>a?9:10};c.zigZagEncode32=function(a){return((a|=0)<<1^a>>31)>>>0};c.zigZagDecode32=function(a){return a>>>1^-(a&1)|0};c.zigZagEncode64=function(a){h||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));
"object"==typeof a&&a instanceof h?a.unsigned&&(a=a.toSigned()):a=h.fromNumber(a,p);return a.shiftLeft(1).xor(a.shiftRight(63)).toUnsigned()};c.zigZagDecode64=function(a){h||l(Error("Long support is not available: See https://github.com/dcodeIO/ByteBuffer.js#on-long-int64-support for details"));"object"==typeof a&&a instanceof h?a.unsigned||(a=a.toUnsigned()):a=h.fromNumber(a,m);return a.shiftRightUnsigned(1).xor(a.and(h.ONE).toSigned().negate()).toSigned()};c.decodeUTF8Char=function(a,b){var d=a.readUint8(b),
c,f,g,q,k,h=b;0==(d&128)?(c=d,b+=1):192==(d&224)?(c=a.readUint8(b+1),c=(d&31)<<6|c&63,b+=2):224==(d&240)?(c=a.readUint8(b+1),f=a.readUint8(b+2),c=(d&15)<<12|(c&63)<<6|f&63,b+=3):240==(d&248)?(c=a.readUint8(b+1),f=a.readUint8(b+2),g=a.readUint8(b+3),c=(d&7)<<18|(c&63)<<12|(f&63)<<6|g&63,b+=4):248==(d&252)?(c=a.readUint8(b+1),f=a.readUint8(b+2),g=a.readUint8(b+3),q=a.readUint8(b+4),c=(d&3)<<24|(c&63)<<18|(f&63)<<12|(g&63)<<6|q&63,b+=5):252==(d&254)?(c=a.readUint8(b+1),f=a.readUint8(b+2),g=a.readUint8(b+
3),q=a.readUint8(b+4),k=a.readUint8(b+5),c=(d&1)<<30|(c&63)<<24|(f&63)<<18|(g&63)<<12|(q&63)<<6|k&63,b+=6):l(Error("Cannot decode UTF8 character at offset "+b+": charCode (0x"+d.toString(16)+") is invalid"));return{"char":c,length:b-h}};c.encodeUTF8Char=function(a,b,c){var e=c;0>a&&l(Error("Cannot encode UTF8 character: charCode ("+a+") is negative"));128>a?(b.writeUint8(a&127,c),c+=1):2048>a?(b.writeUint8(a>>6&31|192,c).writeUint8(a&63|128,c+1),c+=2):65536>a?(b.writeUint8(a>>12&15|224,c).writeUint8(a>>
6&63|128,c+1).writeUint8(a&63|128,c+2),c+=3):2097152>a?(b.writeUint8(a>>18&7|240,c).writeUint8(a>>12&63|128,c+1).writeUint8(a>>6&63|128,c+2).writeUint8(a&63|128,c+3),c+=4):67108864>a?(b.writeUint8(a>>24&3|248,c).writeUint8(a>>18&63|128,c+1).writeUint8(a>>12&63|128,c+2).writeUint8(a>>6&63|128,c+3).writeUint8(a&63|128,c+4),c+=5):2147483648>a?(b.writeUint8(a>>30&1|252,c).writeUint8(a>>24&63|128,c+1).writeUint8(a>>18&63|128,c+2).writeUint8(a>>12&63|128,c+3).writeUint8(a>>6&63|128,c+4).writeUint8(a&63|
128,c+5),c+=6):l(Error("Cannot encode UTF8 character: charCode (0x"+a.toString(16)+") is too large (>= 0x80000000)"));return c-e};c.calculateUTF8Char=function(a){0>a&&l(Error("Cannot calculate length of UTF8 character: charCode ("+a+") is negative"));if(128>a)return 1;if(2048>a)return 2;if(65536>a)return 3;if(2097152>a)return 4;if(67108864>a)return 5;if(2147483648>a)return 6;l(Error("Cannot calculate length of UTF8 character: charCode (0x"+a.toString(16)+") is too large (>= 0x80000000)"))};c.a=function(a){a=
""+a;for(var b=0,d=0;d<a.length;d++)b+=c.calculateUTF8Char(a.charCodeAt(d));return b};c.prototype.writeUTF8String=function(a,b){var d="undefined"==typeof b,e=b="undefined"!=typeof b?b:this.offset,f=c.a(a);this.ensureCapacity(b+f);for(f=0;f<a.length;f++)b+=c.encodeUTF8Char(a.charCodeAt(f),this,b);return d?(this.offset=b,this):b-e};c.prototype.readUTF8String=function(a,b){var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;for(var e,f="",g=b,h=0;h<a;h++)e=c.decodeUTF8Char(this,b),b+=e.length,
f+=String.fromCharCode(e["char"]);return d?(this.offset=b,f):{string:f,length:b-g}};c.prototype.readUTF8StringBytes=function(a,b){var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;var e,f="",g=b;for(a=b+a;b<a;)e=c.decodeUTF8Char(this,b),b+=e.length,f+=String.fromCharCode(e["char"]);b!=a&&l(Error("Actual string length differs from the specified: "+((b>a?"+":"")+b-a)+" bytes"));return d?(this.offset=b,f):{string:f,length:b-g}};c.prototype.writeLString=function(a,b){a=""+a;var d="undefined"==
typeof b;b="undefined"!=typeof b?b:this.offset;var e=c.encodeUTF8Char(a.length,this,b),e=e+this.writeUTF8String(a,b+e);return d?(this.offset+=e,this):e};c.prototype.readLString=function(a){var b="undefined"==typeof a;a="undefined"!=typeof a?a:this.offset;var d=c.decodeUTF8Char(this,a);a=this.readUTF8String(d["char"],a+d.length);return b?(this.offset+=d.length+a.length,a.string):{string:a.string,length:d.length+a.length}};c.prototype.writeVString=function(a,b){a=""+a;var d="undefined"==typeof b;b=
"undefined"!=typeof b?b:this.offset;var e=this.writeVarint32(c.a(a),b),e=e+this.writeUTF8String(a,b+e);return d?(this.offset+=e,this):e};c.prototype.readVString=function(a){var b="undefined"==typeof a;a="undefined"!=typeof a?a:this.offset;var c=this.readVarint32(a);a=this.readUTF8StringBytes(c.value,a+c.length);return b?(this.offset+=c.length+a.length,a.string):{string:a.string,length:c.length+a.length}};c.prototype.writeCString=function(a,b){var c="undefined"==typeof b;b="undefined"!=typeof b?b:
this.offset;var e=this.writeUTF8String(""+a,b);this.writeUint8(0,b+e);return c?(this.offset+=e+1,this):e+1};c.prototype.readCString=function(a){var b="undefined"==typeof a;a="undefined"!=typeof a?a:this.offset;var d,e="",f=a;do d=c.decodeUTF8Char(this,a),a+=d.length,0!=d["char"]&&(e+=String.fromCharCode(d["char"]));while(0!=d["char"]);return b?(this.offset=a,e):{string:e,length:a-f}};c.prototype.writeJSON=function(a,b,c){c="function"==typeof c?c:JSON.stringify;return this.writeLString(c(a),b)};c.prototype.readJSON=
function(a,b){b="function"==typeof b?b:JSON.parse;var c=this.readLString(a);return"string"==typeof c?b(c):{data:b(c.string),length:c.length}};c.prototype.printDebug=function(a){for(var b=(this.array!=n?"ByteBuffer(offset="+this.offset+",markedOffset="+this.markedOffset+",length="+this.length+",capacity="+this.array.byteLength+")":"ByteBuffer(DESTROYED)")+"\n-------------------------------------------------------------------\n",c=this.toHex(16,m),e=this.toASCII(16,m),f=0;f<c.length;f++)b+=c[f]+" "+
e[f]+"\n";if(a===m)return b;"function"==typeof a?a(b):console.log(b)};c.prototype.toHex=function(a,b){if(this.array==n)return"DESTROYED";b=!!b;a="undefined"!=typeof a?parseInt(a,10):16;1>a&&(a=16);for(var c="",e=[],f=new Uint8Array(this.array),c=0==this.offset&&0==this.length?c+"|":0==this.length?c+">":0==this.offset?c+"<":c+" ",g=0;g<this.array.byteLength;g++){0<g&&0==g%a&&(e.push(c),c=" ");var h=f[g],h=h.toString(16).toUpperCase();2>h.length&&(h="0"+h);c+=h;c=g+1==this.offset&&g+1==this.length?
c+"|":g+1==this.offset?c+"<":g+1==this.length?c+">":c+" "}if(b)for(;c.length<3*a+1;)c+=" ";e.push(c);return b?e:e.join("\n")};c.prototype.toASCII=function(a,b){if(this.array==n)return"";b=!!b;a="undefined"!=typeof a?parseInt(a,10):16;1>a&&(a=16);for(var c="",e=[],f=new Uint8Array(this.array),g=0;g<this.array.byteLength;g++){0<g&&0==g%a&&(e.push(c),c="");var h=f[g],h=32<h&&127>h?String.fromCharCode(h):".",c=c+h}e.push(c);return b?e:e.join("\n")+"\n"};c.prototype.toString=function(){return this.array==
n?"ByteBuffer(DESTROYED)":"ByteBuffer(offset="+this.offset+",markedOffset="+this.markedOffset+",length="+this.length+",capacity="+this.array.byteLength+")"};c.prototype.toArrayBuffer=function(a){var b=this.clone();b.offset>b.length&&b.flip();var c=p;if(0<b.offset||b.length<b.array.byteLength)b.compact(),c=m;return a&&!c?b.copy().array:b.array};c.prototype.toBuffer=function(){if(s){var a=this.offset,b=this.length;if(a>b)var c=a,a=b,b=c;c=new Uint8Array(this.array);return new s(c.subarray(a,b))}l(Error("Conversion to Buffer is available under node.js only"))};
c.extend=function(a,b){"string"==typeof a&&"function"==typeof b?c.prototype[a]=b:l(Error("Cannot extend prototype with "+a+"="+b+" (exptected string and function)"))};return c}"undefined"!=typeof module&&module.exports?module.exports=t(require("long"),require("buffer")):"undefined"!=typeof define&&define.amd?define("ByteBuffer",["Math/Long"],function(h){return t(h)}):(r.dcodeIO||(r.dcodeIO={}),r.dcodeIO.ByteBuffer=t(dcodeIO.Long))})(this);
{
"name": "bytebuffer",
"version": "1.3.5",
"version": "1.3.6",
"author": "Daniel Wirtz <dcode@dcode.io>",

@@ -5,0 +5,0 @@ "description": "ByteBuffer.js: A Java-like, Netty-inspired ByteBuffer implementation using typed arrays.",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc