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.3 to 1.3.4

86

ByteBuffer.min.js

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

function l(r){throw r;}var m=!0,n=null,p=!1;
(function(r){function s(g){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}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();
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 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+": 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 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),e=0,
f,k=0;do e==c.MAX_VARINT32_BYTES&&l(Error("Cannot read Varint32 from "+this+"@"+a+": Number of bytes is larger than "+c.MAX_VARINT32_BYTES)),f=d[a+e],k|=(f&127)<<7*e>>>0,++e;while(f&128);k|=0;return b?(this.offset+=e,k):{value:k,length:e}};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 e=a.toInt()>>>0,f=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]=f>>>21|128;case 7:h[b+6]=f>>>14|128;case 6:h[b+5]=f>>>7|128;case 5:h[b+4]=f|128;case 4:h[b+3]=e>>>21|128;case 3:h[b+2]=e>>>14|128;case 2:h[b+1]=e>>>7|128;case 1:h[b+0]=e|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),
f,k=0,q=0,h;h=c[a++];f=h&127;h&128&&(h=c[a++],f|=(h&127)<<7,h&128&&(h=c[a++],f|=(h&127)<<14,h&128&&(h=c[a++],f|=(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(f,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,f,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),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),k=a.readUint8(b+3),c=(d&7)<<18|(c&63)<<12|(f&63)<<6|k&63,b+=4):248==(d&252)?(c=a.readUint8(b+1),f=a.readUint8(b+2),k=a.readUint8(b+
3),q=a.readUint8(b+4),c=(d&3)<<24|(c&63)<<18|(f&63)<<12|(k&63)<<6|q&63,b+=5):252==(d&254)?(c=a.readUint8(b+1),f=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|(f&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 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="",k=b,g=0;g<a;g++)e=c.decodeUTF8Char(this,b),b+=e.length,f+=String.fromCharCode(e["char"]);return d?(this.offset=b,f):{string:f,length:b-k}};c.prototype.readUTF8StringBytes=function(a,b){var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;var e,f="",k=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-k}};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+" ",k=0;k<this.array.byteLength;k++){0<
k&&0==k%a&&(e.push(c),c=" ");var g=f[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+=" ";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),k=0;k<this.array.byteLength;k++){0<k&&0==k%a&&(e.push(c),c="");var g=f[k],
g=32<g&&127>g?String.fromCharCode(g):".",c=c+g}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(){try{require("buffer");var a=this.offset,b=this.length;if(a>b)var c=a,a=b,b=c;var e=new Uint8Array(this.array);return new Buffer(e.subarray(a,b))}catch(f){l(f)}};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=s(require("long")):"undefined"!=typeof define&&define.amd?define("ByteBuffer",["Math/Long"],function(g){return s(g)}):
(r.dcodeIO||(r.dcodeIO={}),r.dcodeIO.ByteBuffer=s(dcodeIO.Long))})(this);
(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 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+": 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 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),e=0,f,k=0;do e==c.MAX_VARINT32_BYTES&&l(Error("Cannot read Varint32 from "+this+"@"+a+": Number of bytes is larger than "+c.MAX_VARINT32_BYTES)),f=d[a+e],k|=(f&127)<<7*e>>>0,++e;while(f&128);k|=0;return b?(this.offset+=e,k):{value:k,
length:e}};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 e=a.toInt()>>>0,f=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]=f>>>21|128;case 7:h[b+6]=f>>>14|128;case 6:h[b+5]=f>>>7|128;case 5:h[b+4]=f|128;case 4:h[b+3]=e>>>21|128;case 3:h[b+2]=e>>>14|128;case 2:h[b+1]=e>>>7|128;case 1:h[b+0]=e|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),f,k=0,q=0,h;h=c[a++];f=h&127;h&128&&(h=c[a++],f|=(h&127)<<7,h&128&&(h=c[a++],f|=(h&127)<<14,h&128&&(h=c[a++],f|=(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(f,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,f,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),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),k=a.readUint8(b+3),c=(d&7)<<18|(c&63)<<12|(f&63)<<6|k&63,b+=4):248==(d&252)?(c=a.readUint8(b+1),f=a.readUint8(b+2),k=a.readUint8(b+3),q=a.readUint8(b+4),c=(d&3)<<24|(c&63)<<18|(f&63)<<12|(k&63)<<6|q&63,b+=5):252==(d&254)?(c=a.readUint8(b+1),f=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|(f&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 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="",k=b,g=0;g<a;g++)e=c.decodeUTF8Char(this,b),b+=e.length,f+=String.fromCharCode(e["char"]);return d?(this.offset=b,f):{string:f,
length:b-k}};c.prototype.readUTF8StringBytes=function(a,b){var d="undefined"==typeof b;b="undefined"!=typeof b?b:this.offset;var e,f="",k=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-k}};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+" ",k=0;k<this.array.byteLength;k++){0<k&&0==k%a&&(e.push(c),c=" ");var g=f[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+=" ";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),k=0;k<this.array.byteLength;k++){0<k&&0==k%a&&(e.push(c),c="");var g=f[k],g=32<g&&127>g?String.fromCharCode(g):".",c=c+g}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(g){return t(g)}):(r.dcodeIO||(r.dcodeIO={}),r.dcodeIO.ByteBuffer=t(dcodeIO.Long))})(this);

@@ -10,3 +10,10 @@ /**

* @constructor
* @extends Array
*/
var Buffer = function(size) {};
/**
* @param {*} buf
* @return {boolean}
*/
Buffer.isBuffer = function(buf) {};
{
"name": "bytebuffer",
"version": "1.3.3",
"version": "1.3.4",
"author": "Daniel Wirtz <dcode@dcode.io>",

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

"dependencies": {
"long": ">=1.1.2"
"long": "latest"
},
"devDependencies": {
"nodeunit": ">=0.7",
"preprocessor": ">=1.0.2",
"closurecompiler": ">=1.1"
"testjs": "latest",
"preprocessor": "latest",
"closurecompiler": "latest"
},
"license": "Apache License, Version 2.0",
"license": "Apache-2.0",
"engines": {

@@ -30,3 +30,3 @@ "node": ">=0.8"

"prepublish": "npm test",
"test": "nodeunit tests/suite.js",
"test": "node node_modules/testjs/bin/testjs tests/suite.js",

@@ -33,0 +33,0 @@ "make": "npm run-script build && npm run-script compile && npm run-script noexpose && npm test && npm run-script jsdoc",

@@ -63,11 +63,3 @@ /*

var suite = {
setUp: function (callback) {
callback();
},
tearDown: function (callback) {
callback();
},
"init": function(test) {

@@ -117,2 +109,9 @@ test.ok(typeof ByteBuffer == "function");

},
"wrap(Buffer)": function(test) {
var b = new Buffer("abc", "utf8");
var bb = ByteBuffer.wrap(b);
test.equal(bb.toHex(), "<61 62 63>");
test.done();
},

@@ -351,3 +350,3 @@ "resize": function(test) {

bb.flip();
test.equals(0x12345678, bb.readUint32());
test.equal(0x12345678, bb.readUint32());
test.done();

@@ -360,3 +359,3 @@ },

bb.flip();
test.equals(0.5, bb.readFloat32()); // 0.5 remains 0.5 if Float32
test.equal(0.5, bb.readFloat32()); // 0.5 remains 0.5 if Float32
test.done();

@@ -376,3 +375,3 @@ },

bb.flip();
test.equals(0.1, bb.readFloat64()); // would be 0.10000000149011612 if Float32
test.equal(0.1, bb.readFloat64()); // would be 0.10000000149011612 if Float32
test.done();

@@ -605,3 +604,3 @@ },

test.equal(bb.offset, 3);
test.equals(bb.length, 0);
test.equal(bb.length, 0);
bb.flip();

@@ -621,3 +620,3 @@ test.equal(bb.toHex(), "<02 61 62>00 ");

test.equal(bb.offset, 3);
test.equals(bb.length, 0);
test.equal(bb.length, 0);
bb.flip();

@@ -717,5 +716,5 @@ test.equal(bb.toHex(), "<02 61 62>00 ");

dec = ByteBuffer.decodeUTF8Char(bb, 0);
test.equals(chars[i], dec['char']);
test.equals(ByteBuffer.calculateUTF8Char(chars[i]), dec["length"]);
test.equals(String.fromCharCode(chars[i]), String.fromCharCode(dec['char']));
test.equal(chars[i], dec['char']);
test.equal(ByteBuffer.calculateUTF8Char(chars[i]), dec["length"]);
test.equal(String.fromCharCode(chars[i]), String.fromCharCode(dec['char']));
}

@@ -737,5 +736,5 @@ test.throws(function() {

"protobuf.js issue 19": function(test) {
"pbjsi19": function(test) {
// test that this issue is fixed: https://github.com/dcodeIO/ProtoBuf.js/issues/19
var bb = new ByteBuffer(17);
var bb = new ByteBuffer(9); // Trigger resize to 18 in writeVarint64
bb.writeVarint32(16);

@@ -749,3 +748,3 @@ bb.writeVarint32(2);

bb.writeVarint64(ByteBuffer.Long.fromString("1235455123"));
test.equals(bb.toHex(17), ">10 02 18 00 20 80 B0 D9 B4 E8 27 28 93 99 8E CD 04<");
test.equal(bb.toHex(18), ">10 02 18 00 20 80 B0 D9 B4 E8 27 28 93 99 8E CD 04<00 ");
test.done();

@@ -752,0 +751,0 @@ },

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

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