msgpack-lite
Advanced tools
Comparing version 0.1.20 to 0.1.26
@@ -1,2 +0,2 @@ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.msgpack=t()}}(function(){return function t(r,e,n){function o(f,u){if(!e[f]){if(!r[f]){var a="function"==typeof require&&require;if(!u&&a)return a(f,!0);if(i)return i(f,!0);var s=new Error("Cannot find module '"+f+"'");throw s.code="MODULE_NOT_FOUND",s}var c=e[f]={exports:{}};r[f][0].call(c.exports,function(t){var e=r[f][1][t];return o(e?e:t)},c,c.exports,t,r,e,n)}return e[f].exports}for(var i="function"==typeof require&&require,f=0;f<n.length;f++)o(n[f]);return o}({1:[function(t,r,e){e.encode=t("./encode").encode,e.decode=t("./decode").decode,e.Encoder=t("./encoder").Encoder,e.Decoder=t("./decoder").Decoder,e.createCodec=t("./ext").createCodec,e.codec=t("./codec").codec},{"./codec":4,"./decode":6,"./decoder":7,"./encode":9,"./encoder":10,"./ext":13}],2:[function(t,r,e){function n(t,r){for(var e=this,n=r||0,o=t.length,i=0;o>i;i++){var f=t.charCodeAt(i);128>f?e[n++]=f:2048>f?(e[n++]=192|f>>6,e[n++]=128|63&f):(e[n++]=224|f>>12,e[n++]=128|f>>6&63,e[n++]=128|63&f)}return n-r}function o(t,r){var e=this,n=t-0||0;r||(r=e.length);var o=r-t;o>p&&(o=p);for(var i=[];r>n;){for(var f=new Array(o),u=0;o>u&&r>n;){var a=e[n++];a=128>a?a:224>a?(63&a)<<6|63&e[n++]:(63&a)<<12|(63&e[n++])<<6|63&e[n++],f[u++]=a}o>u&&(f=f.slice(0,u)),i.push(String.fromCharCode.apply("",f))}return i.length>1?i.join(""):i.length?i.shift():""}function i(t){var r=0;return Array.prototype.forEach.call(t,function(t){var e=t.charCodeAt(0);r+=128>e?1:2048>e?2:3}),r}function f(t,r,e,n){var o;e||(e=0),n||0===n||(n=this.length),r||(r=0);var i=n-e;if(t===this&&r>e&&n>r)for(o=i-1;o>=0;o--)t[o+r]=this[o+e];else for(o=0;i>o;o++)t[o+r]=this[o+e];return i}function u(t,r){new c(this,r,t)}function a(t,r){new h(this,r,t)}var s=t("int64-buffer"),c=s.Uint64BE,h=s.Int64BE,p=8192;e.writeString=n,e.readString=o,e.byteLength=i,e.copy=f,e.writeUint64BE=u,e.writeInt64BE=a},{"int64-buffer":26}],3:[function(t,r,e){function n(){}e.BufferShortageError=n,n.prototype=Error.prototype},{}],4:[function(t,r,e){e.codec={preset:t("./ext").createCodec({preset:!0})}},{"./ext":13}],5:[function(t,r,e){(function(r){function n(t){return this instanceof n?void(t&&(this.options=t,t.codec&&(this.codec=t.codec))):new n(t)}e.DecodeBuffer=n;var o=t("./codec").codec.preset,i=t("./buffer-shortage").BufferShortageError;n.prototype.offset=0,n.prototype.push=function(t){var r=this.buffers||(this.buffers=[]);r.push(t)},n.prototype.codec=o,n.prototype.write=function(t){var e=this.offset?this.buffer.slice(this.offset):this.buffer;this.buffer=e?t?r.concat([e,t]):e:t,this.offset=0},n.prototype.read=function(){var t=this.buffers&&this.buffers.length;return t?(this.flush(),this.pull()):this.fetch()},n.prototype.pull=function(){var t=this.buffers||(this.buffers=[]);return t.shift()},n.prototype.fetch=function(){return this.codec.decode(this)},n.prototype.flush=function(){for(;this.offset<this.buffer.length;){var t,r=this.offset;try{t=this.fetch()}catch(e){if(!(e instanceof i))throw e;this.offset=r;break}this.push(t)}}}).call(this,t("buffer").Buffer)},{"./buffer-shortage":3,"./codec":4,buffer:21}],6:[function(t,r,e){function n(t,r){var e=new o(r);return e.write(t),e.read()}e.decode=n;var o=t("./decode-buffer").DecodeBuffer},{"./decode-buffer":5}],7:[function(t,r,e){function n(t){return this instanceof n?void i.call(this,t):new n(t)}e.Decoder=n;var o=t("event-lite"),i=t("./decode-buffer").DecodeBuffer;n.prototype=new i,o.mixin(n.prototype),n.prototype.decode=function(t){arguments.length&&this.write(t),this.flush()},n.prototype.push=function(t){this.emit("data",t)},n.prototype.end=function(t){this.decode(t),this.emit("end")}},{"./decode-buffer":5,"event-lite":24}],8:[function(t,r,e){(function(r){function n(t){return this instanceof n?void(t&&(this.options=t,t.codec&&(this.codec=t.codec))):new n(t)}e.EncodeBuffer=n;var o=t("./codec").codec.preset,i=2048,f=65536;n.prototype.offset=0,n.prototype.start=0,n.prototype.push=function(t){var r=this.buffers||(this.buffers=[]);r.push(t)},n.prototype.codec=o,n.prototype.write=function(t){this.codec.encode(this,t)},n.prototype.read=function(){var t=this.buffers&&this.buffers.length;return t?(this.flush(),this.pull()):this.fetch()},n.prototype.pull=function(){var t=this.buffers||(this.buffers=[]),e=t.length>1?r.concat(t):t[0];return t.length=0,e},n.prototype.fetch=function(){var t=this.start;return t<this.offset?(this.start=this.offset,this.buffer.slice(t,this.offset)):void 0},n.prototype.flush=function(){var t=this.fetch();t&&this.push(t)},n.prototype.reserve=function(t){if(this.buffer){var e=this.buffer.length;if(this.offset+t<e)return;this.flush(),t=Math.max(t,Math.min(2*e,f))}t=t>i?t:i,this.buffer=new r(t),this.start=0,this.offset=0},n.prototype.send=function(t){var r=this.offset+t.length;this.buffer&&r<this.buffer.length?(t.copy(this.buffer,this.offset),this.offset=r):(this.flush(),this.push(t))}}).call(this,t("buffer").Buffer)},{"./codec":4,buffer:21}],9:[function(t,r,e){function n(t,r){var e=new o(r);return e.write(t),e.read()}e.encode=n;var o=t("./encode-buffer").EncodeBuffer},{"./encode-buffer":8}],10:[function(t,r,e){function n(t){return this instanceof n?void i.call(this,t):new n(t)}e.Encoder=n;var o=t("event-lite"),i=t("./encode-buffer").EncodeBuffer;n.prototype=new i,o.mixin(n.prototype),n.prototype.encode=function(t){this.write(t),this.emit("data",this.read())},n.prototype.end=function(t){arguments.length&&this.encode(t),this.flush(),this.emit("end")}},{"./encode-buffer":8,"event-lite":24}],11:[function(t,r,e){function n(t,r){return this instanceof n?(this.buffer=t,void(this.type=r)):new n(t,r)}e.ExtBuffer=n},{}],12:[function(t,r,e){(function(r){function n(r){function e(r){return d||(d=t("./encode").encode),d(r)}function n(r){return y||(y=t("./decode").decode),y(r)}r.addExtPacker(14,Error,[a,e]),r.addExtPacker(1,EvalError,[a,e]),r.addExtPacker(2,RangeError,[a,e]),r.addExtPacker(3,ReferenceError,[a,e]),r.addExtPacker(4,SyntaxError,[a,e]),r.addExtPacker(5,TypeError,[a,e]),r.addExtPacker(6,URIError,[a,e]),r.addExtUnpacker(14,[n,s(Error)]),r.addExtUnpacker(1,[n,s(EvalError)]),r.addExtUnpacker(2,[n,s(RangeError)]),r.addExtUnpacker(3,[n,s(ReferenceError)]),r.addExtUnpacker(4,[n,s(SyntaxError)]),r.addExtUnpacker(5,[n,s(TypeError)]),r.addExtUnpacker(6,[n,s(URIError)]),r.addExtPacker(10,RegExp,[f,e]),r.addExtPacker(11,Boolean,[i,e]),r.addExtPacker(12,String,[i,e]),r.addExtPacker(13,Date,[Number,e]),r.addExtPacker(15,Number,[i,e]),r.addExtUnpacker(10,[n,u]),r.addExtUnpacker(11,[n,c(Boolean)]),r.addExtUnpacker(12,[n,c(String)]),r.addExtUnpacker(13,[n,c(Date)]),r.addExtUnpacker(15,[n,c(Number)]),"undefined"!=typeof Uint8Array&&(r.addExtPacker(17,Int8Array,o),r.addExtPacker(18,Uint8Array,o),r.addExtPacker(19,Int16Array,h),r.addExtPacker(20,Uint16Array,h),r.addExtPacker(21,Int32Array,h),r.addExtPacker(22,Uint32Array,h),r.addExtPacker(23,Float32Array,h),r.addExtUnpacker(17,c(Int8Array)),r.addExtUnpacker(18,c(Uint8Array)),r.addExtUnpacker(19,[l,c(Int16Array)]),r.addExtUnpacker(20,[l,c(Uint16Array)]),r.addExtUnpacker(21,[l,c(Int32Array)]),r.addExtUnpacker(22,[l,c(Uint32Array)]),r.addExtUnpacker(23,[l,c(Float32Array)]),"undefined"!=typeof Float64Array&&(r.addExtPacker(24,Float64Array,h),r.addExtUnpacker(24,[l,c(Float64Array)])),"undefined"!=typeof Uint8ClampedArray&&(r.addExtPacker(25,Uint8ClampedArray,o),r.addExtUnpacker(25,c(Uint8ClampedArray))),r.addExtPacker(26,ArrayBuffer,p),r.addExtPacker(29,DataView,h),r.addExtUnpacker(26,l),r.addExtUnpacker(29,[l,c(DataView)]))}function o(t){return new r(t)}function i(t){return t.valueOf()}function f(t){t=RegExp.prototype.toString.call(t).split("/"),t.shift();var r=[t.pop()];return r.unshift(t.join("/")),r}function u(t){return RegExp.apply(null,t)}function a(t){var r={};for(var e in g)r[e]=t[e];return r}function s(t){return function(r){var e=new t;for(var n in g)e[n]=r[n];return e}}function c(t){return function(r){return new t(r)}}function h(t){return new r(new Uint8Array(t.buffer))}function p(t){return new r(new Uint8Array(t))}function l(t){return new Uint8Array(t).buffer}e.setExtPreset=n;var d,y,g={name:1,message:1,stack:1,columnNumber:1,fileName:1,lineNumber:1}}).call(this,t("buffer").Buffer)},{"./decode":6,"./encode":9,buffer:21}],13:[function(t,r,e){function n(t){return this instanceof n?(this.extPackers={},this.extUnpackers=[],this.encode=c.getEncoder(t),this.decode=s.getDecoder(t),void(t&&t.preset&&a.setExtPreset(this))):new n(t)}function o(t){return new n(t)}function i(t){function r(t,r){return r(t)}return t=t.slice(),function(e){return t.reduce(r,e)}}var f=t("isarray");e.createCodec=o;var u=t("./ext-buffer").ExtBuffer,a=t("./ext-preset"),s=t("./read-core"),c=t("./write-core");n.prototype.addExtPacker=function(t,r,e){function n(r){var n=e(r);return new u(n,t)}f(e)&&(e=i(e));var o=r.name;if(o&&"Object"!==o)this.extPackers[o]=n;else{var a=this.extEncoderList||(this.extEncoderList=[]);a.unshift([r,n])}},n.prototype.addExtUnpacker=function(t,r){this.extUnpackers[t]=f(r)?i(r):r},n.prototype.getExtPacker=function(t){var r=t.constructor,e=r&&r.name&&this.extPackers[r.name];if(e)return e;var n=this.extEncoderList;if(n)for(var o=n.length,i=0;o>i;i++){var f=n[i];if(r===f[0])return f[1]}},n.prototype.getExtUnpacker=function(t){function r(r){return new u(r,t)}return this.extUnpackers[t]||r}},{"./ext-buffer":11,"./ext-preset":12,"./read-core":14,"./write-core":17,isarray:27}],14:[function(t,r,e){function n(t){function r(t){var r=o(t),n=e[r];if(!n)throw new Error("Invalid type: "+(r?"0x"+r.toString(16):r));return n(t)}var e=i.getReadToken(t);return r}e.getDecoder=n;var o=t("./read-format").readUint8,i=t("./read-token")},{"./read-format":15,"./read-token":16}],15:[function(t,r,e){(function(r){function n(t){var e={map:o,array:i,str:f,bin:u,ext:a,uint8:s,uint16:c,uint32:h(4,r.prototype.readUInt32BE),uint64:h(8,p),int8:h(1,r.prototype.readInt8),int16:h(2,r.prototype.readInt16BE),int32:h(4,r.prototype.readInt32BE),int64:h(8,l),float32:h(4,g),float64:h(8,v)};return t&&t.int64&&(e.uint64=h(8,d),e.int64=h(8,y)),e}function o(t,r){var e,n={},o=new Array(r),i=new Array(r),f=t.codec.decode;for(e=0;r>e;e++)o[e]=f(t),i[e]=f(t);for(e=0;r>e;e++)n[o[e]]=i[e];return n}function i(t,r){for(var e=new Array(r),n=t.codec.decode,o=0;r>o;o++)e[o]=n(t);return e}function f(t,e){var n=t.offset,o=t.offset=n+e,i=t.buffer;if(o>i.length)throw new m;return x||!r.isBuffer(i)?U.readString.call(i,n,o):i.toString("utf-8",n,o)}function u(t,r){var e=t.offset,n=t.offset=e+r;if(n>t.buffer.length)throw new m;return w.call(t.buffer,e,n)}function a(t,r){var e=t.offset,n=t.offset=e+r+1;if(n>t.buffer.length)throw new m;var o=t.buffer[e],i=t.codec.getExtUnpacker(o);if(!i)throw new Error("Invalid ext type: "+(o?"0x"+o.toString(16):o));var f=w.call(t.buffer,e+1,n);return i(f)}function s(t){var r=t.buffer;if(t.offset>=r.length)throw new m;return r[t.offset++]}function c(t){var r=t.buffer;if(t.offset+2>r.length)throw new m;return r[t.offset++]<<8|r[t.offset++]}function h(t,r){return function(e){var n=e.offset,o=e.offset=n+t;if(o>e.buffer.length)throw new m;return r.call(e.buffer,n,P)}}function p(t){return new A(this,t).toNumber()}function l(t){return new B(this,t).toNumber()}function d(t){return new A(this,t)}function y(t){return new B(this,t)}function g(t){return this.readFloatBE?this.readFloatBE(t):E.read(this,t,!1,23,4)}function v(t){return this.readDoubleBE?this.readDoubleBE(t):E.read(this,t,!1,52,8)}function w(t,e){var n=this.slice||Array.prototype.slice,o=n.call(this,t,e);return r.isBuffer(o)||(o=r(o)),o}var E=t("ieee754"),b=t("int64-buffer"),A=b.Uint64BE,B=b.Int64BE;e.getReadFormat=n,e.readUint8=s;var U=t("./buffer-lite"),m=t("./buffer-shortage").BufferShortageError,x="TYPED_ARRAY_SUPPORT"in r,P=!0}).call(this,t("buffer").Buffer)},{"./buffer-lite":2,"./buffer-shortage":3,buffer:21,ieee754:25,"int64-buffer":26}],16:[function(t,r,e){function n(t){var r=s.getReadFormat(t);return t&&t.useraw?i(r):o(r)}function o(t){var r,e=new Array(256);for(r=0;127>=r;r++)e[r]=f(r);for(r=128;143>=r;r++)e[r]=a(r-128,t.map);for(r=144;159>=r;r++)e[r]=a(r-144,t.array);for(r=160;191>=r;r++)e[r]=a(r-160,t.str);for(e[192]=f(null),e[193]=null,e[194]=f(!1),e[195]=f(!0),e[196]=u(t.uint8,t.bin),e[197]=u(t.uint16,t.bin),e[198]=u(t.uint32,t.bin),e[199]=u(t.uint8,t.ext),e[200]=u(t.uint16,t.ext),e[201]=u(t.uint32,t.ext),e[202]=t.float32,e[203]=t.float64,e[204]=t.uint8,e[205]=t.uint16,e[206]=t.uint32,e[207]=t.uint64,e[208]=t.int8,e[209]=t.int16,e[210]=t.int32,e[211]=t.int64,e[212]=a(1,t.ext),e[213]=a(2,t.ext),e[214]=a(4,t.ext),e[215]=a(8,t.ext),e[216]=a(16,t.ext),e[217]=u(t.uint8,t.str),e[218]=u(t.uint16,t.str),e[219]=u(t.uint32,t.str),e[220]=u(t.uint16,t.array),e[221]=u(t.uint32,t.array),e[222]=u(t.uint16,t.map),e[223]=u(t.uint32,t.map),r=224;255>=r;r++)e[r]=f(r-256);return e}function i(t){var r,e=n(t).slice();for(e[217]=e[196],e[218]=e[197],e[219]=e[198],r=160;191>=r;r++)e[r]=a(r-160,t.bin);return e}function f(t){return function(){return t}}function u(t,r){return function(e){var n=t(e);return r(e,n)}}function a(t,r){return function(e){return r(e,t)}}var s=t("./read-format");e.getReadToken=n},{"./read-format":15}],17:[function(t,r,e){function n(t){function r(t,r){var n=e[typeof r];if(!n)throw new Error('Unsupported type "'+typeof r+'": '+r);n(t,r)}var e=o.getWriteType(t);return r}e.getEncoder=n;var o=t("./write-type")},{"./write-type":19}],18:[function(t,r,e){(function(r){function n(t){return l||t&&t.safe?i():o()}function o(){var t=h.slice();return t[196]=f(196),t[197]=u(197),t[198]=a(198),t[199]=f(199),t[200]=u(200),t[201]=a(201),t[202]=s(202,4,r.prototype.writeFloatBE,!0),t[203]=s(203,8,r.prototype.writeDoubleBE,!0),t[204]=f(204),t[205]=u(205),t[206]=a(206),t[207]=s(207,8,c.writeUint64BE),t[208]=f(208),t[209]=u(209),t[210]=a(210),t[211]=s(211,8,c.writeUint64BE),t[217]=f(217),t[218]=u(218),t[219]=a(219),t[220]=u(220),t[221]=a(221),t[222]=u(222),t[223]=a(223),t}function i(){var t=h.slice();return t[196]=s(196,1,r.prototype.writeUInt8),t[197]=s(197,2,r.prototype.writeUInt16BE),t[198]=s(198,4,r.prototype.writeUInt32BE),t[199]=s(199,1,r.prototype.writeUInt8),t[200]=s(200,2,r.prototype.writeUInt16BE),t[201]=s(201,4,r.prototype.writeUInt32BE),t[202]=s(202,4,r.prototype.writeFloatBE),t[203]=s(203,8,r.prototype.writeDoubleBE),t[204]=s(204,1,r.prototype.writeUInt8),t[205]=s(205,2,r.prototype.writeUInt16BE),t[206]=s(206,4,r.prototype.writeUInt32BE),t[207]=s(207,8,c.writeUint64BE),t[208]=s(208,1,r.prototype.writeInt8),t[209]=s(209,2,r.prototype.writeInt16BE),t[210]=s(210,4,r.prototype.writeInt32BE),t[211]=s(211,8,c.writeUint64BE),t[217]=s(217,1,r.prototype.writeUInt8),t[218]=s(218,2,r.prototype.writeUInt16BE),t[219]=s(219,4,r.prototype.writeUInt32BE),t[220]=s(220,2,r.prototype.writeUInt16BE),t[221]=s(221,4,r.prototype.writeUInt32BE),t[222]=s(222,2,r.prototype.writeUInt16BE),t[223]=s(223,4,r.prototype.writeUInt32BE),t}function f(t){return function(r,e){r.reserve(2);var n=r.buffer,o=r.offset;n[o++]=t,n[o++]=e,r.offset=o}}function u(t){return function(r,e){r.reserve(3);var n=r.buffer,o=r.offset;n[o++]=t,n[o++]=e>>>8,n[o++]=e,r.offset=o}}function a(t){return function(r,e){r.reserve(5);var n=r.buffer,o=r.offset;n[o++]=t,n[o++]=e>>>24,n[o++]=e>>>16,n[o++]=e>>>8,n[o++]=e,r.offset=o}}function s(t,r,e,n){return function(o,i){o.reserve(r+1),o.buffer[o.offset++]=t,e.call(o.buffer,i,o.offset,n),o.offset+=r}}var c=t("./buffer-lite"),h=t("./write-uint8").uint8,p="TYPED_ARRAY_SUPPORT"in r,l=p&&!r.TYPED_ARRAY_SUPPORT;e.getWriteToken=n}).call(this,t("buffer").Buffer)},{"./buffer-lite":2,"./write-uint8":20,buffer:21}],19:[function(t,r,e){(function(r){function n(t){function e(t,r){var e=r?195:194;m[e](t,r)}function n(t,r){var e,n=0|r;return r!==n?(e=203,void m[e](t,r)):(e=n>=-32&&127>=n?255&n:n>=0?255>=n?204:65535>=n?205:206:n>=-128?208:n>=-32768?209:210,void m[e](t,n))}function f(t,r){var e=207;m[e](t,r.toArray())}function l(t,r){var e=211;m[e](t,r.toArray())}function y(t,r){var e=r.length,n=5+3*e;t.reserve(n);var i=32>e?1:255>=e?2:65535>=e?3:5,f=t.offset+i;e=s.writeString.call(t.buffer,r,f);var u=32>e?1:255>=e?2:65535>=e?3:5;i!==u&&o(t,f,e,u-i);var a=1===u?160+e:3>=u?215+u:219;m[a](t,e),t.offset+=e}function g(t,e){if(null===e)return v(t,e);if(r.isBuffer(e))return E(t,e);if(i(e))return w(t,e);if(u.isUint64BE(e))return f(t,e);if(a.isInt64BE(e))return l(t,e);var n=t.codec.getExtPacker(e);return n&&(e=n(e)),e instanceof p?b(t,e):void A(t,e)}function v(t,r){var e=192;m[e](t,r)}function w(t,r){var e=r.length,n=16>e?144+e:65535>=e?220:221;m[n](t,e);for(var o=t.codec.encode,i=0;e>i;i++)o(t,r[i])}function E(t,r){var e=r.length,n=255>e?196:65535>=e?197:198;m[n](t,e),t.send(r)}function b(t,r){var e=r.buffer,n=e.length,o=d[n]||(255>n?199:65535>=n?200:201);m[o](t,n),h[r.type](t),t.send(e)}function A(t,r){var e=Object.keys(r),n=e.length,o=16>n?128+n:65535>=n?222:223;m[o](t,n);var i=t.codec.encode;e.forEach(function(e){i(t,e),i(t,r[e])})}function B(t,r){var e=r.length,n=5+3*e;t.reserve(n);var i=32>e?1:65535>=e?3:5,f=t.offset+i;e=s.writeString.call(t.buffer,r,f);var u=32>e?1:65535>=e?3:5;i!==u&&o(t,f,e,u-i);var a=32>e?160+e:65535>=e?218:219;m[a](t,e),t.offset+=e}function U(t,e){if(!r.isBuffer(e))return g(t,e);var n=e.length,o=32>n?160+n:65535>=n?218:219;m[o](t,n),t.send(e)}var m=c.getWriteToken(t),x={"boolean":e,"function":v,number:n,object:g,string:y,symbol:v,undefined:v};return t&&t.useraw&&(x.object=U,x.string=B),x}function o(t,r,e,n){var o=r+n,i=r+e;l?s.copy.call(t.buffer,t.buffer,o,r,i):t.buffer.copy(t.buffer,o,r,i)}var i=t("isarray"),f=t("int64-buffer"),u=f.Uint64BE,a=f.Int64BE,s=t("./buffer-lite"),c=t("./write-token"),h=t("./write-uint8").uint8,p=t("./ext-buffer").ExtBuffer,l="TYPED_ARRAY_SUPPORT"in r,d=[];d[1]=212,d[2]=213,d[4]=214,d[8]=215,d[16]=216,e.getWriteType=n}).call(this,t("buffer").Buffer)},{"./buffer-lite":2,"./ext-buffer":11,"./write-token":18,"./write-uint8":20,buffer:21,"int64-buffer":26,isarray:27}],20:[function(t,r,e){function n(t){return function(r){r.reserve(1),r.buffer[r.offset++]=t}}for(var o=e.uint8=new Array(256),i=0;255>=i;i++)o[i]=n(i)},{}],21:[function(t,r,e){(function(r){"use strict";function n(){try{var t=new Uint8Array(1);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(r){return!1}}function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t,r){if(o()<r)throw new RangeError("Invalid typed array length");return f.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=f.prototype):(null===t&&(t=new f(r)),t.length=r),t}function f(t,r,e){if(!(f.TYPED_ARRAY_SUPPORT||this instanceof f))return new f(t,r,e);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return c(this,t)}return u(this,t,r,e)}function u(t,r,e,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?l(t,r,e,n):"string"==typeof r?h(t,r,e):d(t,r)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number')}function s(t,r,e,n){return a(r),0>=r?i(t,r):void 0!==e?"string"==typeof n?i(t,r).fill(e,n):i(t,r).fill(e):i(t,r)}function c(t,r){if(a(r),t=i(t,0>r?0:0|y(r)),!f.TYPED_ARRAY_SUPPORT)for(var e=0;r>e;e++)t[e]=0;return t}function h(t,r,e){if("string"==typeof e&&""!==e||(e="utf8"),!f.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|v(r,e);return t=i(t,n),t.write(r,e),t}function p(t,r){var e=0|y(r.length);t=i(t,e);for(var n=0;e>n;n+=1)t[n]=255&r[n];return t}function l(t,r,e,n){if(r.byteLength,0>e||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return r=void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),f.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=f.prototype):t=p(t,r),t}function d(t,r){if(f.isBuffer(r)){var e=0|y(r.length);return t=i(t,e),0===t.length?t:(r.copy(t,0,0,e),t)}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||G(r.length)?i(t,0):p(t,r);if("Buffer"===r.type&&Q(r.data))return p(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function y(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t){return+t!=t&&(t=0),f.alloc(+t)}function v(t,r){if(f.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"binary":case"raw":case"raws":return e;case"utf8":case"utf-8":case void 0:return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return X(t).length;default:if(n)return V(t).length;r=(""+r).toLowerCase(),n=!0}}function w(t,r,e){var n=!1;if((void 0===r||0>r)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),0>=e)return"";if(e>>>=0,r>>>=0,r>=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,r,e);case"utf8":case"utf-8":return _(this,r,e);case"ascii":return I(this,r,e);case"binary":return T(this,r,e);case"base64":return R(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function E(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function b(t,r,e,n){function o(t,r){return 1===i?t[r]:t.readUInt16BE(r*i)}var i=1,f=t.length,u=r.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;i=2,f/=2,u/=2,e/=2}for(var a=-1,s=0;f>e+s;s++)if(o(t,e+s)===o(r,-1===a?0:s-a)){if(-1===a&&(a=s),s-a+1===u)return(e+a)*i}else-1!==a&&(s-=s-a),a=-1;return-1}function A(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;var i=r.length;if(i%2!==0)throw new Error("Invalid hex string");n>i/2&&(n=i/2);for(var f=0;n>f;f++){var u=parseInt(r.substr(2*f,2),16);if(isNaN(u))return f;t[e+f]=u}return f}function B(t,r,e,n){return Z(V(r,t.length-e),t,e,n)}function U(t,r,e,n){return Z(W(r),t,e,n)}function m(t,r,e,n){return U(t,r,e,n)}function x(t,r,e,n){return Z(X(r),t,e,n)}function P(t,r,e,n){return Z(J(r,t.length-e),t,e,n)}function R(t,r,e){return 0===r&&e===t.length?H.fromByteArray(t):H.fromByteArray(t.slice(r,e))}function _(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;e>o;){var i=t[o],f=null,u=i>239?4:i>223?3:i>191?2:1;if(e>=o+u){var a,s,c,h;switch(u){case 1:128>i&&(f=i);break;case 2:a=t[o+1],128===(192&a)&&(h=(31&i)<<6|63&a,h>127&&(f=h));break;case 3:a=t[o+1],s=t[o+2],128===(192&a)&&128===(192&s)&&(h=(15&i)<<12|(63&a)<<6|63&s,h>2047&&(55296>h||h>57343)&&(f=h));break;case 4:a=t[o+1],s=t[o+2],c=t[o+3],128===(192&a)&&128===(192&s)&&128===(192&c)&&(h=(15&i)<<18|(63&a)<<12|(63&s)<<6|63&c,h>65535&&1114112>h&&(f=h))}}null===f?(f=65533,u=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=u}return k(n)}function k(t){var r=t.length;if($>=r)return String.fromCharCode.apply(String,t);for(var e="",n=0;r>n;)e+=String.fromCharCode.apply(String,t.slice(n,n+=$));return e}function I(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;e>o;o++)n+=String.fromCharCode(127&t[o]);return n}function T(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;e>o;o++)n+=String.fromCharCode(t[o]);return n}function S(t,r,e){var n=t.length;(!r||0>r)&&(r=0),(!e||0>e||e>n)&&(e=n);for(var o="",i=r;e>i;i++)o+=q(t[i]);return o}function Y(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function D(t,r,e){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function C(t,r,e,n,o,i){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||i>r)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}function O(t,r,e,n){0>r&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);i>o;o++)t[e+o]=(r&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function L(t,r,e,n){0>r&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);i>o;o++)t[e+o]=r>>>8*(n?o:3-o)&255}function M(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(0>e)throw new RangeError("Index out of range")}function N(t,r,e,n,o){return o||M(t,r,e,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,r,e,n,23,4),e+4}function j(t,r,e,n,o){return o||M(t,r,e,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,r,e,n,52,8),e+8}function F(t){if(t=z(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function z(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function q(t){return 16>t?"0"+t.toString(16):t.toString(16)}function V(t,r){r=r||1/0;for(var e,n=t.length,o=null,i=[],f=0;n>f;f++){if(e=t.charCodeAt(f),e>55295&&57344>e){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(f+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(56320>e){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,128>e){if((r-=1)<0)break;i.push(e)}else if(2048>e){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(65536>e){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(1114112>e))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function W(t){for(var r=[],e=0;e<t.length;e++)r.push(255&t.charCodeAt(e));return r}function J(t,r){for(var e,n,o,i=[],f=0;f<t.length&&!((r-=2)<0);f++)e=t.charCodeAt(f),n=e>>8,o=e%256,i.push(o),i.push(n);return i}function X(t){return H.toByteArray(F(t))}function Z(t,r,e,n){for(var o=0;n>o&&!(o+e>=r.length||o>=t.length);o++)r[o+e]=t[o];return o}function G(t){return t!==t}var H=t("base64-js"),K=t("ieee754"),Q=t("isarray");e.Buffer=f,e.SlowBuffer=g,e.INSPECT_MAX_BYTES=50,f.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:n(),e.kMaxLength=o(),f.poolSize=8192,f._augment=function(t){return t.__proto__=f.prototype,t},f.from=function(t,r,e){return u(null,t,r,e)},f.TYPED_ARRAY_SUPPORT&&(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0})),f.alloc=function(t,r,e){return s(null,t,r,e)},f.allocUnsafe=function(t){return c(null,t)},f.allocUnsafeSlow=function(t){return c(null,t)},f.isBuffer=function(t){return!(null==t||!t._isBuffer)},f.compare=function(t,r){if(!f.isBuffer(t)||!f.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,n=r.length,o=0,i=Math.min(e,n);i>o;++o)if(t[o]!==r[o]){e=t[o],n=r[o];break}return n>e?-1:e>n?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(t,r){if(!Q(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;e++)r+=t[e].length;var n=f.allocUnsafe(r),o=0;for(e=0;e<t.length;e++){var i=t[e];if(!f.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},f.byteLength=v,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;t>r;r+=2)E(this,r,r+1);return this},f.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;t>r;r+=4)E(this,r,r+3),E(this,r+1,r+2);return this},f.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?_(this,0,t):w.apply(this,arguments)},f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:0===f.compare(this,t)},f.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},f.prototype.compare=function(t,r,e,n,o){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),0>r||e>t.length||0>n||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=e)return 0;if(n>=o)return-1;if(r>=e)return 1;if(r>>>=0,e>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,u=e-r,a=Math.min(i,u),s=this.slice(n,o),c=t.slice(r,e),h=0;a>h;++h)if(s[h]!==c[h]){i=s[h],u=c[h];break}return u>i?-1:i>u?1:0},f.prototype.indexOf=function(t,r,e){if("string"==typeof r?(e=r,r=0):r>2147483647?r=2147483647:-2147483648>r&&(r=-2147483648),r>>=0,0===this.length)return-1;if(r>=this.length)return-1;if(0>r&&(r=Math.max(this.length+r,0)),"string"==typeof t&&(t=f.from(t,e)),f.isBuffer(t))return 0===t.length?-1:b(this,t,r,e);if("number"==typeof t)return f.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,r):b(this,[t],r,e);throw new TypeError("val must be string, number or Buffer")},f.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},f.prototype.write=function(t,r,e,n){if(void 0===r)n="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r=0|r,isFinite(e)?(e=0|e,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||e>o)&&(e=o),t.length>0&&(0>e||0>r)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return A(this,t,r,e);case"utf8":case"utf-8":return B(this,t,r,e);case"ascii":return U(this,t,r,e);case"binary":return m(this,t,r,e);case"base64":return x(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;f.prototype.slice=function(t,r){var e=this.length;t=~~t,r=void 0===r?e:~~r,0>t?(t+=e,0>t&&(t=0)):t>e&&(t=e),0>r?(r+=e,0>r&&(r=0)):r>e&&(r=e),t>r&&(r=t);var n;if(f.TYPED_ARRAY_SUPPORT)n=this.subarray(t,r),n.__proto__=f.prototype;else{var o=r-t;n=new f(o,void 0);for(var i=0;o>i;i++)n[i]=this[i+t]}return n},f.prototype.readUIntLE=function(t,r,e){t=0|t,r=0|r,e||D(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n},f.prototype.readUIntBE=function(t,r,e){t=0|t,r=0|r,e||D(t,r,this.length);for(var n=this[t+--r],o=1;r>0&&(o*=256);)n+=this[t+--r]*o;return n},f.prototype.readUInt8=function(t,r){return r||D(t,1,this.length),this[t]},f.prototype.readUInt16LE=function(t,r){return r||D(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUInt16BE=function(t,r){return r||D(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUInt32LE=function(t,r){return r||D(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUInt32BE=function(t,r){return r||D(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readIntLE=function(t,r,e){t=0|t,r=0|r,e||D(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*r)), | ||
n},f.prototype.readIntBE=function(t,r,e){t=0|t,r=0|r,e||D(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i},f.prototype.readInt8=function(t,r){return r||D(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,r){r||D(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt16BE=function(t,r){r||D(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},f.prototype.readInt32LE=function(t,r){return r||D(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,r){return r||D(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readFloatLE=function(t,r){return r||D(t,4,this.length),K.read(this,t,!0,23,4)},f.prototype.readFloatBE=function(t,r){return r||D(t,4,this.length),K.read(this,t,!1,23,4)},f.prototype.readDoubleLE=function(t,r){return r||D(t,8,this.length),K.read(this,t,!0,52,8)},f.prototype.readDoubleBE=function(t,r){return r||D(t,8,this.length),K.read(this,t,!1,52,8)},f.prototype.writeUIntLE=function(t,r,e,n){if(t=+t,r=0|r,e=0|e,!n){var o=Math.pow(2,8*e)-1;C(this,t,r,e,o,0)}var i=1,f=0;for(this[r]=255&t;++f<e&&(i*=256);)this[r+f]=t/i&255;return r+e},f.prototype.writeUIntBE=function(t,r,e,n){if(t=+t,r=0|r,e=0|e,!n){var o=Math.pow(2,8*e)-1;C(this,t,r,e,o,0)}var i=e-1,f=1;for(this[r+i]=255&t;--i>=0&&(f*=256);)this[r+i]=t/f&255;return r+e},f.prototype.writeUInt8=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,1,255,0),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},f.prototype.writeUInt16LE=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},f.prototype.writeUInt16BE=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},f.prototype.writeUInt32LE=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):L(this,t,r,!0),r+4},f.prototype.writeUInt32BE=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):L(this,t,r,!1),r+4},f.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r=0|r,!n){var o=Math.pow(2,8*e-1);C(this,t,r,e,o-1,-o)}var i=0,f=1,u=0;for(this[r]=255&t;++i<e&&(f*=256);)0>t&&0===u&&0!==this[r+i-1]&&(u=1),this[r+i]=(t/f>>0)-u&255;return r+e},f.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r=0|r,!n){var o=Math.pow(2,8*e-1);C(this,t,r,e,o-1,-o)}var i=e-1,f=1,u=0;for(this[r+i]=255&t;--i>=0&&(f*=256);)0>t&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/f>>0)-u&255;return r+e},f.prototype.writeInt8=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,1,127,-128),f.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[r]=255&t,r+1},f.prototype.writeInt16LE=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},f.prototype.writeInt16BE=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},f.prototype.writeInt32LE=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):L(this,t,r,!0),r+4},f.prototype.writeInt32BE=function(t,r,e){return t=+t,r=0|r,e||C(this,t,r,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),f.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):L(this,t,r,!1),r+4},f.prototype.writeFloatLE=function(t,r,e){return N(this,t,r,!0,e)},f.prototype.writeFloatBE=function(t,r,e){return N(this,t,r,!1,e)},f.prototype.writeDoubleLE=function(t,r,e){return j(this,t,r,!0,e)},f.prototype.writeDoubleBE=function(t,r,e){return j(this,t,r,!1,e)},f.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&e>n&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(0>r)throw new RangeError("targetStart out of bounds");if(0>e||e>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var o,i=n-e;if(this===t&&r>e&&n>r)for(o=i-1;o>=0;o--)t[o+r]=this[o+e];else if(1e3>i||!f.TYPED_ARRAY_SUPPORT)for(o=0;i>o;o++)t[o+r]=this[o+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+i),r);return i},f.prototype.fill=function(t,r,e,n){if("string"==typeof t){if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),1===t.length){var o=t.charCodeAt(0);256>o&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t=255&t);if(0>r||this.length<r||this.length<e)throw new RangeError("Out of range index");if(r>=e)return this;r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0);var i;if("number"==typeof t)for(i=r;e>i;i++)this[i]=t;else{var u=f.isBuffer(t)?t:V(new f(t,n).toString()),a=u.length;for(i=0;e-r>i;i++)this[i+r]=u[i%a]}return this};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":22,ieee754:25,isarray:23}],22:[function(t,r,e){"use strict";function n(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;e>r;++r)a[r]=t[r],s[t.charCodeAt(r)]=r;s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63}function o(t){var r,e,n,o,i,f,u=t.length;if(u%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===t[u-2]?2:"="===t[u-1]?1:0,f=new c(3*u/4-i),n=i>0?u-4:u;var a=0;for(r=0,e=0;n>r;r+=4,e+=3)o=s[t.charCodeAt(r)]<<18|s[t.charCodeAt(r+1)]<<12|s[t.charCodeAt(r+2)]<<6|s[t.charCodeAt(r+3)],f[a++]=o>>16&255,f[a++]=o>>8&255,f[a++]=255&o;return 2===i?(o=s[t.charCodeAt(r)]<<2|s[t.charCodeAt(r+1)]>>4,f[a++]=255&o):1===i&&(o=s[t.charCodeAt(r)]<<10|s[t.charCodeAt(r+1)]<<4|s[t.charCodeAt(r+2)]>>2,f[a++]=o>>8&255,f[a++]=255&o),f}function i(t){return a[t>>18&63]+a[t>>12&63]+a[t>>6&63]+a[63&t]}function f(t,r,e){for(var n,o=[],f=r;e>f;f+=3)n=(t[f]<<16)+(t[f+1]<<8)+t[f+2],o.push(i(n));return o.join("")}function u(t){for(var r,e=t.length,n=e%3,o="",i=[],u=16383,s=0,c=e-n;c>s;s+=u)i.push(f(t,s,s+u>c?c:s+u));return 1===n?(r=t[e-1],o+=a[r>>2],o+=a[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=a[r>>10],o+=a[r>>4&63],o+=a[r<<2&63],o+="="),i.push(o),i.join("")}e.toByteArray=o,e.fromByteArray=u;var a=[],s=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array;n()},{}],23:[function(t,r,e){var n={}.toString;r.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],24:[function(t,r,e){function n(){return this instanceof n?void 0:new n}!function(t){function e(t){for(var r in s)t[r]=s[r];return t}function n(t,r){return u(this,t).push(r),this}function o(t,r){function e(){i.call(n,t,e),r.apply(this,arguments)}var n=this;return e.originalListener=r,u(n,t).push(e),n}function i(t,r){function e(t){return t!==r&&t.originalListener!==r}var n,o=this;if(arguments.length){if(r){if(n=u(o,t,!0)){if(n=n.filter(e),!n.length)return i.call(o,t);o[a][t]=n}}else if(n=o[a],n&&(delete n[t],!Object.keys(n).length))return i.call(o)}else delete o[a];return o}function f(t,r){function e(t){t.call(i)}function n(t){t.call(i,r)}function o(t){t.apply(i,s)}var i=this,f=u(i,t,!0);if(!f)return!1;var a=arguments.length;if(1===a)f.forEach(e);else if(2===a)f.forEach(n);else{var s=Array.prototype.slice.call(arguments,1);f.forEach(o)}return!!f.length}function u(t,r,e){if(!e||t[a]){var n=t[a]||(t[a]={});return n[r]||(n[r]=[])}}"undefined"!=typeof r&&(r.exports=t);var a="listeners",s={on:n,once:o,off:i,emit:f};e(t.prototype),t.mixin=e}(n)},{}],25:[function(t,r,e){e.read=function(t,r,e,n,o){var i,f,u=8*o-n-1,a=(1<<u)-1,s=a>>1,c=-7,h=e?o-1:0,p=e?-1:1,l=t[r+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=u;c>0;i=256*i+t[r+h],h+=p,c-=8);for(f=i&(1<<-c)-1,i>>=-c,c+=n;c>0;f=256*f+t[r+h],h+=p,c-=8);if(0===i)i=1-s;else{if(i===a)return f?NaN:(l?-1:1)*(1/0);f+=Math.pow(2,n),i-=s}return(l?-1:1)*f*Math.pow(2,i-n)},e.write=function(t,r,e,n,o,i){var f,u,a,s=8*i-o-1,c=(1<<s)-1,h=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,d=n?1:-1,y=0>r||0===r&&0>1/r?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,f=c):(f=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-f))<1&&(f--,a*=2),r+=f+h>=1?p/a:p*Math.pow(2,1-h),r*a>=2&&(f++,a/=2),f+h>=c?(u=0,f=c):f+h>=1?(u=(r*a-1)*Math.pow(2,o),f+=h):(u=r*Math.pow(2,h-1)*Math.pow(2,o),f=0));o>=8;t[e+l]=255&u,l+=d,u/=256,o-=8);for(f=f<<o|u,s+=o;s>0;t[e+l]=255&f,l+=d,f/=256,s-=8);t[e+l-d]|=128*y}},{}],26:[function(t,r,e){(function(t){var r,n;!function(e){function o(t,r,e,n,o){if(B&&U&&(r instanceof U&&(r=new B(r)),n instanceof U&&(n=new B(n))),!(r||e||n||y))return void(t.buffer=s(m,0));if(!i(r,e)){var a=y||Array;o=e,n=r,e=0,r=new a(8)}t.buffer=r,t.offset=e|=0,"undefined"!=typeof n&&("string"==typeof n?u(r,e,n,o||10):i(n,o)?f(r,e,n,o):"number"==typeof o?(h(r,e,n),h(r,e+4,o)):n>0?p(r,e,n):0>n?l(r,e,n):f(r,e,m,0))}function i(t,r){var e=t&&t.length;return r|=0,e&&e>=r+8&&"string"!=typeof t[r]}function f(t,r,e,n){r|=0,n|=0;for(var o=0;8>o;o++)t[r++]=255&e[n++]}function u(t,r,e,n){var o=0,i=e.length,f=0,u=0;"-"===e[0]&&o++;for(var a=o;i>o;){var s=parseInt(e[o++],n);if(!(s>=0))break;u=u*n+s,f=f*n+Math.floor(u/P),u%=P}a&&(f=~f,u?u=P-u:f++),h(t,r,f),h(t,r+4,u)}function a(t,r,e,n){var o="",i=c(t,r),f=c(t,r+4),u=n&&2147483648&i;for(u&&(i=~i,f=P-f),e=e||10;;){var a=i%e*P+f;if(i=Math.floor(i/e),f=Math.floor(a/e),o=(a%e).toString(e)+o,!i&&!f)break}return u&&(o="-"+o),o}function s(t,r){return Array.prototype.slice.call(t,r,r+8)}function c(t,r){return t[r++]*R+(t[r++]<<16)+(t[r++]<<8)+t[r]}function h(t,r,e){t[r+3]=255&e,e>>=8,t[r+2]=255&e,e>>=8,t[r+1]=255&e,e>>=8,t[r]=255&e}function p(t,r,e){for(var n=r+7;n>=r;n--)t[n]=255&e,e/=256}function l(t,r,e){e++;for(var n=r+7;n>=r;n--)t[n]=255&-e^255,e/=256}function d(t){return!!t&&"[object Array]"==Object.prototype.toString.call(t)}var y,g=e.Uint64BE=r=function(t,e,n,i){return this instanceof r?o(this,t,e,n,i):new r(t,e,n,i)},v=e.Int64BE=n=function(t,r,e,i){return this instanceof n?o(this,t,r,e,i):new n(t,r,e,i)},w=g.prototype,E=v.prototype,b="undefined",A=b!==typeof t&&t,B=b!==typeof Uint8Array&&Uint8Array,U=b!==typeof ArrayBuffer&&ArrayBuffer,m=[0,0,0,0,0,0,0,0],x=Array.isArray||d,P=4294967296,R=16777216;w.buffer=E.buffer=void 0,w.offset=E.offset=0,w._isUint64BE=E._isInt64BE=!0,g.isUint64BE=function(t){return!(!t||!t._isUint64BE)},v.isInt64BE=function(t){return!(!t||!t._isInt64BE)},w.toNumber=function(){var t=this.buffer,r=this.offset,e=c(t,r),n=c(t,r+4);return e?e*P+n:n},E.toNumber=function(){var t=this.buffer,r=this.offset,e=0|c(t,r),n=c(t,r+4);return e?e*P+n:n},w.toArray=E.toArray=function(t){var r=this.buffer,e=this.offset;return y=null,t!==!1&&0===e&&8===r.length&&x(r)?r:s(r,e)},A&&(w.toBuffer=E.toBuffer=function(r){var e=this.buffer,n=this.offset;if(y=A,r!==!1&&0===n&&8===e.length&&t.isBuffer(e))return e;var o=new A(8);return f(o,0,e,n),o}),B&&(w.toArrayBuffer=E.toArrayBuffer=function(t){var r=this.buffer,e=this.offset,n=r.buffer;if(y=B,t!==!1&&0===e&&n instanceof U&&8===n.byteLength)return n;var o=new B(8);return f(o,0,r,e),o.buffer}),E.toString=function(t){return a(this.buffer,this.offset,t,!0)},w.toString=function(t){return a(this.buffer,this.offset,t,!1)},w.toJSON=w.toNumber,E.toJSON=E.toNumber}("object"==typeof e&&"string"!=typeof e.nodeName?e:this||{})}).call(this,t("buffer").Buffer)},{buffer:21}],27:[function(t,r,e){arguments[4][23][0].apply(e,arguments)},{dup:23}]},{},[1])(1)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.msgpack=t()}}(function(){return function t(r,e,n){function i(f,u){if(!e[f]){if(!r[f]){var a="function"==typeof require&&require;if(!u&&a)return a(f,!0);if(o)return o(f,!0);var s=new Error("Cannot find module '"+f+"'");throw s.code="MODULE_NOT_FOUND",s}var c=e[f]={exports:{}};r[f][0].call(c.exports,function(t){var e=r[f][1][t];return i(e?e:t)},c,c.exports,t,r,e,n)}return e[f].exports}for(var o="function"==typeof require&&require,f=0;f<n.length;f++)i(n[f]);return i}({1:[function(t,r,e){e.encode=t("./encode").encode,e.decode=t("./decode").decode,e.Encoder=t("./encoder").Encoder,e.Decoder=t("./decoder").Decoder,e.createCodec=t("./ext").createCodec,e.codec=t("./codec").codec},{"./codec":10,"./decode":12,"./decoder":13,"./encode":15,"./encoder":16,"./ext":20}],2:[function(t,r,e){(function(Buffer){function t(t){return t&&t.isBuffer&&t}r.exports=t("undefined"!=typeof Buffer&&Buffer)||t(this.Buffer)||t("undefined"!=typeof window&&window.Buffer)||this.Buffer}).call(this,t("buffer").Buffer)},{buffer:29}],3:[function(t,r,e){function n(t,r){for(var e=this,n=r||(r|=0),i=t.length,o=0,f=0;f<i;)o=t.charCodeAt(f++),o<128?e[n++]=o:o<2048?(e[n++]=192|o>>>6,e[n++]=128|63&o):o<55296||o>57343?(e[n++]=224|o>>>12,e[n++]=128|o>>>6&63,e[n++]=128|63&o):(o=(o-55296<<10|t.charCodeAt(f++)-56320)+65536,e[n++]=240|o>>>18,e[n++]=128|o>>>12&63,e[n++]=128|o>>>6&63,e[n++]=128|63&o);return n-r}function i(t,r,e){var n=this,i=0|r;e||(e=n.length);for(var o="",f=0;i<e;)f=n[i++],f<128?o+=String.fromCharCode(f):(192===(224&f)?f=(31&f)<<6|63&n[i++]:224===(240&f)?f=(15&f)<<12|(63&n[i++])<<6|63&n[i++]:240===(248&f)&&(f=(7&f)<<18|(63&n[i++])<<12|(63&n[i++])<<6|63&n[i++]),f>=65536?(f-=65536,o+=String.fromCharCode((f>>>10)+55296,(1023&f)+56320)):o+=String.fromCharCode(f));return o}function o(t,r,e,n){var i;e||(e=0),n||0===n||(n=this.length),r||(r=0);var o=n-e;if(t===this&&e<r&&r<n)for(i=o-1;i>=0;i--)t[i+r]=this[i+e];else for(i=0;i<o;i++)t[i+r]=this[i+e];return o}e.copy=o,e.toString=i,e.write=n},{}],4:[function(t,r,e){function n(t){return new Array(t)}function i(t){if(!o.isBuffer(t)&&o.isView(t))t=o.Uint8Array.from(t);else if(o.isArrayBuffer(t))t=new Uint8Array(t);else{if("string"==typeof t)return o.from.call(e,t);if("number"==typeof t)throw new TypeError('"value" argument must not be a number')}return Array.prototype.slice.call(t)}var o=t("./bufferish"),e=r.exports=n(0);e.alloc=n,e.concat=o.concat,e.from=i},{"./bufferish":8}],5:[function(t,r,e){function n(t){return new Buffer(t)}function i(t){if(!o.isBuffer(t)&&o.isView(t))t=o.Uint8Array.from(t);else if(o.isArrayBuffer(t))t=new Uint8Array(t);else{if("string"==typeof t)return o.from.call(e,t);if("number"==typeof t)throw new TypeError('"value" argument must not be a number')}return Buffer.from&&1!==Buffer.from.length?Buffer.from(t):new Buffer(t)}var o=t("./bufferish"),Buffer=o.global,e=r.exports=o.hasBuffer?n(0):[];e.alloc=o.hasBuffer&&Buffer.alloc||n,e.concat=o.concat,e.from=i},{"./bufferish":8}],6:[function(t,r,e){function n(t,r,e,n){var o=a.isBuffer(this),f=a.isBuffer(t);if(o&&f)return this.copy(t,r,e,n);if(c||o||f||!a.isView(this)||!a.isView(t))return u.copy.call(this,t,r,e,n);var s=e||null!=n?i.call(this,e,n):this;return t.set(s,r),s.length}function i(t,r){var e=this.slice||!c&&this.subarray;if(e)return e.call(this,t,r);var i=a.alloc.call(this,r-t);return n.call(this,i,0,t,r),i}function o(t,r,e){var n=!s&&a.isBuffer(this)?this.toString:u.toString;return n.apply(this,arguments)}function f(t){function r(){var r=this[t]||u[t];return r.apply(this,arguments)}return r}var u=t("./buffer-lite");e.copy=n,e.slice=i,e.toString=o,e.write=f("write");var a=t("./bufferish"),Buffer=a.global,s=a.hasBuffer&&"TYPED_ARRAY_SUPPORT"in Buffer,c=s&&!Buffer.TYPED_ARRAY_SUPPORT},{"./buffer-lite":3,"./bufferish":8}],7:[function(t,r,e){function n(t){return new Uint8Array(t)}function i(t){if(o.isView(t)){var r=t.byteOffset,n=t.byteLength;t=t.buffer,t.byteLength!==n&&(t.slice?t=t.slice(r,r+n):(t=new Uint8Array(t),t.byteLength!==n&&(t=Array.prototype.slice.call(t,r,r+n))))}else{if("string"==typeof t)return o.from.call(e,t);if("number"==typeof t)throw new TypeError('"value" argument must not be a number')}return new Uint8Array(t)}var o=t("./bufferish"),e=r.exports=o.hasArrayBuffer?n(0):[];e.alloc=n,e.concat=o.concat,e.from=i},{"./bufferish":8}],8:[function(t,r,e){function n(t){return"string"==typeof t?u.call(this,t):a(this).from(t)}function i(t){return a(this).alloc(t)}function o(t,r){function n(t){r+=t.length}function o(t){a+=w.copy.call(t,u,a)}r||(r=0,Array.prototype.forEach.call(t,n));var f=this!==e&&this||t[0],u=i.call(f,r),a=0;return Array.prototype.forEach.call(t,o),u}function f(t){return t instanceof ArrayBuffer||E(t)}function u(t){var r=3*t.length,e=i.call(this,r),n=w.write.call(e,t);return r!==n&&(e=w.slice.call(e,0,n)),e}function a(t){return d(t)?g:y(t)?b:p(t)?v:h?g:l?b:v}function s(){return!1}function c(t,r){return t="[object "+t+"]",function(e){return null!=e&&{}.toString.call(r?e[r]:e)===t}}var Buffer=e.global=t("./buffer-global"),h=e.hasBuffer=Buffer&&!!Buffer.isBuffer,l=e.hasArrayBuffer="undefined"!=typeof ArrayBuffer,p=e.isArray=t("isarray");e.isArrayBuffer=l?f:s;var d=e.isBuffer=h?Buffer.isBuffer:s,y=e.isView=l?ArrayBuffer.isView||c("ArrayBuffer","buffer"):s;e.alloc=i,e.concat=o,e.from=n;var v=e.Array=t("./bufferish-array"),g=e.Buffer=t("./bufferish-buffer"),b=e.Uint8Array=t("./bufferish-uint8array"),w=e.prototype=t("./bufferish-proto"),E=c("ArrayBuffer")},{"./buffer-global":2,"./bufferish-array":4,"./bufferish-buffer":5,"./bufferish-proto":6,"./bufferish-uint8array":7,isarray:34}],9:[function(t,r,e){function n(t){return this instanceof n?(this.options=t,void this.init()):new n(t)}function i(t){for(var r in t)n.prototype[r]=o(n.prototype[r],t[r])}function o(t,r){function e(){return t.apply(this,arguments),r.apply(this,arguments)}return t&&r?e:t||r}function f(t){function r(t,r){return r(t)}return t=t.slice(),function(e){return t.reduce(r,e)}}function u(t){return s(t)?f(t):t}function a(t){return new n(t)}var s=t("isarray");e.createCodec=a,e.install=i,e.filter=u;var c=t("./bufferish");n.prototype.init=function(){var t=this.options;return t&&t.uint8array&&(this.bufferish=c.Uint8Array),this},e.preset=a({preset:!0})},{"./bufferish":8,isarray:34}],10:[function(t,r,e){t("./read-core"),t("./write-core"),e.codec={preset:t("./codec-base").preset}},{"./codec-base":9,"./read-core":22,"./write-core":25}],11:[function(t,r,e){function n(t){if(!(this instanceof n))return new n(t);if(t&&(this.options=t,t.codec)){var r=this.codec=t.codec;r.bufferish&&(this.bufferish=r.bufferish)}}e.DecodeBuffer=n;var i=t("./read-core").preset,o=t("./flex-buffer").FlexDecoder;o.mixin(n.prototype),n.prototype.codec=i,n.prototype.fetch=function(){return this.codec.decode(this)}},{"./flex-buffer":21,"./read-core":22}],12:[function(t,r,e){function n(t,r){var e=new i(r);return e.write(t),e.read()}e.decode=n;var i=t("./decode-buffer").DecodeBuffer},{"./decode-buffer":11}],13:[function(t,r,e){function n(t){return this instanceof n?void o.call(this,t):new n(t)}e.Decoder=n;var i=t("event-lite"),o=t("./decode-buffer").DecodeBuffer;n.prototype=new o,i.mixin(n.prototype),n.prototype.decode=function(t){arguments.length&&this.write(t),this.flush()},n.prototype.push=function(t){this.emit("data",t)},n.prototype.end=function(t){this.decode(t),this.emit("end")}},{"./decode-buffer":11,"event-lite":31}],14:[function(t,r,e){function n(t){if(!(this instanceof n))return new n(t);if(t&&(this.options=t,t.codec)){var r=this.codec=t.codec;r.bufferish&&(this.bufferish=r.bufferish)}}e.EncodeBuffer=n;var i=t("./write-core").preset,o=t("./flex-buffer").FlexEncoder;o.mixin(n.prototype),n.prototype.codec=i,n.prototype.write=function(t){this.codec.encode(this,t)}},{"./flex-buffer":21,"./write-core":25}],15:[function(t,r,e){function n(t,r){var e=new i(r);return e.write(t),e.read()}e.encode=n;var i=t("./encode-buffer").EncodeBuffer},{"./encode-buffer":14}],16:[function(t,r,e){function n(t){return this instanceof n?void o.call(this,t):new n(t)}e.Encoder=n;var i=t("event-lite"),o=t("./encode-buffer").EncodeBuffer;n.prototype=new o,i.mixin(n.prototype),n.prototype.encode=function(t){this.write(t),this.emit("data",this.read())},n.prototype.end=function(t){arguments.length&&this.encode(t),this.flush(),this.emit("end")}},{"./encode-buffer":14,"event-lite":31}],17:[function(t,r,e){function n(t,r){return this instanceof n?(this.buffer=i.from(t),void(this.type=r)):new n(t,r)}e.ExtBuffer=n;var i=t("./bufferish")},{"./bufferish":8}],18:[function(t,r,e){function n(t){t.addExtPacker(14,Error,[u,i]),t.addExtPacker(1,EvalError,[u,i]),t.addExtPacker(2,RangeError,[u,i]),t.addExtPacker(3,ReferenceError,[u,i]),t.addExtPacker(4,SyntaxError,[u,i]),t.addExtPacker(5,TypeError,[u,i]),t.addExtPacker(6,URIError,[u,i]),t.addExtPacker(10,RegExp,[f,i]),t.addExtPacker(11,Boolean,[o,i]),t.addExtPacker(12,String,[o,i]),t.addExtPacker(13,Date,[Number,i]),t.addExtPacker(15,Number,[o,i]),"undefined"!=typeof Uint8Array&&(t.addExtPacker(17,Int8Array,c),t.addExtPacker(18,Uint8Array,c),t.addExtPacker(19,Int16Array,c),t.addExtPacker(20,Uint16Array,c),t.addExtPacker(21,Int32Array,c),t.addExtPacker(22,Uint32Array,c),t.addExtPacker(23,Float32Array,c),"undefined"!=typeof Float64Array&&t.addExtPacker(24,Float64Array,c),"undefined"!=typeof Uint8ClampedArray&&t.addExtPacker(25,Uint8ClampedArray,c),t.addExtPacker(26,ArrayBuffer,c),t.addExtPacker(29,DataView,c)),s.hasBuffer&&t.addExtPacker(27,Buffer,s.from)}function i(r){return a||(a=t("./encode").encode),a(r)}function o(t){return t.valueOf()}function f(t){t=RegExp.prototype.toString.call(t).split("/"),t.shift();var r=[t.pop()];return r.unshift(t.join("/")),r}function u(t){var r={};for(var e in h)r[e]=t[e];return r}e.setExtPackers=n;var a,s=t("./bufferish"),Buffer=s.global,c=s.Uint8Array.from,h={name:1,message:1,stack:1,columnNumber:1,fileName:1,lineNumber:1}},{"./bufferish":8,"./encode":15}],19:[function(t,r,e){function n(t){t.addExtUnpacker(14,[i,f(Error)]),t.addExtUnpacker(1,[i,f(EvalError)]),t.addExtUnpacker(2,[i,f(RangeError)]),t.addExtUnpacker(3,[i,f(ReferenceError)]),t.addExtUnpacker(4,[i,f(SyntaxError)]),t.addExtUnpacker(5,[i,f(TypeError)]),t.addExtUnpacker(6,[i,f(URIError)]),t.addExtUnpacker(10,[i,o]),t.addExtUnpacker(11,[i,u(Boolean)]),t.addExtUnpacker(12,[i,u(String)]),t.addExtUnpacker(13,[i,u(Date)]),t.addExtUnpacker(15,[i,u(Number)]),"undefined"!=typeof Uint8Array&&(t.addExtUnpacker(17,u(Int8Array)),t.addExtUnpacker(18,u(Uint8Array)),t.addExtUnpacker(19,[a,u(Int16Array)]),t.addExtUnpacker(20,[a,u(Uint16Array)]),t.addExtUnpacker(21,[a,u(Int32Array)]),t.addExtUnpacker(22,[a,u(Uint32Array)]),t.addExtUnpacker(23,[a,u(Float32Array)]),"undefined"!=typeof Float64Array&&t.addExtUnpacker(24,[a,u(Float64Array)]),"undefined"!=typeof Uint8ClampedArray&&t.addExtUnpacker(25,u(Uint8ClampedArray)),t.addExtUnpacker(26,a),t.addExtUnpacker(29,[a,u(DataView)])),c.hasBuffer&&t.addExtUnpacker(27,u(Buffer))}function i(r){return s||(s=t("./decode").decode),s(r)}function o(t){return RegExp.apply(null,t)}function f(t){return function(r){var e=new t;for(var n in h)e[n]=r[n];return e}}function u(t){return function(r){return new t(r)}}function a(t){return new Uint8Array(t).buffer}e.setExtUnpackers=n;var s,c=t("./bufferish"),Buffer=c.global,h={name:1,message:1,stack:1,columnNumber:1,fileName:1,lineNumber:1}},{"./bufferish":8,"./decode":12}],20:[function(t,r,e){t("./read-core"),t("./write-core"),e.createCodec=t("./codec-base").createCodec},{"./codec-base":9,"./read-core":22,"./write-core":25}],21:[function(t,r,e){function n(){if(!(this instanceof n))return new n}function i(){if(!(this instanceof i))return new i}function o(){function t(t){var r=this.offset?p.prototype.slice.call(this.buffer,this.offset):this.buffer;this.buffer=r?t?this.bufferish.concat([r,t]):r:t,this.offset=0}function r(){for(;this.offset<this.buffer.length;){var t,r=this.offset;try{t=this.fetch()}catch(t){if(t&&t.message!=v)throw t;this.offset=r;break}this.push(t)}}function e(t){var r=this.offset,e=r+t;if(e>this.buffer.length)throw new Error(v);return this.offset=e,r}return{bufferish:p,write:t,fetch:a,flush:r,push:c,pull:h,read:s,reserve:e,offset:0}}function f(){function t(){var t=this.start;if(t<this.offset){var r=this.start=this.offset;return p.prototype.slice.call(this.buffer,t,r)}}function r(){for(;this.start<this.offset;){var t=this.fetch();t&&this.push(t)}}function e(){var t=this.buffers||(this.buffers=[]),r=t.length>1?this.bufferish.concat(t):t[0];return t.length=0,r}function n(t){var r=0|t;if(this.buffer){var e=this.buffer.length,n=0|this.offset,i=n+r;if(i<e)return this.offset=i,n;this.flush(),t=Math.max(t,Math.min(2*e,this.maxBufferSize))}return t=Math.max(t,this.minBufferSize),this.buffer=this.bufferish.alloc(t),this.start=0,this.offset=r,0}function i(t){var r=t.length;if(r>this.minBufferSize)this.flush(),this.push(t);else{var e=this.reserve(r);p.prototype.copy.call(t,this.buffer,e)}}return{bufferish:p,write:u,fetch:t,flush:r,push:c,pull:e,read:s,reserve:n,send:i,maxBufferSize:y,minBufferSize:d,offset:0,start:0}}function u(){throw new Error("method not implemented: write()")}function a(){throw new Error("method not implemented: fetch()")}function s(){var t=this.buffers&&this.buffers.length;return t?(this.flush(),this.pull()):this.fetch()}function c(t){var r=this.buffers||(this.buffers=[]);r.push(t)}function h(){var t=this.buffers||(this.buffers=[]);return t.shift()}function l(t){function r(r){for(var e in t)r[e]=t[e];return r}return r}e.FlexDecoder=n,e.FlexEncoder=i;var p=t("./bufferish"),d=2048,y=65536,v="BUFFER_SHORTAGE";n.mixin=l(o()),n.mixin(n.prototype),i.mixin=l(f()),i.mixin(i.prototype)},{"./bufferish":8}],22:[function(t,r,e){function n(t){function r(t){var r=s(t),n=e[r];if(!n)throw new Error("Invalid type: "+(r?"0x"+r.toString(16):r));return n(t)}var e=c.getReadToken(t);return r}function i(){var t=this.options;return this.decode=n(t),t&&t.preset&&a.setExtUnpackers(this),this}function o(t,r){var e=this.extUnpackers||(this.extUnpackers=[]);e[t]=h.filter(r)}function f(t){function r(r){return new u(r,t)}var e=this.extUnpackers||(this.extUnpackers=[]);return e[t]||r}var u=t("./ext-buffer").ExtBuffer,a=t("./ext-unpacker"),s=t("./read-format").readUint8,c=t("./read-token"),h=t("./codec-base");h.install({addExtUnpacker:o,getExtUnpacker:f,init:i}),e.preset=i.call(h.preset)},{"./codec-base":9,"./ext-buffer":17,"./ext-unpacker":19,"./read-format":23,"./read-token":24}],23:[function(t,r,e){function n(t){var r=k.hasArrayBuffer&&t&&t.binarraybuffer,e=t&&t.int64,n=T&&t&&t.usemap,B={map:n?o:i,array:f,str:u,bin:r?s:a,ext:c,uint8:h,uint16:p,uint32:y,uint64:g(8,e?E:b),int8:l,int16:d,int32:v,int64:g(8,e?A:w),float32:g(4,m),float64:g(8,x)};return B}function i(t,r){var e,n={},i=new Array(r),o=new Array(r),f=t.codec.decode;for(e=0;e<r;e++)i[e]=f(t),o[e]=f(t);for(e=0;e<r;e++)n[i[e]]=o[e];return n}function o(t,r){var e,n=new Map,i=new Array(r),o=new Array(r),f=t.codec.decode;for(e=0;e<r;e++)i[e]=f(t),o[e]=f(t);for(e=0;e<r;e++)n.set(i[e],o[e]);return n}function f(t,r){for(var e=new Array(r),n=t.codec.decode,i=0;i<r;i++)e[i]=n(t);return e}function u(t,r){var e=t.reserve(r),n=e+r;return _.toString.call(t.buffer,"utf-8",e,n)}function a(t,r){var e=t.reserve(r),n=e+r,i=_.slice.call(t.buffer,e,n);return k.from(i)}function s(t,r){var e=t.reserve(r),n=e+r,i=_.slice.call(t.buffer,e,n);return k.Uint8Array.from(i).buffer}function c(t,r){var e=t.reserve(r+1),n=t.buffer[e++],i=e+r,o=t.codec.getExtUnpacker(n);if(!o)throw new Error("Invalid ext type: "+(n?"0x"+n.toString(16):n));var f=_.slice.call(t.buffer,e,i);return o(f)}function h(t){var r=t.reserve(1);return t.buffer[r]}function l(t){var r=t.reserve(1),e=t.buffer[r];return 128&e?e-256:e}function p(t){var r=t.reserve(2),e=t.buffer;return e[r++]<<8|e[r]}function d(t){var r=t.reserve(2),e=t.buffer,n=e[r++]<<8|e[r];return 32768&n?n-65536:n}function y(t){var r=t.reserve(4),e=t.buffer;return 16777216*e[r++]+(e[r++]<<16)+(e[r++]<<8)+e[r]}function v(t){var r=t.reserve(4),e=t.buffer;return e[r++]<<24|e[r++]<<16|e[r++]<<8|e[r]}function g(t,r){return function(e){var n=e.reserve(t);return r.call(e.buffer,n,S)}}function b(t){return new P(this,t).toNumber()}function w(t){return new R(this,t).toNumber()}function E(t){return new P(this,t)}function A(t){return new R(this,t)}function m(t){return B.read(this,t,!1,23,4)}function x(t){return B.read(this,t,!1,52,8)}var B=t("ieee754"),U=t("int64-buffer"),P=U.Uint64BE,R=U.Int64BE;e.getReadFormat=n,e.readUint8=h;var k=t("./bufferish"),_=t("./bufferish-proto"),T="undefined"!=typeof Map,S=!0},{"./bufferish":8,"./bufferish-proto":6,ieee754:32,"int64-buffer":33}],24:[function(t,r,e){function n(t){var r=s.getReadFormat(t);return t&&t.useraw?o(r):i(r)}function i(t){var r,e=new Array(256);for(r=0;r<=127;r++)e[r]=f(r);for(r=128;r<=143;r++)e[r]=a(r-128,t.map);for(r=144;r<=159;r++)e[r]=a(r-144,t.array);for(r=160;r<=191;r++)e[r]=a(r-160,t.str);for(e[192]=f(null),e[193]=null,e[194]=f(!1),e[195]=f(!0),e[196]=u(t.uint8,t.bin),e[197]=u(t.uint16,t.bin),e[198]=u(t.uint32,t.bin),e[199]=u(t.uint8,t.ext),e[200]=u(t.uint16,t.ext),e[201]=u(t.uint32,t.ext),e[202]=t.float32,e[203]=t.float64,e[204]=t.uint8,e[205]=t.uint16,e[206]=t.uint32,e[207]=t.uint64,e[208]=t.int8,e[209]=t.int16,e[210]=t.int32,e[211]=t.int64,e[212]=a(1,t.ext),e[213]=a(2,t.ext),e[214]=a(4,t.ext),e[215]=a(8,t.ext),e[216]=a(16,t.ext),e[217]=u(t.uint8,t.str),e[218]=u(t.uint16,t.str),e[219]=u(t.uint32,t.str),e[220]=u(t.uint16,t.array),e[221]=u(t.uint32,t.array),e[222]=u(t.uint16,t.map),e[223]=u(t.uint32,t.map),r=224;r<=255;r++)e[r]=f(r-256);return e}function o(t){var r,e=i(t).slice();for(e[217]=e[196],e[218]=e[197],e[219]=e[198],r=160;r<=191;r++)e[r]=a(r-160,t.bin);return e}function f(t){return function(){return t}}function u(t,r){return function(e){var n=t(e);return r(e,n)}}function a(t,r){return function(e){return r(e,t)}}var s=t("./read-format");e.getReadToken=n},{"./read-format":23}],25:[function(t,r,e){function n(t){function r(t,r){var n=e[typeof r];if(!n)throw new Error('Unsupported type "'+typeof r+'": '+r);n(t,r)}var e=s.getWriteType(t);return r}function i(){var t=this.options;return this.encode=n(t),t&&t.preset&&a.setExtPackers(this),this}function o(t,r,e){function n(r){return e&&(r=e(r)),new u(r,t)}e=c.filter(e);var i=r.name;if(i&&"Object"!==i){var o=this.extPackers||(this.extPackers={});o[i]=n}else{var f=this.extEncoderList||(this.extEncoderList=[]);f.unshift([r,n])}}function f(t){var r=this.extPackers||(this.extPackers={}),e=t.constructor,n=e&&e.name&&r[e.name];if(n)return n;for(var i=this.extEncoderList||(this.extEncoderList=[]),o=i.length,f=0;f<o;f++){var u=i[f];if(e===u[0])return u[1]}}var u=t("./ext-buffer").ExtBuffer,a=t("./ext-packer"),s=t("./write-type"),c=t("./codec-base");c.install({addExtPacker:o,getExtPacker:f,init:i}),e.preset=i.call(c.preset)},{"./codec-base":9,"./ext-buffer":17,"./ext-packer":18,"./write-type":27}],26:[function(t,r,e){function n(t){return t&&t.uint8array?i():m||E.hasBuffer&&t&&t.safe?f():o()}function i(){var t=o();return t[202]=c(202,4,p),t[203]=c(203,8,d),t}function o(){var t=w.slice();return t[196]=u(196),t[197]=a(197),t[198]=s(198),t[199]=u(199),t[200]=a(200),t[201]=s(201),t[202]=c(202,4,x.writeFloatBE||p,!0),t[203]=c(203,8,x.writeDoubleBE||d,!0),t[204]=u(204),t[205]=a(205),t[206]=s(206),t[207]=c(207,8,h),t[208]=u(208),t[209]=a(209),t[210]=s(210),t[211]=c(211,8,l),t[217]=u(217),t[218]=a(218),t[219]=s(219),t[220]=a(220),t[221]=s(221),t[222]=a(222),t[223]=s(223),t}function f(){var t=w.slice();return t[196]=c(196,1,Buffer.prototype.writeUInt8),t[197]=c(197,2,Buffer.prototype.writeUInt16BE),t[198]=c(198,4,Buffer.prototype.writeUInt32BE),t[199]=c(199,1,Buffer.prototype.writeUInt8),t[200]=c(200,2,Buffer.prototype.writeUInt16BE),t[201]=c(201,4,Buffer.prototype.writeUInt32BE),t[202]=c(202,4,Buffer.prototype.writeFloatBE),t[203]=c(203,8,Buffer.prototype.writeDoubleBE),t[204]=c(204,1,Buffer.prototype.writeUInt8),t[205]=c(205,2,Buffer.prototype.writeUInt16BE),t[206]=c(206,4,Buffer.prototype.writeUInt32BE),t[207]=c(207,8,h),t[208]=c(208,1,Buffer.prototype.writeInt8),t[209]=c(209,2,Buffer.prototype.writeInt16BE),t[210]=c(210,4,Buffer.prototype.writeInt32BE),t[211]=c(211,8,l),t[217]=c(217,1,Buffer.prototype.writeUInt8),t[218]=c(218,2,Buffer.prototype.writeUInt16BE),t[219]=c(219,4,Buffer.prototype.writeUInt32BE),t[220]=c(220,2,Buffer.prototype.writeUInt16BE),t[221]=c(221,4,Buffer.prototype.writeUInt32BE),t[222]=c(222,2,Buffer.prototype.writeUInt16BE),t[223]=c(223,4,Buffer.prototype.writeUInt32BE),t}function u(t){return function(r,e){var n=r.reserve(2),i=r.buffer;i[n++]=t,i[n]=e}}function a(t){return function(r,e){var n=r.reserve(3),i=r.buffer;i[n++]=t,i[n++]=e>>>8,i[n]=e}}function s(t){return function(r,e){var n=r.reserve(5),i=r.buffer;i[n++]=t,i[n++]=e>>>24,i[n++]=e>>>16,i[n++]=e>>>8,i[n]=e}}function c(t,r,e,n){return function(i,o){var f=i.reserve(r+1);i.buffer[f++]=t,e.call(i.buffer,o,f,n)}}function h(t,r){new g(this,r,t)}function l(t,r){new b(this,r,t)}function p(t,r){y.write(this,t,r,!1,23,4)}function d(t,r){y.write(this,t,r,!1,52,8)}var y=t("ieee754"),v=t("int64-buffer"),g=v.Uint64BE,b=v.Int64BE,w=t("./write-uint8").uint8,E=t("./bufferish"),Buffer=E.global,A=E.hasBuffer&&"TYPED_ARRAY_SUPPORT"in Buffer,m=A&&!Buffer.TYPED_ARRAY_SUPPORT,x=E.hasBuffer&&Buffer.prototype||{};e.getWriteToken=n},{"./bufferish":8,"./write-uint8":28,ieee754:32,"int64-buffer":33}],27:[function(t,r,e){function n(t){function r(t,r){var e=r?195:194;_[e](t,r)}function e(t,r){var e,n=0|r;return r!==n?(e=203,void _[e](t,r)):(e=-32<=n&&n<=127?255&n:0<=n?n<=255?204:n<=65535?205:206:-128<=n?208:-32768<=n?209:210,void _[e](t,n))}function n(t,r){var e=207;_[e](t,r.toArray())}function o(t,r){var e=211;_[e](t,r.toArray())}function v(t){return t<32?1:t<=255?2:t<=65535?3:5}function g(t){return t<32?1:t<=65535?3:5}function b(t){function r(r,e){var n=e.length,i=5+3*n;r.offset=r.reserve(i);var o=r.buffer,f=t(n),u=r.offset+f;n=s.write.call(o,e,u);var a=t(n);if(f!==a){var c=u+a-f,h=u+n;s.copy.call(o,o,c,u,h)}var l=1===a?160+n:a<=3?215+a:219;_[l](r,n),r.offset+=n}return r}function w(t,r){if(null===r)return A(t,r);if(I(r))return Y(t,r);if(i(r))return m(t,r);if(f.isUint64BE(r))return n(t,r);if(u.isInt64BE(r))return o(t,r);var e=t.codec.getExtPacker(r);return e&&(r=e(r)),r instanceof l?U(t,r):void D(t,r)}function E(t,r){return I(r)?k(t,r):void w(t,r)}function A(t,r){var e=192;_[e](t,r)}function m(t,r){var e=r.length,n=e<16?144+e:e<=65535?220:221;_[n](t,e);for(var i=t.codec.encode,o=0;o<e;o++)i(t,r[o])}function x(t,r){var e=r.length,n=e<255?196:e<=65535?197:198;_[n](t,e),t.send(r)}function B(t,r){x(t,new Uint8Array(r))}function U(t,r){var e=r.buffer,n=e.length,i=y[n]||(n<255?199:n<=65535?200:201);_[i](t,n),h[r.type](t),t.send(e)}function P(t,r){var e=Object.keys(r),n=e.length,i=n<16?128+n:n<=65535?222:223;_[i](t,n);var o=t.codec.encode;e.forEach(function(e){o(t,e),o(t,r[e])})}function R(t,r){if(!(r instanceof Map))return P(t,r);var e=r.size,n=e<16?128+e:e<=65535?222:223;_[n](t,e);var i=t.codec.encode;r.forEach(function(r,e,n){i(t,e),i(t,r)})}function k(t,r){var e=r.length,n=e<32?160+e:e<=65535?218:219;_[n](t,e),t.send(r)}var _=c.getWriteToken(t),T=t&&t.useraw,S=p&&t&&t.binarraybuffer,I=S?a.isArrayBuffer:a.isBuffer,Y=S?B:x,C=d&&t&&t.usemap,D=C?R:P,O={boolean:r,function:A,number:e,object:T?E:w,string:b(T?g:v),symbol:A,undefined:A};return O}var i=t("isarray"),o=t("int64-buffer"),f=o.Uint64BE,u=o.Int64BE,a=t("./bufferish"),s=t("./bufferish-proto"),c=t("./write-token"),h=t("./write-uint8").uint8,l=t("./ext-buffer").ExtBuffer,p="undefined"!=typeof Uint8Array,d="undefined"!=typeof Map,y=[];y[1]=212,y[2]=213,y[4]=214,y[8]=215,y[16]=216,e.getWriteType=n},{"./bufferish":8,"./bufferish-proto":6,"./ext-buffer":17,"./write-token":26,"./write-uint8":28,"int64-buffer":33,isarray:34}],28:[function(t,r,e){function n(t){return function(r){var e=r.reserve(1);r.buffer[e]=t}}for(var i=e.uint8=new Array(256),o=0;o<=255;o++)i[o]=n(o)},{}],29:[function(t,r,e){(function(r){"use strict";function n(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function i(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,r){if(i()<r)throw new RangeError("Invalid typed array length");return Buffer.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r),t.__proto__=Buffer.prototype):(null===t&&(t=new Buffer(r)),t.length=r),t}function Buffer(t,r,e){if(!(Buffer.TYPED_ARRAY_SUPPORT||this instanceof Buffer))return new Buffer(t,r,e);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return s(this,t)}return f(this,t,r,e)}function f(t,r,e,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?l(t,r,e,n):"string"==typeof r?c(t,r,e):p(t,r)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function a(t,r,e,n){return u(r),r<=0?o(t,r):void 0!==e?"string"==typeof n?o(t,r).fill(e,n):o(t,r).fill(e):o(t,r)}function s(t,r){if(u(r),t=o(t,r<0?0:0|d(r)),!Buffer.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function c(t,r,e){if("string"==typeof e&&""!==e||(e="utf8"),!Buffer.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|v(r,e);t=o(t,n);var i=t.write(r,e);return i!==n&&(t=t.slice(0,i)),t}function h(t,r){var e=r.length<0?0:0|d(r.length);t=o(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function l(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n),Buffer.TYPED_ARRAY_SUPPORT?(t=r,t.__proto__=Buffer.prototype):t=h(t,r),t}function p(t,r){if(Buffer.isBuffer(r)){var e=0|d(r.length);return t=o(t,e),0===t.length?t:(r.copy(t,0,0,e),t)}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||H(r.length)?o(t,0):h(t,r);if("Buffer"===r.type&&Q(r.data))return h(t,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function d(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function y(t){return+t!=t&&(t=0),Buffer.alloc(+t)}function v(t,r){if(Buffer.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return X(t).length;default:if(n)return q(t).length;r=(""+r).toLowerCase(),n=!0}}function g(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if(e>>>=0,r>>>=0,e<=r)return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,r,e);case"utf8":case"utf-8":return k(this,r,e);case"ascii":return T(this,r,e);case"latin1":case"binary":return S(this,r,e);case"base64":return R(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function w(t,r,e,n,i){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(i)return-1;e=t.length-1}else if(e<0){if(!i)return-1;e=0}if("string"==typeof r&&(r=Buffer.from(r,n)),Buffer.isBuffer(r))return 0===r.length?-1:E(t,r,e,n,i);if("number"==typeof r)return r=255&r,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):E(t,[r],e,n,i);throw new TypeError("val must be string, number or Buffer")}function E(t,r,e,n,i){function o(t,r){return 1===f?t[r]:t.readUInt16BE(r*f)}var f=1,u=t.length,a=r.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;f=2,u/=2,a/=2,e/=2}var s;if(i){var c=-1;for(s=e;s<u;s++)if(o(t,s)===o(r,c===-1?0:s-c)){if(c===-1&&(c=s),s-c+1===a)return c*f}else c!==-1&&(s-=s-c),c=-1}else for(e+a>u&&(e=u-a),s=e;s>=0;s--){for(var h=!0,l=0;l<a;l++)if(o(t,s+l)!==o(r,l)){h=!1;break}if(h)return s}return-1}function A(t,r,e,n){e=Number(e)||0;var i=t.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var o=r.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var f=0;f<n;++f){var u=parseInt(r.substr(2*f,2),16);if(isNaN(u))return f;t[e+f]=u}return f}function m(t,r,e,n){return G(q(r,t.length-e),t,e,n)}function x(t,r,e,n){return G(W(r),t,e,n)}function B(t,r,e,n){return x(t,r,e,n)}function U(t,r,e,n){return G(X(r),t,e,n)}function P(t,r,e,n){return G(J(r,t.length-e),t,e,n)}function R(t,r,e){return 0===r&&e===t.length?Z.fromByteArray(t):Z.fromByteArray(t.slice(r,e))}function k(t,r,e){e=Math.min(t.length,e);for(var n=[],i=r;i<e;){var o=t[i],f=null,u=o>239?4:o>223?3:o>191?2:1;if(i+u<=e){var a,s,c,h;switch(u){case 1:o<128&&(f=o);break;case 2:a=t[i+1],128===(192&a)&&(h=(31&o)<<6|63&a,h>127&&(f=h));break;case 3:a=t[i+1],s=t[i+2],128===(192&a)&&128===(192&s)&&(h=(15&o)<<12|(63&a)<<6|63&s,h>2047&&(h<55296||h>57343)&&(f=h));break;case 4:a=t[i+1],s=t[i+2],c=t[i+3],128===(192&a)&&128===(192&s)&&128===(192&c)&&(h=(15&o)<<18|(63&a)<<12|(63&s)<<6|63&c,h>65535&&h<1114112&&(f=h))}}null===f?(f=65533,u=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=u}return _(n)}function _(t){var r=t.length;if(r<=$)return String.fromCharCode.apply(String,t);for(var e="",n=0;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=$));return e}function T(t,r,e){var n="";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(127&t[i]);return n}function S(t,r,e){var n="";e=Math.min(t.length,e);for(var i=r;i<e;++i)n+=String.fromCharCode(t[i]);return n}function I(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var i="",o=r;o<e;++o)i+=V(t[o]);return i}function Y(t,r,e){for(var n=t.slice(r,e),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function C(t,r,e){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function D(t,r,e,n,i,o){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||r<o)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}function O(t,r,e,n){r<0&&(r=65535+r+1);for(var i=0,o=Math.min(t.length-e,2);i<o;++i)t[e+i]=(r&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function L(t,r,e,n){r<0&&(r=4294967295+r+1);for(var i=0,o=Math.min(t.length-e,4);i<o;++i)t[e+i]=r>>>8*(n?i:3-i)&255}function M(t,r,e,n,i,o){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function N(t,r,e,n,i){return i||M(t,r,e,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,r,e,n,23,4),e+4}function F(t,r,e,n,i){return i||M(t,r,e,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,r,e,n,52,8),e+8}function j(t){ | ||
if(t=z(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function z(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return t<16?"0"+t.toString(16):t.toString(16)}function q(t,r){r=r||1/0;for(var e,n=t.length,i=null,o=[],f=0;f<n;++f){if(e=t.charCodeAt(f),e>55295&&e<57344){if(!i){if(e>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(r-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(r-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((r-=1)<0)break;o.push(e)}else if(e<2048){if((r-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function W(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}function J(t,r){for(var e,n,i,o=[],f=0;f<t.length&&!((r-=2)<0);++f)e=t.charCodeAt(f),n=e>>8,i=e%256,o.push(i),o.push(n);return o}function X(t){return Z.toByteArray(j(t))}function G(t,r,e,n){for(var i=0;i<n&&!(i+e>=r.length||i>=t.length);++i)r[i+e]=t[i];return i}function H(t){return t!==t}var Z=t("base64-js"),K=t("ieee754"),Q=t("isarray");e.Buffer=Buffer,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,Buffer.TYPED_ARRAY_SUPPORT=void 0!==r.TYPED_ARRAY_SUPPORT?r.TYPED_ARRAY_SUPPORT:n(),e.kMaxLength=i(),Buffer.poolSize=8192,Buffer._augment=function(t){return t.__proto__=Buffer.prototype,t},Buffer.from=function(t,r,e){return f(null,t,r,e)},Buffer.TYPED_ARRAY_SUPPORT&&(Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0})),Buffer.alloc=function(t,r,e){return a(null,t,r,e)},Buffer.allocUnsafe=function(t){return s(null,t)},Buffer.allocUnsafeSlow=function(t){return s(null,t)},Buffer.isBuffer=function(t){return!(null==t||!t._isBuffer)},Buffer.compare=function(t,r){if(!Buffer.isBuffer(t)||!Buffer.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,n=r.length,i=0,o=Math.min(e,n);i<o;++i)if(t[i]!==r[i]){e=t[i],n=r[i];break}return e<n?-1:n<e?1:0},Buffer.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(t,r){if(!Q(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Buffer.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var n=Buffer.allocUnsafe(r),i=0;for(e=0;e<t.length;++e){var o=t[e];if(!Buffer.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},Buffer.byteLength=v,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)b(this,r,r+1);return this},Buffer.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)b(this,r,r+3),b(this,r+1,r+2);return this},Buffer.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)b(this,r,r+7),b(this,r+1,r+6),b(this,r+2,r+5),b(this,r+3,r+4);return this},Buffer.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?k(this,0,t):g.apply(this,arguments)},Buffer.prototype.equals=function(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},Buffer.prototype.compare=function(t,r,e,n,i){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),r<0||e>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&r>=e)return 0;if(n>=i)return-1;if(r>=e)return 1;if(r>>>=0,e>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,f=e-r,u=Math.min(o,f),a=this.slice(n,i),s=t.slice(r,e),c=0;c<u;++c)if(a[c]!==s[c]){o=a[c],f=s[c];break}return o<f?-1:f<o?1:0},Buffer.prototype.includes=function(t,r,e){return this.indexOf(t,r,e)!==-1},Buffer.prototype.indexOf=function(t,r,e){return w(this,t,r,e,!0)},Buffer.prototype.lastIndexOf=function(t,r,e){return w(this,t,r,e,!1)},Buffer.prototype.write=function(t,r,e,n){if(void 0===r)n="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r=0|r,isFinite(e)?(e=0|e,void 0===n&&(n="utf8")):(n=e,e=void 0)}var i=this.length-r;if((void 0===e||e>i)&&(e=i),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return A(this,t,r,e);case"utf8":case"utf-8":return m(this,t,r,e);case"ascii":return x(this,t,r,e);case"latin1":case"binary":return B(this,t,r,e);case"base64":return U(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r,e);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;Buffer.prototype.slice=function(t,r){var e=this.length;t=~~t,r=void 0===r?e:~~r,t<0?(t+=e,t<0&&(t=0)):t>e&&(t=e),r<0?(r+=e,r<0&&(r=0)):r>e&&(r=e),r<t&&(r=t);var n;if(Buffer.TYPED_ARRAY_SUPPORT)n=this.subarray(t,r),n.__proto__=Buffer.prototype;else{var i=r-t;n=new Buffer(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+t]}return n},Buffer.prototype.readUIntLE=function(t,r,e){t=0|t,r=0|r,e||C(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return n},Buffer.prototype.readUIntBE=function(t,r,e){t=0|t,r=0|r,e||C(t,r,this.length);for(var n=this[t+--r],i=1;r>0&&(i*=256);)n+=this[t+--r]*i;return n},Buffer.prototype.readUInt8=function(t,r){return r||C(t,1,this.length),this[t]},Buffer.prototype.readUInt16LE=function(t,r){return r||C(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUInt16BE=function(t,r){return r||C(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUInt32LE=function(t,r){return r||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUInt32BE=function(t,r){return r||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readIntLE=function(t,r,e){t=0|t,r=0|r,e||C(t,r,this.length);for(var n=this[t],i=1,o=0;++o<r&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*r)),n},Buffer.prototype.readIntBE=function(t,r,e){t=0|t,r=0|r,e||C(t,r,this.length);for(var n=r,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*r)),o},Buffer.prototype.readInt8=function(t,r){return r||C(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},Buffer.prototype.readInt16LE=function(t,r){r||C(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},Buffer.prototype.readInt16BE=function(t,r){r||C(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},Buffer.prototype.readInt32LE=function(t,r){return r||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function(t,r){return r||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readFloatLE=function(t,r){return r||C(t,4,this.length),K.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function(t,r){return r||C(t,4,this.length),K.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function(t,r){return r||C(t,8,this.length),K.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function(t,r){return r||C(t,8,this.length),K.read(this,t,!1,52,8)},Buffer.prototype.writeUIntLE=function(t,r,e,n){if(t=+t,r=0|r,e=0|e,!n){var i=Math.pow(2,8*e)-1;D(this,t,r,e,i,0)}var o=1,f=0;for(this[r]=255&t;++f<e&&(o*=256);)this[r+f]=t/o&255;return r+e},Buffer.prototype.writeUIntBE=function(t,r,e,n){if(t=+t,r=0|r,e=0|e,!n){var i=Math.pow(2,8*e)-1;D(this,t,r,e,i,0)}var o=e-1,f=1;for(this[r+o]=255&t;--o>=0&&(f*=256);)this[r+o]=t/f&255;return r+e},Buffer.prototype.writeUInt8=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},Buffer.prototype.writeUInt16LE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},Buffer.prototype.writeUInt16BE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},Buffer.prototype.writeUInt32LE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):L(this,t,r,!0),r+4},Buffer.prototype.writeUInt32BE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):L(this,t,r,!1),r+4},Buffer.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r=0|r,!n){var i=Math.pow(2,8*e-1);D(this,t,r,e,i-1,-i)}var o=0,f=1,u=0;for(this[r]=255&t;++o<e&&(f*=256);)t<0&&0===u&&0!==this[r+o-1]&&(u=1),this[r+o]=(t/f>>0)-u&255;return r+e},Buffer.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r=0|r,!n){var i=Math.pow(2,8*e-1);D(this,t,r,e,i-1,-i)}var o=e-1,f=1,u=0;for(this[r+o]=255&t;--o>=0&&(f*=256);)t<0&&0===u&&0!==this[r+o+1]&&(u=1),this[r+o]=(t/f>>0)-u&255;return r+e},Buffer.prototype.writeInt8=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},Buffer.prototype.writeInt16LE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):O(this,t,r,!0),r+2},Buffer.prototype.writeInt16BE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):O(this,t,r,!1),r+2},Buffer.prototype.writeInt32LE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):L(this,t,r,!0),r+4},Buffer.prototype.writeInt32BE=function(t,r,e){return t=+t,r=0|r,e||D(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Buffer.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):L(this,t,r,!1),r+4},Buffer.prototype.writeFloatLE=function(t,r,e){return N(this,t,r,!0,e)},Buffer.prototype.writeFloatBE=function(t,r,e){return N(this,t,r,!1,e)},Buffer.prototype.writeDoubleLE=function(t,r,e){return F(this,t,r,!0,e)},Buffer.prototype.writeDoubleBE=function(t,r,e){return F(this,t,r,!1,e)},Buffer.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var i,o=n-e;if(this===t&&e<r&&r<n)for(i=o-1;i>=0;--i)t[i+r]=this[i+e];else if(o<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+r]=this[i+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+o),r);return o},Buffer.prototype.fill=function(t,r,e,n){if("string"==typeof t){if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t=255&t);if(r<0||this.length<r||this.length<e)throw new RangeError("Out of range index");if(e<=r)return this;r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0);var o;if("number"==typeof t)for(o=r;o<e;++o)this[o]=t;else{var f=Buffer.isBuffer(t)?t:q(new Buffer(t,n).toString()),u=f.length;for(o=0;o<e-r;++o)this[o+r]=f[o%u]}return this};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":30,ieee754:32,isarray:34}],30:[function(t,r,e){"use strict";function n(t){var r=t.length;if(r%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[r-2]?2:"="===t[r-1]?1:0}function i(t){return 3*t.length/4-n(t)}function o(t){var r,e,i,o,f,u,a=t.length;f=n(t),u=new h(3*a/4-f),i=f>0?a-4:a;var s=0;for(r=0,e=0;r<i;r+=4,e+=3)o=c[t.charCodeAt(r)]<<18|c[t.charCodeAt(r+1)]<<12|c[t.charCodeAt(r+2)]<<6|c[t.charCodeAt(r+3)],u[s++]=o>>16&255,u[s++]=o>>8&255,u[s++]=255&o;return 2===f?(o=c[t.charCodeAt(r)]<<2|c[t.charCodeAt(r+1)]>>4,u[s++]=255&o):1===f&&(o=c[t.charCodeAt(r)]<<10|c[t.charCodeAt(r+1)]<<4|c[t.charCodeAt(r+2)]>>2,u[s++]=o>>8&255,u[s++]=255&o),u}function f(t){return s[t>>18&63]+s[t>>12&63]+s[t>>6&63]+s[63&t]}function u(t,r,e){for(var n,i=[],o=r;o<e;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(f(n));return i.join("")}function a(t){for(var r,e=t.length,n=e%3,i="",o=[],f=16383,a=0,c=e-n;a<c;a+=f)o.push(u(t,a,a+f>c?c:a+f));return 1===n?(r=t[e-1],i+=s[r>>2],i+=s[r<<4&63],i+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],i+=s[r>>10],i+=s[r>>4&63],i+=s[r<<2&63],i+="="),o.push(i),o.join("")}e.byteLength=i,e.toByteArray=o,e.fromByteArray=a;for(var s=[],c=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=l.length;p<d;++p)s[p]=l[p],c[l.charCodeAt(p)]=p;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],31:[function(t,r,e){function n(){if(!(this instanceof n))return new n}!function(t){function e(t){for(var r in s)t[r]=s[r];return t}function n(t,r){return u(this,t).push(r),this}function i(t,r){function e(){o.call(n,t,e),r.apply(this,arguments)}var n=this;return e.originalListener=r,u(n,t).push(e),n}function o(t,r){function e(t){return t!==r&&t.originalListener!==r}var n,i=this;if(arguments.length){if(r){if(n=u(i,t,!0)){if(n=n.filter(e),!n.length)return o.call(i,t);i[a][t]=n}}else if(n=i[a],n&&(delete n[t],!Object.keys(n).length))return o.call(i)}else delete i[a];return i}function f(t,r){function e(t){t.call(o)}function n(t){t.call(o,r)}function i(t){t.apply(o,s)}var o=this,f=u(o,t,!0);if(!f)return!1;var a=arguments.length;if(1===a)f.forEach(e);else if(2===a)f.forEach(n);else{var s=Array.prototype.slice.call(arguments,1);f.forEach(i)}return!!f.length}function u(t,r,e){if(!e||t[a]){var n=t[a]||(t[a]={});return n[r]||(n[r]=[])}}"undefined"!=typeof r&&(r.exports=t);var a="listeners",s={on:n,once:i,off:o,emit:f};e(t.prototype),t.mixin=e}(n)},{}],32:[function(t,r,e){e.read=function(t,r,e,n,i){var o,f,u=8*i-n-1,a=(1<<u)-1,s=a>>1,c=-7,h=e?i-1:0,l=e?-1:1,p=t[r+h];for(h+=l,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[r+h],h+=l,c-=8);for(f=o&(1<<-c)-1,o>>=-c,c+=n;c>0;f=256*f+t[r+h],h+=l,c-=8);if(0===o)o=1-s;else{if(o===a)return f?NaN:(p?-1:1)*(1/0);f+=Math.pow(2,n),o-=s}return(p?-1:1)*f*Math.pow(2,o-n)},e.write=function(t,r,e,n,i,o){var f,u,a,s=8*o-i-1,c=(1<<s)-1,h=c>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,f=c):(f=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-f))<1&&(f--,a*=2),r+=f+h>=1?l/a:l*Math.pow(2,1-h),r*a>=2&&(f++,a/=2),f+h>=c?(u=0,f=c):f+h>=1?(u=(r*a-1)*Math.pow(2,i),f+=h):(u=r*Math.pow(2,h-1)*Math.pow(2,i),f=0));i>=8;t[e+p]=255&u,p+=d,u/=256,i-=8);for(f=f<<i|u,s+=i;s>0;t[e+p]=255&f,p+=d,f/=256,s-=8);t[e+p-d]|=128*y}},{}],33:[function(t,r,e){(function(Buffer){var t,r,n,i;!function(e){function o(t,r,n){function i(t,r,e,n){return this instanceof i?v(this,t,r,e,n):new i(t,r,e,n)}function o(t){return!(!t||!t[F])}function v(t,r,e,n,i){if(E&&A&&(r instanceof A&&(r=new E(r)),n instanceof A&&(n=new E(n))),!(r||e||n||g))return void(t.buffer=h(m,0));if(!s(r,e)){var o=g||Array;i=e,n=r,e=0,r=new o(8)}t.buffer=r,t.offset=e|=0,b!==typeof n&&("string"==typeof n?x(r,e,n,i||10):s(n,i)?c(r,e,n,i):"number"==typeof i?(k(r,e+T,n),k(r,e+S,i)):n>0?O(r,e,n):n<0?L(r,e,n):c(r,e,m,0))}function x(t,r,e,n){var i=0,o=e.length,f=0,u=0;"-"===e[0]&&i++;for(var a=i;i<o;){var s=parseInt(e[i++],n);if(!(s>=0))break;u=u*n+s,f=f*n+Math.floor(u/B),u%=B}a&&(f=~f,u?u=B-u:f++),k(t,r+T,f),k(t,r+S,u)}function P(){var t=this.buffer,r=this.offset,e=_(t,r+T),i=_(t,r+S);return n||(e|=0),e?e*B+i:i}function R(t){var r=this.buffer,e=this.offset,i=_(r,e+T),o=_(r,e+S),f="",u=!n&&2147483648&i;for(u&&(i=~i,o=B-o),t=t||10;;){var a=i%t*B+o;if(i=Math.floor(i/t),o=Math.floor(a/t),f=(a%t).toString(t)+f,!i&&!o)break}return u&&(f="-"+f),f}function k(t,r,e){t[r+D]=255&e,e>>=8,t[r+C]=255&e,e>>=8,t[r+Y]=255&e,e>>=8,t[r+I]=255&e}function _(t,r){return t[r+I]*U+(t[r+Y]<<16)+(t[r+C]<<8)+t[r+D]}var T=r?0:4,S=r?4:0,I=r?0:3,Y=r?1:2,C=r?2:1,D=r?3:0,O=r?l:d,L=r?p:y,M=i.prototype,N="is"+t,F="_"+N;return M.buffer=void 0,M.offset=0,M[F]=!0,M.toNumber=P,M.toString=R,M.toJSON=P,M.toArray=f,w&&(M.toBuffer=u),E&&(M.toArrayBuffer=a),i[N]=o,e[t]=i,i}function f(t){var r=this.buffer,e=this.offset;return g=null,t!==!1&&0===e&&8===r.length&&x(r)?r:h(r,e)}function u(t){var r=this.buffer,e=this.offset;if(g=w,t!==!1&&0===e&&8===r.length&&Buffer.isBuffer(r))return r;var n=new w(8);return c(n,0,r,e),n}function a(t){var r=this.buffer,e=this.offset,n=r.buffer;if(g=E,t!==!1&&0===e&&n instanceof A&&8===n.byteLength)return n;var i=new E(8);return c(i,0,r,e),i.buffer}function s(t,r){var e=t&&t.length;return r|=0,e&&r+8<=e&&"string"!=typeof t[r]}function c(t,r,e,n){r|=0,n|=0;for(var i=0;i<8;i++)t[r++]=255&e[n++]}function h(t,r){return Array.prototype.slice.call(t,r,r+8)}function l(t,r,e){for(var n=r+8;n>r;)t[--n]=255&e,e/=256}function p(t,r,e){var n=r+8;for(e++;n>r;)t[--n]=255&-e^255,e/=256}function d(t,r,e){for(var n=r+8;r<n;)t[r++]=255&e,e/=256}function y(t,r,e){var n=r+8;for(e++;r<n;)t[r++]=255&-e^255,e/=256}function v(t){return!!t&&"[object Array]"==Object.prototype.toString.call(t)}var g,b="undefined",w=b!==typeof Buffer&&Buffer,E=b!==typeof Uint8Array&&Uint8Array,A=b!==typeof ArrayBuffer&&ArrayBuffer,m=[0,0,0,0,0,0,0,0],x=Array.isArray||v,B=4294967296,U=16777216;t=o("Uint64BE",!0,!0),r=o("Int64BE",!0,!1),n=o("Uint64LE",!1,!0),i=o("Int64LE",!1,!1)}("object"==typeof e&&"string"!=typeof e.nodeName?e:this||{})}).call(this,t("buffer").Buffer)},{buffer:29}],34:[function(t,r,e){var n={}.toString;r.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}]},{},[1])(1)}); |
@@ -1,77 +0,113 @@ | ||
// util.js | ||
// buffer-lite.js | ||
var Int64Buffer = require("int64-buffer"); | ||
var Uint64BE = Int64Buffer.Uint64BE; | ||
var Int64BE = Int64Buffer.Int64BE; | ||
var MAXBUFLEN = 8192; | ||
exports.writeString = writeString; | ||
exports.readString = readString; | ||
exports.byteLength = byteLength; | ||
exports.copy = copy; | ||
exports.writeUint64BE = writeUint64BE; | ||
exports.writeInt64BE = writeInt64BE; | ||
exports.toString = toString; | ||
exports.write = write; | ||
// new Buffer(string, "utf-8") is SLOWER then below | ||
/** | ||
* Buffer.prototype.write() | ||
* | ||
* @param string {String} | ||
* @param [offset] {Number} | ||
* @returns {Number} | ||
*/ | ||
function writeString(string, start) { | ||
function write(string, offset) { | ||
var buffer = this; | ||
var index = start || 0; | ||
var index = offset || (offset |= 0); | ||
var length = string.length; | ||
// JavaScript's string uses UTF-16 surrogate pairs for characters other than BMP. | ||
// This encodes string as CESU-8 which never reaches 4 octets per character. | ||
for (var i = 0; i < length; i++) { | ||
var chr = string.charCodeAt(i); | ||
if (chr < 0x80) { | ||
var chr = 0; | ||
var i = 0; | ||
while (i < length) { | ||
chr = string.charCodeAt(i++); | ||
if (chr < 128) { | ||
buffer[index++] = chr; | ||
} else if (chr < 0x800) { | ||
buffer[index++] = 0xC0 | (chr >> 6); | ||
// 2 bytes | ||
buffer[index++] = 0xC0 | (chr >>> 6); | ||
buffer[index++] = 0x80 | (chr & 0x3F); | ||
} else if (chr < 0xD800 || chr > 0xDFFF) { | ||
// 3 bytes | ||
buffer[index++] = 0xE0 | (chr >>> 12); | ||
buffer[index++] = 0x80 | ((chr >>> 6) & 0x3F); | ||
buffer[index++] = 0x80 | (chr & 0x3F); | ||
} else { | ||
buffer[index++] = 0xE0 | (chr >> 12); | ||
buffer[index++] = 0x80 | ((chr >> 6) & 0x3F); | ||
buffer[index++] = 0x80 | (chr & 0x3F); | ||
// 4 bytes - surrogate pair | ||
chr = (((chr - 0xD800) << 10) | (string.charCodeAt(i++) - 0xDC00)) + 0x10000; | ||
buffer[index++] = 0xF0 | (chr >>> 18); | ||
buffer[index++] = 0x80 | ((chr >>> 12) & 0x3F); | ||
buffer[index++] = 0x80 | ((chr >>> 6) & 0x3F); | ||
buffer[index++] = 0x80 | (chr & 0x3F); | ||
} | ||
} | ||
return index - start; | ||
return index - offset; | ||
} | ||
// Buffer.ptototype.toString is 2x FASTER then below | ||
// https://github.com/feross/buffer may throw "Maximum call stack size exceeded." at String.fromCharCode.apply. | ||
/** | ||
* Buffer.prototype.toString() | ||
* | ||
* @param [encoding] {String} ignored | ||
* @param [start] {Number} | ||
* @param [end] {Number} | ||
* @returns {String} | ||
*/ | ||
function readString(start, end) { | ||
function toString(encoding, start, end) { | ||
var buffer = this; | ||
var index = start - 0 || 0; | ||
var index = start|0; | ||
if (!end) end = buffer.length; | ||
var size = end - start; | ||
if (size > MAXBUFLEN) size = MAXBUFLEN; | ||
var out = []; | ||
for (; index < end;) { | ||
var array = new Array(size); | ||
for (var pos = 0; pos < size && index < end;) { | ||
var chr = buffer[index++]; | ||
chr = (chr < 0x80) ? chr : | ||
(chr < 0xE0) ? (((chr & 0x3F) << 6) | (buffer[index++] & 0x3F)) : | ||
(((chr & 0x3F) << 12) | ((buffer[index++] & 0x3F) << 6) | ((buffer[index++] & 0x3F))); | ||
array[pos++] = chr; | ||
var string = ''; | ||
var chr = 0; | ||
while (index < end) { | ||
chr = buffer[index++]; | ||
if (chr < 128) { | ||
string += String.fromCharCode(chr); | ||
continue; | ||
} | ||
if (pos < size) array = array.slice(0, pos); | ||
out.push(String.fromCharCode.apply("", array)); | ||
if ((chr & 0xE0) === 0xC0) { | ||
// 2 bytes | ||
chr = (chr & 0x1F) << 6 | | ||
(buffer[index++] & 0x3F); | ||
} else if ((chr & 0xF0) === 0xE0) { | ||
// 3 bytes | ||
chr = (chr & 0x0F) << 12 | | ||
(buffer[index++] & 0x3F) << 6 | | ||
(buffer[index++] & 0x3F); | ||
} else if ((chr & 0xF8) === 0xF0) { | ||
// 4 bytes | ||
chr = (chr & 0x07) << 18 | | ||
(buffer[index++] & 0x3F) << 12 | | ||
(buffer[index++] & 0x3F) << 6 | | ||
(buffer[index++] & 0x3F); | ||
} | ||
if (chr >= 0x010000) { | ||
// A surrogate pair | ||
chr -= 0x010000; | ||
string += String.fromCharCode((chr >>> 10) + 0xD800, (chr & 0x3FF) + 0xDC00); | ||
} else { | ||
string += String.fromCharCode(chr); | ||
} | ||
} | ||
return (out.length > 1) ? out.join("") : out.length ? out.shift() : ""; | ||
} | ||
// Buffer.byteLength is FASTER than below | ||
function byteLength(string) { | ||
var length = 0 | 0; | ||
Array.prototype.forEach.call(string, function(chr) { | ||
var code = chr.charCodeAt(0); | ||
length += (code < 0x80) ? 1 : (code < 0x800) ? 2 : 3; | ||
}); | ||
return length; | ||
return string; | ||
} | ||
// https://github.com/feross/buffer lacks descending copying feature | ||
/** | ||
* Buffer.prototype.copy() | ||
* | ||
* @param target {Buffer} | ||
* @param [targetStart] {Number} | ||
* @param [start] {Number} | ||
* @param [end] {Number} | ||
* @returns {number} | ||
*/ | ||
@@ -99,9 +135,1 @@ function copy(target, targetStart, start, end) { | ||
} | ||
function writeUint64BE(value, offset) { | ||
new Uint64BE(this, offset, value); | ||
} | ||
function writeInt64BE(value, offset) { | ||
new Int64BE(this, offset, value); | ||
} |
// codec.js | ||
// load both interfaces | ||
require("./read-core"); | ||
require("./write-core"); | ||
// @public | ||
// msgpack.codec.preset | ||
exports.codec = { | ||
preset: require("./ext").createCodec({preset: true}) | ||
preset: require("./codec-base").preset | ||
}; |
@@ -5,6 +5,8 @@ // decode-buffer.js | ||
var preset = require("./codec").codec.preset; | ||
var preset = require("./read-core").preset; | ||
var BufferShortageError = require("./buffer-shortage").BufferShortageError; | ||
var FlexDecoder = require("./flex-buffer").FlexDecoder; | ||
FlexDecoder.mixin(DecodeBuffer.prototype); | ||
function DecodeBuffer(options) { | ||
@@ -16,3 +18,4 @@ if (!(this instanceof DecodeBuffer)) return new DecodeBuffer(options); | ||
if (options.codec) { | ||
this.codec = options.codec; | ||
var codec = this.codec = options.codec; | ||
if (codec.bufferish) this.bufferish = codec.bufferish; | ||
} | ||
@@ -22,53 +25,6 @@ } | ||
DecodeBuffer.prototype.offset = 0; | ||
DecodeBuffer.prototype.push = function(chunk) { | ||
var buffers = this.buffers || (this.buffers = []); | ||
buffers.push(chunk); | ||
}; | ||
DecodeBuffer.prototype.codec = preset; | ||
DecodeBuffer.prototype.write = function(chunk) { | ||
var prev = this.offset ? this.buffer.slice(this.offset) : this.buffer; | ||
this.buffer = prev ? (chunk ? Buffer.concat([prev, chunk]) : prev) : chunk; | ||
this.offset = 0; | ||
}; | ||
DecodeBuffer.prototype.read = function() { | ||
var length = this.buffers && this.buffers.length; | ||
// fetch the first result | ||
if (!length) return this.fetch(); | ||
// flush current buffer | ||
this.flush(); | ||
// read from the results | ||
return this.pull(); | ||
}; | ||
DecodeBuffer.prototype.pull = function() { | ||
var buffers = this.buffers || (this.buffers = []); | ||
return buffers.shift(); | ||
}; | ||
DecodeBuffer.prototype.fetch = function() { | ||
return this.codec.decode(this); | ||
}; | ||
DecodeBuffer.prototype.flush = function() { | ||
while (this.offset < this.buffer.length) { | ||
var start = this.offset; | ||
var value; | ||
try { | ||
value = this.fetch(); | ||
} catch (e) { | ||
if (!(e instanceof BufferShortageError)) throw e; | ||
// rollback | ||
this.offset = start; | ||
break; | ||
} | ||
this.push(value); | ||
} | ||
}; |
@@ -5,7 +5,8 @@ // encode-buffer.js | ||
var preset = require("./codec").codec.preset; | ||
var preset = require("./write-core").preset; | ||
var MIN_BUFFER_SIZE = 2048; | ||
var MAX_BUFFER_SIZE = 65536; | ||
var FlexEncoder = require("./flex-buffer").FlexEncoder; | ||
FlexEncoder.mixin(EncodeBuffer.prototype); | ||
function EncodeBuffer(options) { | ||
@@ -17,3 +18,4 @@ if (!(this instanceof EncodeBuffer)) return new EncodeBuffer(options); | ||
if (options.codec) { | ||
this.codec = options.codec; | ||
var codec = this.codec = options.codec; | ||
if (codec.bufferish) this.bufferish = codec.bufferish; | ||
} | ||
@@ -23,10 +25,2 @@ } | ||
EncodeBuffer.prototype.offset = 0; | ||
EncodeBuffer.prototype.start = 0; | ||
EncodeBuffer.prototype.push = function(chunk) { | ||
var buffers = this.buffers || (this.buffers = []); | ||
buffers.push(chunk); | ||
}; | ||
EncodeBuffer.prototype.codec = preset; | ||
@@ -37,68 +31,1 @@ | ||
}; | ||
EncodeBuffer.prototype.read = function() { | ||
var length = this.buffers && this.buffers.length; | ||
// fetch the first result | ||
if (!length) return this.fetch(); | ||
// flush current buffer | ||
this.flush(); | ||
// read from the results | ||
return this.pull(); | ||
}; | ||
EncodeBuffer.prototype.pull = function() { | ||
var buffers = this.buffers || (this.buffers = []); | ||
var chunk = buffers.length > 1 ? Buffer.concat(buffers) : buffers[0]; | ||
buffers.length = 0; // buffer exhausted | ||
return chunk; | ||
}; | ||
EncodeBuffer.prototype.fetch = function() { | ||
var start = this.start; | ||
if (start < this.offset) { | ||
this.start = this.offset; | ||
return this.buffer.slice(start, this.offset); | ||
} | ||
}; | ||
EncodeBuffer.prototype.flush = function() { | ||
var buffer = this.fetch(); | ||
if (buffer) this.push(buffer); | ||
}; | ||
EncodeBuffer.prototype.reserve = function(length) { | ||
if (this.buffer) { | ||
var size = this.buffer.length; | ||
// is it long enough? | ||
if (this.offset + length < size) return; | ||
// flush current buffer | ||
this.flush(); | ||
// resize it to 2x current length | ||
length = Math.max(length, Math.min(size * 2, MAX_BUFFER_SIZE)); | ||
} | ||
// minimum buffer size | ||
length = length > MIN_BUFFER_SIZE ? length : MIN_BUFFER_SIZE; | ||
// allocate new buffer | ||
this.buffer = new Buffer(length); | ||
this.start = 0; | ||
this.offset = 0; | ||
}; | ||
EncodeBuffer.prototype.send = function(buffer) { | ||
var end = this.offset + buffer.length; | ||
if (this.buffer && end < this.buffer.length) { | ||
buffer.copy(this.buffer, this.offset); | ||
this.offset = end; | ||
} else { | ||
this.flush(); | ||
this.push(buffer); | ||
} | ||
}; |
@@ -5,6 +5,8 @@ // ext-buffer.js | ||
var Bufferish = require("./bufferish"); | ||
function ExtBuffer(buffer, type) { | ||
if (!(this instanceof ExtBuffer)) return new ExtBuffer(buffer, type); | ||
this.buffer = buffer; | ||
this.buffer = Bufferish.from(buffer); | ||
this.type = type; | ||
} |
// ext.js | ||
var IS_ARRAY = require("isarray"); | ||
// load both interfaces | ||
require("./read-core"); | ||
require("./write-core"); | ||
exports.createCodec = createCodec; | ||
var ExtBuffer = require("./ext-buffer").ExtBuffer; | ||
var ExtPreset = require("./ext-preset"); | ||
var ReadCore = require("./read-core"); | ||
var WriteCore = require("./write-core"); | ||
function Codec(options) { | ||
if (!(this instanceof Codec)) return new Codec(options); | ||
this.extPackers = {}; | ||
this.extUnpackers = []; | ||
this.encode = WriteCore.getEncoder(options); | ||
this.decode = ReadCore.getDecoder(options); | ||
if (options && options.preset) { | ||
ExtPreset.setExtPreset(this); | ||
} | ||
} | ||
function createCodec(options) { | ||
return new Codec(options); | ||
} | ||
Codec.prototype.addExtPacker = function(etype, Class, packer) { | ||
if (IS_ARRAY(packer)) { | ||
packer = join(packer); | ||
} | ||
var name = Class.name; | ||
if (name && name !== "Object") { | ||
this.extPackers[name] = extPacker; | ||
} else { | ||
var list = this.extEncoderList || (this.extEncoderList = []); | ||
list.unshift([Class, extPacker]); | ||
} | ||
function extPacker(value) { | ||
var buffer = packer(value); | ||
return new ExtBuffer(buffer, etype); | ||
} | ||
}; | ||
Codec.prototype.addExtUnpacker = function(etype, unpacker) { | ||
this.extUnpackers[etype] = IS_ARRAY(unpacker) ? join(unpacker) : unpacker; | ||
}; | ||
Codec.prototype.getExtPacker = function(value) { | ||
var c = value.constructor; | ||
var e = c && c.name && this.extPackers[c.name]; | ||
if (e) return e; | ||
var list = this.extEncoderList; | ||
if (!list) return; | ||
var len = list.length; | ||
for (var i = 0; i < len; i++) { | ||
var pair = list[i]; | ||
if (c === pair[0]) return pair[1]; | ||
} | ||
}; | ||
Codec.prototype.getExtUnpacker = function(type) { | ||
return this.extUnpackers[type] || extUnpacker; | ||
function extUnpacker(buffer) { | ||
return new ExtBuffer(buffer, type); | ||
} | ||
}; | ||
function join(filters) { | ||
filters = filters.slice(); | ||
return function(value) { | ||
return filters.reduce(iterator, value); | ||
}; | ||
function iterator(value, filter) { | ||
return filter(value); | ||
} | ||
} | ||
exports.createCodec = require("./codec-base").createCodec; |
// read-core.js | ||
exports.getDecoder = getDecoder; | ||
var ExtBuffer = require("./ext-buffer").ExtBuffer; | ||
var ExtUnpacker = require("./ext-unpacker"); | ||
var readUint8 = require("./read-format").readUint8; | ||
var ReadToken = require("./read-token"); | ||
var CodecBase = require("./codec-base"); | ||
CodecBase.install({ | ||
addExtUnpacker: addExtUnpacker, | ||
getExtUnpacker: getExtUnpacker, | ||
init: init | ||
}); | ||
exports.preset = init.call(CodecBase.preset); | ||
function getDecoder(options) { | ||
@@ -19,1 +28,26 @@ var readToken = ReadToken.getReadToken(options); | ||
} | ||
function init() { | ||
var options = this.options; | ||
this.decode = getDecoder(options); | ||
if (options && options.preset) { | ||
ExtUnpacker.setExtUnpackers(this); | ||
} | ||
return this; | ||
} | ||
function addExtUnpacker(etype, unpacker) { | ||
var unpackers = this.extUnpackers || (this.extUnpackers = []); | ||
unpackers[etype] = CodecBase.filter(unpacker); | ||
} | ||
function getExtUnpacker(type) { | ||
var unpackers = this.extUnpackers || (this.extUnpackers = []); | ||
return unpackers[type] || extUnpacker; | ||
function extUnpacker(buffer) { | ||
return new ExtBuffer(buffer, type); | ||
} | ||
} |
@@ -11,23 +11,27 @@ // read-format.js | ||
var BufferLite = require("./buffer-lite"); | ||
var BufferShortageError = require("./buffer-shortage").BufferShortageError; | ||
var Bufferish = require("./bufferish"); | ||
var BufferProto = require("./bufferish-proto"); | ||
var IS_BUFFER_SHIM = ("TYPED_ARRAY_SUPPORT" in Buffer); | ||
var HAS_MAP = ("undefined" !== typeof Map); | ||
var NO_ASSERT = true; | ||
function getReadFormat(options) { | ||
var binarraybuffer = Bufferish.hasArrayBuffer && options && options.binarraybuffer; | ||
var int64 = options && options.int64; | ||
var usemap = HAS_MAP && options && options.usemap; | ||
var readFormat = { | ||
map: map, | ||
map: (usemap ? map_to_map : map_to_obj), | ||
array: array, | ||
str: str, | ||
bin: bin, | ||
bin: (binarraybuffer ? bin_arraybuffer : bin_buffer), | ||
ext: ext, | ||
uint8: uint8, | ||
uint16: uint16, | ||
uint32: read(4, Buffer.prototype.readUInt32BE), | ||
uint64: read(8, readUInt64BE), | ||
int8: read(1, Buffer.prototype.readInt8), | ||
int16: read(2, Buffer.prototype.readInt16BE), | ||
int32: read(4, Buffer.prototype.readInt32BE), | ||
int64: read(8, readInt64BE), | ||
uint32: uint32, | ||
uint64: read(8, int64 ? readUInt64BE_int64 : readUInt64BE), | ||
int8: int8, | ||
int16: int16, | ||
int32: int32, | ||
int64: read(8, int64 ? readInt64BE_int64 : readInt64BE), | ||
float32: read(4, readFloatBE), | ||
@@ -37,11 +41,6 @@ float64: read(8, readDoubleBE) | ||
if (options && options.int64) { | ||
readFormat.uint64 = read(8, readUInt64BE_int64); | ||
readFormat.int64 = read(8, readInt64BE_int64); | ||
} | ||
return readFormat; | ||
} | ||
function map(decoder, len) { | ||
function map_to_obj(decoder, len) { | ||
var value = {}; | ||
@@ -63,2 +62,19 @@ var i; | ||
function map_to_map(decoder, len) { | ||
var value = new Map(); | ||
var i; | ||
var k = new Array(len); | ||
var v = new Array(len); | ||
var decode = decoder.codec.decode; | ||
for (i = 0; i < len; i++) { | ||
k[i] = decode(decoder); | ||
v[i] = decode(decoder); | ||
} | ||
for (i = 0; i < len; i++) { | ||
value.set(k[i], v[i]); | ||
} | ||
return value; | ||
} | ||
function array(decoder, len) { | ||
@@ -74,30 +90,28 @@ var value = new Array(len); | ||
function str(decoder, len) { | ||
var start = decoder.offset; | ||
var end = decoder.offset = start + len; | ||
var buffer = decoder.buffer; | ||
if (end > buffer.length) throw new BufferShortageError(); | ||
if (IS_BUFFER_SHIM || !Buffer.isBuffer(buffer)) { | ||
// slower (compat) | ||
return BufferLite.readString.call(buffer, start, end); | ||
} else { | ||
// 2x faster | ||
return buffer.toString("utf-8", start, end); | ||
} | ||
var start = decoder.reserve(len); | ||
var end = start + len; | ||
return BufferProto.toString.call(decoder.buffer, "utf-8", start, end); | ||
} | ||
function bin(decoder, len) { | ||
var start = decoder.offset; | ||
var end = decoder.offset = start + len; | ||
if (end > decoder.buffer.length) throw new BufferShortageError(); | ||
return slice.call(decoder.buffer, start, end); | ||
function bin_buffer(decoder, len) { | ||
var start = decoder.reserve(len); | ||
var end = start + len; | ||
var buf = BufferProto.slice.call(decoder.buffer, start, end); | ||
return Bufferish.from(buf); | ||
} | ||
function bin_arraybuffer(decoder, len) { | ||
var start = decoder.reserve(len); | ||
var end = start + len; | ||
var buf = BufferProto.slice.call(decoder.buffer, start, end); | ||
return Bufferish.Uint8Array.from(buf).buffer; | ||
} | ||
function ext(decoder, len) { | ||
var start = decoder.offset; | ||
var end = decoder.offset = start + len + 1; | ||
if (end > decoder.buffer.length) throw new BufferShortageError(); | ||
var type = decoder.buffer[start]; | ||
var start = decoder.reserve(len+1); | ||
var type = decoder.buffer[start++]; | ||
var end = start + len; | ||
var unpack = decoder.codec.getExtUnpacker(type); | ||
if (!unpack) throw new Error("Invalid ext type: " + (type ? ("0x" + type.toString(16)) : type)); | ||
var buf = slice.call(decoder.buffer, start + 1, end); | ||
var buf = BufferProto.slice.call(decoder.buffer, start, end); | ||
return unpack(buf); | ||
@@ -107,18 +121,40 @@ } | ||
function uint8(decoder) { | ||
var buffer = decoder.buffer; | ||
if (decoder.offset >= buffer.length) throw new BufferShortageError(); | ||
return buffer[decoder.offset++]; | ||
var start = decoder.reserve(1); | ||
return decoder.buffer[start]; | ||
} | ||
function int8(decoder) { | ||
var start = decoder.reserve(1); | ||
var value = decoder.buffer[start]; | ||
return (value & 0x80) ? value - 0x100 : value; | ||
} | ||
function uint16(decoder) { | ||
var start = decoder.reserve(2); | ||
var buffer = decoder.buffer; | ||
if (decoder.offset + 2 > buffer.length) throw new BufferShortageError(); | ||
return (buffer[decoder.offset++] << 8) | buffer[decoder.offset++]; | ||
return (buffer[start++] << 8) | buffer[start]; | ||
} | ||
function int16(decoder) { | ||
var start = decoder.reserve(2); | ||
var buffer = decoder.buffer; | ||
var value = (buffer[start++] << 8) | buffer[start]; | ||
return (value & 0x8000) ? value - 0x10000 : value; | ||
} | ||
function uint32(decoder) { | ||
var start = decoder.reserve(4); | ||
var buffer = decoder.buffer; | ||
return (buffer[start++] * 16777216) + (buffer[start++] << 16) + (buffer[start++] << 8) + buffer[start]; | ||
} | ||
function int32(decoder) { | ||
var start = decoder.reserve(4); | ||
var buffer = decoder.buffer; | ||
return (buffer[start++] << 24) | (buffer[start++] << 16) | (buffer[start++] << 8) | buffer[start]; | ||
} | ||
function read(len, method) { | ||
return function(decoder) { | ||
var start = decoder.offset; | ||
var end = decoder.offset = start + len; | ||
if (end > decoder.buffer.length) throw new BufferShortageError(); | ||
var start = decoder.reserve(len); | ||
return method.call(decoder.buffer, start, NO_ASSERT); | ||
@@ -145,3 +181,2 @@ }; | ||
function readFloatBE(start) { | ||
if (this.readFloatBE) return this.readFloatBE(start); | ||
return ieee754.read(this, start, false, 23, 4); | ||
@@ -151,11 +186,3 @@ } | ||
function readDoubleBE(start) { | ||
if (this.readDoubleBE) return this.readDoubleBE(start); | ||
return ieee754.read(this, start, false, 52, 8); | ||
} | ||
function slice(start, end) { | ||
var f = this.slice || Array.prototype.slice; | ||
var buf = f.call(this, start, end); | ||
if (!Buffer.isBuffer(buf)) buf = Buffer(buf); | ||
return buf; | ||
} | ||
} |
@@ -127,3 +127,3 @@ // read-token.js | ||
var i; | ||
var token = getReadToken(format).slice(); | ||
var token = init_token(format).slice(); | ||
@@ -130,0 +130,0 @@ // raw 8 -- 0xd9 |
// write-core.js | ||
exports.getEncoder = getEncoder; | ||
var ExtBuffer = require("./ext-buffer").ExtBuffer; | ||
var ExtPacker = require("./ext-packer"); | ||
var WriteType = require("./write-type"); | ||
var CodecBase = require("./codec-base"); | ||
CodecBase.install({ | ||
addExtPacker: addExtPacker, | ||
getExtPacker: getExtPacker, | ||
init: init | ||
}); | ||
exports.preset = init.call(CodecBase.preset); | ||
function getEncoder(options) { | ||
@@ -17,1 +26,45 @@ var writeType = WriteType.getWriteType(options); | ||
} | ||
function init() { | ||
var options = this.options; | ||
this.encode = getEncoder(options); | ||
if (options && options.preset) { | ||
ExtPacker.setExtPackers(this); | ||
} | ||
return this; | ||
} | ||
function addExtPacker(etype, Class, packer) { | ||
packer = CodecBase.filter(packer); | ||
var name = Class.name; | ||
if (name && name !== "Object") { | ||
var packers = this.extPackers || (this.extPackers = {}); | ||
packers[name] = extPacker; | ||
} else { | ||
// fallback for IE | ||
var list = this.extEncoderList || (this.extEncoderList = []); | ||
list.unshift([Class, extPacker]); | ||
} | ||
function extPacker(value) { | ||
if (packer) value = packer(value); | ||
return new ExtBuffer(value, etype); | ||
} | ||
} | ||
function getExtPacker(value) { | ||
var packers = this.extPackers || (this.extPackers = {}); | ||
var c = value.constructor; | ||
var e = c && c.name && packers[c.name]; | ||
if (e) return e; | ||
// fallback for IE | ||
var list = this.extEncoderList || (this.extEncoderList = []); | ||
var len = list.length; | ||
for (var i = 0; i < len; i++) { | ||
var pair = list[i]; | ||
if (c === pair[0]) return pair[1]; | ||
} | ||
} |
// write-token.js | ||
var BufferLite = require("./buffer-lite"); | ||
var ieee754 = require("ieee754"); | ||
var Int64Buffer = require("int64-buffer"); | ||
var Uint64BE = Int64Buffer.Uint64BE; | ||
var Int64BE = Int64Buffer.Int64BE; | ||
var uint8 = require("./write-uint8").uint8; | ||
var IS_BUFFER_SHIM = ("TYPED_ARRAY_SUPPORT" in Buffer); | ||
var Bufferish = require("./bufferish"); | ||
var Buffer = Bufferish.global; | ||
var IS_BUFFER_SHIM = Bufferish.hasBuffer && ("TYPED_ARRAY_SUPPORT" in Buffer); | ||
var NO_TYPED_ARRAY = IS_BUFFER_SHIM && !Buffer.TYPED_ARRAY_SUPPORT; | ||
var Buffer_prototype = Bufferish.hasBuffer && Buffer.prototype || {}; | ||
@@ -12,3 +18,5 @@ exports.getWriteToken = getWriteToken; | ||
function getWriteToken(options) { | ||
if (NO_TYPED_ARRAY || (options && options.safe)) { | ||
if (options && options.uint8array) { | ||
return init_uint8array(); | ||
} else if (NO_TYPED_ARRAY || (Bufferish.hasBuffer && options && options.safe)) { | ||
return init_safe(); | ||
@@ -20,2 +28,13 @@ } else { | ||
function init_uint8array() { | ||
var token = init_token(); | ||
// float 32 -- 0xca | ||
// float 64 -- 0xcb | ||
token[0xca] = writeN(0xca, 4, writeFloatBE); | ||
token[0xcb] = writeN(0xcb, 8, writeDoubleBE); | ||
return token; | ||
} | ||
// Node.js and browsers with TypedArray | ||
@@ -48,4 +67,4 @@ | ||
// float 64 -- 0xcb | ||
token[0xca] = writeN(0xca, 4, Buffer.prototype.writeFloatBE, true); | ||
token[0xcb] = writeN(0xcb, 8, Buffer.prototype.writeDoubleBE, true); | ||
token[0xca] = writeN(0xca, 4, (Buffer_prototype.writeFloatBE || writeFloatBE), true); | ||
token[0xcb] = writeN(0xcb, 8, (Buffer_prototype.writeDoubleBE || writeDoubleBE), true); | ||
@@ -59,3 +78,3 @@ // uint 8 -- 0xcc | ||
token[0xce] = write4(0xce); | ||
token[0xcf] = writeN(0xcf, 8, BufferLite.writeUint64BE); | ||
token[0xcf] = writeN(0xcf, 8, writeUInt64BE); | ||
@@ -69,3 +88,3 @@ // int 8 -- 0xd0 | ||
token[0xd2] = write4(0xd2); | ||
token[0xd3] = writeN(0xd3, 8, BufferLite.writeUint64BE); | ||
token[0xd3] = writeN(0xd3, 8, writeInt64BE); | ||
@@ -129,3 +148,3 @@ // str 8 -- 0xd9 | ||
token[0xce] = writeN(0xce, 4, Buffer.prototype.writeUInt32BE); | ||
token[0xcf] = writeN(0xcf, 8, BufferLite.writeUint64BE); | ||
token[0xcf] = writeN(0xcf, 8, writeUInt64BE); | ||
@@ -139,3 +158,3 @@ // int 8 -- 0xd0 | ||
token[0xd2] = writeN(0xd2, 4, Buffer.prototype.writeInt32BE); | ||
token[0xd3] = writeN(0xd3, 8, BufferLite.writeUint64BE); | ||
token[0xd3] = writeN(0xd3, 8, writeInt64BE); | ||
@@ -164,8 +183,6 @@ // str 8 -- 0xd9 | ||
return function(encoder, value) { | ||
encoder.reserve(2); | ||
var offset = encoder.reserve(2); | ||
var buffer = encoder.buffer; | ||
var offset = encoder.offset; | ||
buffer[offset++] = type; | ||
buffer[offset++] = value; | ||
encoder.offset = offset; | ||
buffer[offset] = value; | ||
}; | ||
@@ -176,9 +193,7 @@ } | ||
return function(encoder, value) { | ||
encoder.reserve(3); | ||
var offset = encoder.reserve(3); | ||
var buffer = encoder.buffer; | ||
var offset = encoder.offset; | ||
buffer[offset++] = type; | ||
buffer[offset++] = value >>> 8; | ||
buffer[offset++] = value; | ||
encoder.offset = offset; | ||
buffer[offset] = value; | ||
}; | ||
@@ -189,5 +204,4 @@ } | ||
return function(encoder, value) { | ||
encoder.reserve(5); | ||
var offset = encoder.reserve(5); | ||
var buffer = encoder.buffer; | ||
var offset = encoder.offset; | ||
buffer[offset++] = type; | ||
@@ -197,4 +211,3 @@ buffer[offset++] = value >>> 24; | ||
buffer[offset++] = value >>> 8; | ||
buffer[offset++] = value; | ||
encoder.offset = offset; | ||
buffer[offset] = value; | ||
}; | ||
@@ -205,7 +218,22 @@ } | ||
return function(encoder, value) { | ||
encoder.reserve(len + 1); | ||
encoder.buffer[encoder.offset++] = type; | ||
method.call(encoder.buffer, value, encoder.offset, noAssert); | ||
encoder.offset += len; | ||
var offset = encoder.reserve(len + 1); | ||
encoder.buffer[offset++] = type; | ||
method.call(encoder.buffer, value, offset, noAssert); | ||
}; | ||
} | ||
function writeUInt64BE(value, offset) { | ||
new Uint64BE(this, offset, value); | ||
} | ||
function writeInt64BE(value, offset) { | ||
new Int64BE(this, offset, value); | ||
} | ||
function writeFloatBE(value, offset) { | ||
ieee754.write(this, value, offset, false, 23, 4); | ||
} | ||
function writeDoubleBE(value, offset) { | ||
ieee754.write(this, value, offset, false, 52, 8); | ||
} |
@@ -8,3 +8,4 @@ // write-type.js | ||
var BufferLite = require("./buffer-lite"); | ||
var Bufferish = require("./bufferish"); | ||
var BufferProto = require("./bufferish-proto"); | ||
var WriteToken = require("./write-token"); | ||
@@ -14,3 +15,4 @@ var uint8 = require("./write-uint8").uint8; | ||
var IS_BUFFER_SHIM = ("TYPED_ARRAY_SUPPORT" in Buffer); | ||
var HAS_UINT8ARRAY = ("undefined" !== typeof Uint8Array); | ||
var HAS_MAP = ("undefined" !== typeof Map); | ||
@@ -28,2 +30,8 @@ var extmap = []; | ||
var token = WriteToken.getWriteToken(options); | ||
var useraw = options && options.useraw; | ||
var binarraybuffer = HAS_UINT8ARRAY && options && options.binarraybuffer; | ||
var isBuffer = binarraybuffer ? Bufferish.isArrayBuffer : Bufferish.isBuffer; | ||
var bin = binarraybuffer ? bin_arraybuffer : bin_buffer; | ||
var usemap = HAS_MAP && options && options.usemap; | ||
var map = usemap ? map_to_map : obj_to_map; | ||
@@ -34,4 +42,4 @@ var writeType = { | ||
"number": number, | ||
"object": object, | ||
"string": string, | ||
"object": (useraw ? object_raw : object), | ||
"string": _string(useraw ? raw_head_size : str_head_size), | ||
"symbol": nil, | ||
@@ -41,7 +49,2 @@ "undefined": nil | ||
if (options && options.useraw) { | ||
writeType.object = object_raw; | ||
writeType.string = string_raw; | ||
} | ||
return writeType; | ||
@@ -98,29 +101,49 @@ | ||
// fixstr -- 0xa0 - 0xbf | ||
function string(encoder, value) { | ||
// prepare buffer | ||
var length = value.length; | ||
var maxsize = 5 + length * 3; | ||
encoder.reserve(maxsize); | ||
function str_head_size(length) { | ||
return (length < 32) ? 1 : (length <= 0xFF) ? 2 : (length <= 0xFFFF) ? 3 : 5; | ||
} | ||
// expected header size | ||
var expected = (length < 32) ? 1 : (length <= 0xFF) ? 2 : (length <= 0xFFFF) ? 3 : 5; | ||
// raw 16 -- 0xda | ||
// raw 32 -- 0xdb | ||
// fixraw -- 0xa0 - 0xbf | ||
function raw_head_size(length) { | ||
return (length < 32) ? 1 : (length <= 0xFFFF) ? 3 : 5; | ||
} | ||
// expected start point | ||
var start = encoder.offset + expected; | ||
function _string(head_size) { | ||
return string; | ||
// write string | ||
length = BufferLite.writeString.call(encoder.buffer, value, start); | ||
function string(encoder, value) { | ||
// prepare buffer | ||
var length = value.length; | ||
var maxsize = 5 + length * 3; | ||
encoder.offset = encoder.reserve(maxsize); | ||
var buffer = encoder.buffer; | ||
// actual header size | ||
var actual = (length < 32) ? 1 : (length <= 0xFF) ? 2 : (length <= 0xFFFF) ? 3 : 5; | ||
// expected header size | ||
var expected = head_size(length); | ||
// move content when needed | ||
if (expected !== actual) move(encoder, start, length, actual - expected); | ||
// expected start point | ||
var start = encoder.offset + expected; | ||
// write header | ||
var type = (actual === 1) ? (0xa0 + length) : (actual <= 3) ? 0xd7 + actual : 0xdb; | ||
token[type](encoder, length); | ||
// write string | ||
length = BufferProto.write.call(buffer, value, start); | ||
// move cursor | ||
encoder.offset += length; | ||
// actual header size | ||
var actual = head_size(length); | ||
// move content when needed | ||
if (expected !== actual) { | ||
var targetStart = start + actual - expected; | ||
var end = start + length; | ||
BufferProto.copy.call(buffer, buffer, targetStart, start, end); | ||
} | ||
// write header | ||
var type = (actual === 1) ? (0xa0 + length) : (actual <= 3) ? (0xd7 + actual) : 0xdb; | ||
token[type](encoder, length); | ||
// move cursor | ||
encoder.offset += length; | ||
} | ||
} | ||
@@ -133,3 +156,3 @@ | ||
// Buffer | ||
if (Buffer.isBuffer(value)) return bin(encoder, value); | ||
if (isBuffer(value)) return bin(encoder, value); | ||
@@ -148,6 +171,14 @@ // Array | ||
// plain old objects | ||
// plain old Objects or Map | ||
map(encoder, value); | ||
} | ||
function object_raw(encoder, value) { | ||
// Buffer | ||
if (isBuffer(value)) return raw(encoder, value); | ||
// others | ||
object(encoder, value); | ||
} | ||
// nil -- 0xc0 | ||
@@ -176,3 +207,3 @@ function nil(encoder, value) { | ||
// bin 32 -- 0xc6 | ||
function bin(encoder, value) { | ||
function bin_buffer(encoder, value) { | ||
var length = value.length; | ||
@@ -184,2 +215,6 @@ var type = (length < 0xFF) ? 0xc4 : (length <= 0xFFFF) ? 0xc5 : 0xc6; | ||
function bin_arraybuffer(encoder, value) { | ||
bin_buffer(encoder, new Uint8Array(value)); | ||
} | ||
// fixext 1 -- 0xd4 | ||
@@ -205,3 +240,3 @@ // fixext 2 -- 0xd5 | ||
// map 32 -- 0xdf | ||
function map(encoder, value) { | ||
function obj_to_map(encoder, value) { | ||
var keys = Object.keys(value); | ||
@@ -219,32 +254,17 @@ var length = keys.length; | ||
// raw 16 -- 0xda | ||
// raw 32 -- 0xdb | ||
// fixraw -- 0xa0 - 0xbf | ||
function string_raw(encoder, value) { | ||
// prepare buffer | ||
var length = value.length; | ||
var maxsize = 5 + length * 3; | ||
encoder.reserve(maxsize); | ||
// fixmap -- 0x80 - 0x8f | ||
// map 16 -- 0xde | ||
// map 32 -- 0xdf | ||
function map_to_map(encoder, value) { | ||
if (!(value instanceof Map)) return obj_to_map(encoder, value); | ||
// expected header size | ||
var expected = (length < 32) ? 1 : (length <= 0xFFFF) ? 3 : 5; | ||
// expected start point | ||
var start = encoder.offset + expected; | ||
// write string | ||
length = BufferLite.writeString.call(encoder.buffer, value, start); | ||
// actual header size | ||
var actual = (length < 32) ? 1 : (length <= 0xFFFF) ? 3 : 5; | ||
// move content when needed | ||
if (expected !== actual) move(encoder, start, length, actual - expected); | ||
// write header | ||
var type = (length < 32) ? (0xa0 + length) : (length <= 0xFFFF) ? 0xda : 0xdb; | ||
var length = value.size; | ||
var type = (length < 16) ? (0x80 + length) : (length <= 0xFFFF) ? 0xde : 0xdf; | ||
token[type](encoder, length); | ||
// move cursor | ||
encoder.offset += length; | ||
var encode = encoder.codec.encode; | ||
value.forEach(function(val, key, m) { | ||
encode(encoder, key); | ||
encode(encoder, val); | ||
}); | ||
} | ||
@@ -255,5 +275,3 @@ | ||
// fixraw -- 0xa0 - 0xbf | ||
function object_raw(encoder, value) { | ||
if (!Buffer.isBuffer(value)) return object(encoder, value); | ||
function raw(encoder, value) { | ||
var length = value.length; | ||
@@ -265,11 +283,1 @@ var type = (length < 32) ? (0xa0 + length) : (length <= 0xFFFF) ? 0xda : 0xdb; | ||
} | ||
function move(encoder, start, length, diff) { | ||
var targetStart = start + diff; | ||
var end = start + length; | ||
if (IS_BUFFER_SHIM) { | ||
BufferLite.copy.call(encoder.buffer, encoder.buffer, targetStart, start, end); | ||
} else { | ||
encoder.buffer.copy(encoder.buffer, targetStart, start, end); | ||
} | ||
} |
@@ -11,5 +11,5 @@ // write-unit8.js | ||
return function(encoder) { | ||
encoder.reserve(1); | ||
encoder.buffer[encoder.offset++] = type; | ||
var offset = encoder.reserve(1); | ||
encoder.buffer[offset] = type; | ||
}; | ||
} |
{ | ||
"name": "msgpack-lite", | ||
"description": "Fast Pure JavaScript MessagePack Encoder and Decoder", | ||
"version": "0.1.20", | ||
"version": "0.1.26", | ||
"author": "@kawanet", | ||
@@ -14,22 +14,24 @@ "bin": { | ||
"contributors": [ | ||
"Christopher Vermilion <chris@figlyinc.com>", | ||
"Frederik Dudzik <4004blog@gmail.com>", | ||
"Garrett Serack <gserack@gmail.com>", | ||
"Jesse Armand <jesse@jessearmand.com>", | ||
"Joshua Wise <josh@joshuawise.ninja>" | ||
"Joshua Wise <josh@joshuawise.ninja>", | ||
"Maciej Hirsz <maciej.hirsz@gmail.com>" | ||
], | ||
"dependencies": { | ||
"event-lite": "^0.1.1", | ||
"ieee754": "^1.1.6", | ||
"int64-buffer": "^0.1.6", | ||
"ieee754": "^1.1.8", | ||
"int64-buffer": "^0.1.9", | ||
"isarray": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"async": "^1.5.2", | ||
"browserify": "^13.0.0", | ||
"concat-stream": "^1.5.1", | ||
"jshint": "^2.9.2", | ||
"mocha": "^2.4.5", | ||
"async": "^2.1.1", | ||
"browserify": "^13.1.0", | ||
"concat-stream": "^1.5.2", | ||
"jshint": "^2.9.3", | ||
"mocha": "^3.1.2", | ||
"msgpack.codec": "git+https://github.com/kawanet/msgpack-javascript.git#msgpack.codec", | ||
"uglify-js": "^2.6.2", | ||
"zuul": "^3.10.1" | ||
"uglify-js": "^2.7.3", | ||
"zuul": "^3.11.1" | ||
}, | ||
@@ -42,2 +44,3 @@ "homepage": "https://github.com/kawanet/msgpack-lite", | ||
"Symbol": true, | ||
"Map": true, | ||
"window": true | ||
@@ -50,2 +53,3 @@ }, | ||
"keywords": [ | ||
"arraybuffer", | ||
"buffer", | ||
@@ -58,3 +62,2 @@ "fluentd", | ||
"typedarray", | ||
"arraybuffer", | ||
"uint8array" | ||
@@ -69,4 +72,11 @@ ], | ||
"scripts": { | ||
"test": "make test" | ||
"benchmark": "./lib/benchmark.js", | ||
"benchmark-lite": "./lib/benchmark.js msgpack-lite", | ||
"benchmark-stream": "./lib/benchmark-stream.js", | ||
"fixpack": "fixpack", | ||
"make": "make", | ||
"size": "make clean dist/msgpack.min.js && gzip -9fkv dist/msgpack.min.js && ls -l dist", | ||
"test": "make test", | ||
"test-browser-local": "make test-browser-local" | ||
} | ||
} |
@@ -16,3 +16,3 @@ # msgpack-lite [![npm version](https://badge.fury.io/js/msgpack-lite.svg)](http://badge.fury.io/js/msgpack-lite) [![Build Status](https://travis-ci.org/kawanet/msgpack-lite.svg?branch=master)](https://travis-ci.org/kawanet/msgpack-lite) | ||
- Ready for [Web browsers](https://saucelabs.com/u/msgpack-lite) including Chrome, Firefox, Safari and even IE8 | ||
- [Tested](https://travis-ci.org/kawanet/msgpack-lite) on Node.js v0.10, v0.12, v4 and v5 as well as Web browsers | ||
- [Tested](https://travis-ci.org/kawanet/msgpack-lite) on Node.js v0.10, v0.12, v4, v5 and v6 as well as Web browsers | ||
@@ -115,3 +115,3 @@ ### Encoding and Decoding MessagePack | ||
Browser version [msgpack.min.js](https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js) is also available. 44KB minified, 13KB gziped. | ||
Browser version [msgpack.min.js](https://rawgit.com/kawanet/msgpack-lite/master/dist/msgpack.min.js) is also available. 50KB minified, 14KB gziped. | ||
@@ -195,3 +195,3 @@ ```html | ||
$ npm install msgpack msgpack-js msgpack-js-v5 msgpack-unpack msgpack5 notepack | ||
$ node lib/benchmark.js 10 | ||
$ npm run benchmark 10 | ||
``` | ||
@@ -224,3 +224,3 @@ | ||
```sh | ||
$ node lib/benchmark-stream.js 2 | ||
$ npm run benchmark-stream 2 | ||
``` | ||
@@ -256,3 +256,4 @@ | ||
Array|array format family|Array | ||
Object (plain object)|map format family|Object | ||
Map|map format family|Map (if `usemap=true`) | ||
Object (plain object)|map format family|Object (or Map if `usemap=true`) | ||
Object (see below)|ext format family|Object (see below) | ||
@@ -282,3 +283,3 @@ | ||
0x0A|RegExp|0x1A|ArrayBuffer | ||
0x0B|Boolean|0x1B| | ||
0x0B|Boolean|0x1B|Buffer | ||
0x0C|String|0x1C| | ||
@@ -362,3 +363,3 @@ 0x0D|Date|0x1D|DataView | ||
`int64`: It decodes msgpack's int64/uint64 formats with [int64-buffer](https://github.com/kawanet/int64-buffer) object. | ||
`int64`: It decodes msgpack's `int64`/`uint64` formats with [int64-buffer](https://github.com/kawanet/int64-buffer) object. | ||
@@ -369,2 +370,21 @@ ```js | ||
`binarraybuffer`: It ties msgpack's `bin` format with `ArrayBuffer` object, instead of `Buffer` object. | ||
```js | ||
var codec = msgpack.createCodec({binarraybuffer: true, preset: true}); | ||
``` | ||
`uint8array`: It returns Uint8Array object when encoding, instead of `Buffer` object. | ||
```js | ||
var codec = msgpack.createCodec({uint8array: true}); | ||
``` | ||
`usemap`: Uses the global JavaScript Map type, if available, to unpack | ||
MessagePack map elements. | ||
```js | ||
var codec = msgpack.createCodec({usemap: true}); | ||
``` | ||
### Compatibility Mode | ||
@@ -371,0 +391,0 @@ |
@@ -9,8 +9,28 @@ #!/usr/bin/env mocha -R spec | ||
var HAS_UINT8ARRAY = ("undefined" !== typeof Uint8Array); | ||
describe(TITLE, function() { | ||
describe("Buffer", function() { | ||
run_tests(); | ||
}); | ||
var describe_Uint8Array = HAS_UINT8ARRAY ? describe : describe.skip; | ||
describe_Uint8Array("Uint8Array", function() { | ||
run_tests({uint8array: true}); | ||
}); | ||
}); | ||
function run_tests(codecopt) { | ||
var options; | ||
if (codecopt) it(JSON.stringify(codecopt), function() { | ||
var codec = msgpack.createCodec(codecopt); | ||
assert.ok(codec); | ||
options = {codec: codec}; | ||
}); | ||
// positive fixint -- 0x00 - 0x7f | ||
it("00-7f: positive fixint", function() { | ||
for (var i = 0; i <= 0x7F; i++) { | ||
assert.deepEqual(toArray(msgpack.encode(i)), [i]); | ||
assert.deepEqual(toArray(msgpack.encode(i, options)), [i]); | ||
} | ||
@@ -25,3 +45,3 @@ }); | ||
Object.keys(map).forEach(function(key) { | ||
assert.deepEqual(toArray(msgpack.encode(src)), exp); | ||
assert.deepEqual(toArray(msgpack.encode(src, options)), exp); | ||
src[key] = map[key]; | ||
@@ -41,3 +61,3 @@ exp[0]++; | ||
for (var i = 0; i < 16; i++) { | ||
assert.deepEqual(toArray(msgpack.encode(src)), exp); | ||
assert.deepEqual(toArray(msgpack.encode(src, options)), exp); | ||
src.push(array[i]); | ||
@@ -51,3 +71,3 @@ exp[0]++; | ||
it("a0-bf: fixstr", function() { | ||
assert.deepEqual(toArray(msgpack.encode("")), [0xa0]); | ||
assert.deepEqual(toArray(msgpack.encode("", options)), [0xa0]); | ||
@@ -58,3 +78,3 @@ var str = "0123456789abcdefghijklmnopqrstu"; | ||
var src = str.substr(0, i); | ||
assert.deepEqual(toArray(msgpack.encode(src)), exp); | ||
assert.deepEqual(toArray(msgpack.encode(src, options)), exp); | ||
exp[0]++; | ||
@@ -67,9 +87,9 @@ exp.push(str.charCodeAt(i)); | ||
it("c0: nil (null)", function() { | ||
assert.deepEqual(toArray(msgpack.encode(null)), [0xc0]); | ||
assert.deepEqual(toArray(msgpack.encode(null, options)), [0xc0]); | ||
}); | ||
it("c0: nil (undefined)", function() { | ||
assert.deepEqual(toArray(msgpack.encode(undefined)), [0xc0]); | ||
assert.deepEqual(toArray(msgpack.encode(undefined, options)), [0xc0]); | ||
}); | ||
it("c0: nil (Function)", function() { | ||
assert.deepEqual(toArray(msgpack.encode(NOP)), [0xc0]); | ||
assert.deepEqual(toArray(msgpack.encode(NOP, options)), [0xc0]); | ||
}); | ||
@@ -80,4 +100,4 @@ | ||
it("c2-c3: boolean", function() { | ||
assert.deepEqual(toArray(msgpack.encode(false)), [0xc2]); | ||
assert.deepEqual(toArray(msgpack.encode(true)), [0xc3]); | ||
assert.deepEqual(toArray(msgpack.encode(false, options)), [0xc2]); | ||
assert.deepEqual(toArray(msgpack.encode(true, options)), [0xc3]); | ||
}); | ||
@@ -93,11 +113,11 @@ | ||
bin.fill(0); | ||
assert.deepEqual(toArray(msgpack.encode(bin)), concat([0xc4, 1], bin)); | ||
assert.deepEqual(toArray(msgpack.encode(bin, options)), concat([0xc4, 1], bin)); | ||
bin = Buffer(256); | ||
bin.fill(0); | ||
assert.deepEqual(toArray(msgpack.encode(bin)), concat([0xc5, 1, 0], bin)); | ||
assert.deepEqual(toArray(msgpack.encode(bin, options)), concat([0xc5, 1, 0], bin)); | ||
bin = Buffer(65536); | ||
bin.fill(0); | ||
assert.deepEqual(toArray(msgpack.encode(bin)), concat([0xc6, 0, 1, 0, 0], bin)); | ||
assert.deepEqual(toArray(msgpack.encode(bin, options)), concat([0xc6, 0, 1, 0, 0], bin)); | ||
}); | ||
@@ -108,3 +128,3 @@ | ||
it("ca-cb: float 32/64", function() { | ||
assert.deepEqual(toArray(msgpack.encode(0.5)), [0xcb, 63, 224, 0, 0, 0, 0, 0, 0]); | ||
assert.deepEqual(toArray(msgpack.encode(0.5, options)), [0xcb, 63, 224, 0, 0, 0, 0, 0, 0]); | ||
}); | ||
@@ -117,5 +137,5 @@ | ||
it("cc-cf: uint 8/16/32/64", function() { | ||
assert.deepEqual(toArray(msgpack.encode(0xFF)), [0xcc, 0xFF]); | ||
assert.deepEqual(toArray(msgpack.encode(0xFFFF)), [0xcd, 0xFF, 0xFF]); | ||
assert.deepEqual(toArray(msgpack.encode(0x7FFFFFFF)), [0xce, 0x7F, 0xFF, 0xFF, 0xFF]); | ||
assert.deepEqual(toArray(msgpack.encode(0xFF, options)), [0xcc, 0xFF]); | ||
assert.deepEqual(toArray(msgpack.encode(0xFFFF, options)), [0xcd, 0xFF, 0xFF]); | ||
assert.deepEqual(toArray(msgpack.encode(0x7FFFFFFF, options)), [0xce, 0x7F, 0xFF, 0xFF, 0xFF]); | ||
}); | ||
@@ -128,5 +148,5 @@ | ||
it("d0-d3: int 8/16/32/64", function() { | ||
assert.deepEqual(toArray(msgpack.encode(-0x80)), [0xd0, 0x80]); | ||
assert.deepEqual(toArray(msgpack.encode(-0x8000)), [0xd1, 0x80, 0x00]); | ||
assert.deepEqual(toArray(msgpack.encode(-0x80000000)), [0xd2, 0x80, 0x00, 0x00, 0x00]); | ||
assert.deepEqual(toArray(msgpack.encode(-0x80, options)), [0xd0, 0x80]); | ||
assert.deepEqual(toArray(msgpack.encode(-0x8000, options)), [0xd1, 0x80, 0x00]); | ||
assert.deepEqual(toArray(msgpack.encode(-0x80000000, options)), [0xd2, 0x80, 0x00, 0x00, 0x00]); | ||
}); | ||
@@ -143,12 +163,12 @@ | ||
str = src.substr(0, 0xFF); | ||
assert.deepEqual(toArray(msgpack.encode(str)), concat([0xd9, 0xFF], Buffer(str))); | ||
assert.deepEqual(toArray(msgpack.encode(str, options)), concat([0xd9, 0xFF], Buffer(str))); | ||
str = src.substr(0, 0x0100); | ||
assert.deepEqual(toArray(msgpack.encode(str)), concat([0xda, 0x01, 0x00], Buffer(str))); | ||
assert.deepEqual(toArray(msgpack.encode(str, options)), concat([0xda, 0x01, 0x00], Buffer(str))); | ||
str = src.substr(0, 0xFFFF); | ||
assert.deepEqual(toArray(msgpack.encode(str)), concat([0xda, 0xFF, 0xFF], Buffer(str))); | ||
assert.deepEqual(toArray(msgpack.encode(str, options)), concat([0xda, 0xFF, 0xFF], Buffer(str))); | ||
str = src.substr(0, 0x010000); | ||
assert.deepEqual(toArray(msgpack.encode(str)), concat([0xdb, 0x00, 0x01, 0x00, 0x00], Buffer(str))); | ||
assert.deepEqual(toArray(msgpack.encode(str, options)), concat([0xdb, 0x00, 0x01, 0x00, 0x00], Buffer(str))); | ||
}); | ||
@@ -164,7 +184,7 @@ | ||
exp = [0xdc, 0x01, 0x00].concat(src); | ||
assert.deepEqual(toArray(msgpack.encode(src)), exp); | ||
assert.deepEqual(toArray(msgpack.encode(src, options)), exp); | ||
for (i = 0; i < 8; i++) src = src.concat(src); | ||
exp = [0xdd, 0x00, 0x01, 0x00, 0x00].concat(src); | ||
assert.deepEqual(toArray(msgpack.encode(src)), exp); | ||
assert.deepEqual(toArray(msgpack.encode(src, options)), exp); | ||
}); | ||
@@ -179,3 +199,3 @@ | ||
for (i = 0; i < 256; i++) map[i] = i; | ||
actual = msgpack.encode(map); | ||
actual = msgpack.encode(map, options); | ||
// check only headers because order may vary | ||
@@ -187,3 +207,3 @@ assert.equal(actual[0], 0xde); | ||
for (i = 256; i < 65536; i++) map[i] = i; | ||
actual = msgpack.encode(map); | ||
actual = msgpack.encode(map, options); | ||
assert.equal(actual[0], 0xdf); | ||
@@ -199,6 +219,6 @@ assert.equal(actual[1], 0); | ||
for (var i = -32; i <= -1; i++) { | ||
assert.deepEqual(toArray(msgpack.encode(i)), [i & 0xFF]); | ||
assert.deepEqual(toArray(msgpack.encode(i, options)), [i & 0xFF]); | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -205,0 +225,0 @@ function toArray(buffer) { |
@@ -179,2 +179,3 @@ #!/usr/bin/env mocha -R spec | ||
assert.deepEqual(msgpack.decode(BUFFER([0xce, 0xFF, 0xFF, 0xFF, 0xFF])), 0xFFFFFFFF); | ||
assert.deepEqual(msgpack.decode(BUFFER([0xce, 0x12, 0x34, 0x56, 0x78])), 0x12345678); | ||
assert.deepEqual(msgpack.decode(BUFFER([0xcf, 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF])), 0x00000000FFFFFFFF); | ||
@@ -199,2 +200,3 @@ assert.deepEqual(msgpack.decode(BUFFER([0xcf, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0])), 0x0000FFFFFFFF0000); | ||
assert.deepEqual(msgpack.decode(BUFFER([0xd2, 0xFF, 0xFF, 0xFF, 0xFF])), -1); | ||
assert.deepEqual(msgpack.decode(BUFFER([0xd2, 0x12, 0x34, 0x56, 0x78])), 0x12345678); | ||
assert.deepEqual(msgpack.decode(BUFFER([0xd3, 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF])), 0x00000000FFFFFFFF); | ||
@@ -201,0 +203,0 @@ assert.deepEqual(msgpack.decode(BUFFER([0xd3, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0])), 0x0000FFFFFFFF0000); |
@@ -9,2 +9,4 @@ #!/usr/bin/env mocha -R spec | ||
var HAS_UINT8ARRAY = ("undefined" !== typeof Uint8Array); | ||
describe(TITLE, function() { | ||
@@ -28,3 +30,3 @@ it("createCodec()", function() { | ||
var encoded = msgpack.encode(decoded, options); | ||
assert.deepEqual(encoded, source); | ||
assert.deepEqual(toArray(encoded), toArray(source)); | ||
} | ||
@@ -91,1 +93,6 @@ }); | ||
} | ||
function toArray(array) { | ||
if (HAS_UINT8ARRAY && array instanceof ArrayBuffer) array = new Uint8Array(array); | ||
return Array.prototype.slice.call(array); | ||
} |
@@ -36,8 +36,28 @@ #!/usr/bin/env mocha -R spec | ||
var HAS_UINT8ARRAY = ("undefined" !== typeof Uint8Array); | ||
describe(TITLE, function() { | ||
describe("Buffer", function() { | ||
run_tests(); | ||
}); | ||
var describe_Uint8Array = HAS_UINT8ARRAY ? describe : describe.skip; | ||
describe_Uint8Array("Uint8Array", function() { | ||
run_tests({uint8array: true}); | ||
}); | ||
}); | ||
function run_tests(codecopt) { | ||
var options; | ||
if (codecopt) it(JSON.stringify(codecopt), function() { | ||
var codec = msgpack.createCodec(codecopt); | ||
assert.ok(codec); | ||
options = {codec: codec}; | ||
}); | ||
it("null", function() { | ||
[null, undefined].forEach(function(value) { | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -49,4 +69,4 @@ }); | ||
[true, false].forEach(function(value) { | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -59,4 +79,4 @@ }); | ||
value = value | 0; // integer | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -68,4 +88,4 @@ }); | ||
pattern(0x40000000, 0xFFFFFFFF).forEach(function(value) { | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -78,4 +98,4 @@ }); | ||
value = -value | 0; // integer | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -88,4 +108,4 @@ }); | ||
value = -value; | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -97,4 +117,4 @@ }); | ||
[1.1, 10.01, 100.001, 1000.0001, 10000.00001, 100000.000001, 1000000.0000001].forEach(function(value) { | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -108,4 +128,4 @@ }); | ||
var value = STRING_ASCII.substr(0, length); | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -119,4 +139,4 @@ }); | ||
var value = STRING_GREEK.substr(0, length); | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -130,4 +150,4 @@ }); | ||
var value = STRING_ASIAN.substr(0, length); | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded, value); | ||
@@ -144,4 +164,4 @@ }); | ||
assert.equal(value.length, length); | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded.length, length); | ||
@@ -158,4 +178,4 @@ assert.equal(decoded[0], value[0]); | ||
assert.equal(value.length, length); | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded.length, length); | ||
@@ -167,3 +187,3 @@ assert.equal(decoded[0], value[0]); | ||
it("map (small)", function() { | ||
it("object map (small)", function() { | ||
pattern(0, 257).forEach(function(length) { | ||
@@ -176,4 +196,4 @@ var value = {}; | ||
assert.equal(Object.keys(value).length, length); | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(Object.keys(decoded).length, length); | ||
@@ -185,3 +205,3 @@ assert.equal(decoded[0], value[0]); | ||
it("map (large)", function() { | ||
it("object map (large)", function() { | ||
this.timeout(30000); | ||
@@ -194,4 +214,4 @@ pattern(65536, 65537).forEach(function(length) { | ||
assert.equal(Object.keys(value).length, length); | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(Object.keys(decoded).length, length); | ||
@@ -209,4 +229,4 @@ assert.equal(decoded[0], value[0]); | ||
assert.equal(value.length, length); | ||
var encoded = msgpack.encode(value); | ||
var decoded = msgpack.decode(encoded); | ||
var encoded = msgpack.encode(value, options); | ||
var decoded = msgpack.decode(encoded, options); | ||
assert.equal(decoded.length, length); | ||
@@ -217,2 +237,2 @@ assert.equal(decoded[0], value[0]); | ||
}); | ||
}); | ||
} |
@@ -11,2 +11,4 @@ #!/usr/bin/env mocha -R spec | ||
var HAS_UINT8ARRAY = ("undefined" !== typeof Uint8Array); | ||
describe(TITLE, function() { | ||
@@ -23,2 +25,8 @@ it("ExtBuffer (0x00)", function() { | ||
it("ExtBuffer Array (0x20-0xFF)", function() { | ||
for (var i = 32; i < 256; i++) { | ||
testExtBufferArray(i); | ||
} | ||
}); | ||
function testExtBuffer(type) { | ||
@@ -35,6 +43,40 @@ // fixext 8 -- 0xd7 | ||
assert.equal(decoded.buffer.length, content.length); | ||
assert.deepEqual(decoded.buffer, content); | ||
assert.deepEqual(toArray(decoded.buffer), toArray(content)); | ||
var encoded = msgpack.encode(decoded); | ||
assert.deepEqual(encoded, source); | ||
assert.deepEqual(toArray(encoded), toArray(source)); | ||
} | ||
// Unpack and re-pack an array of extension types. | ||
// Tests, among other things, that the right number of bytes are | ||
// consumed with each ext type read. | ||
function testExtBufferArray(type) { | ||
function content(j) { | ||
var x = j * type; | ||
return Buffer([x & 0x7F, (x + 1) & 0x7F]); | ||
} | ||
// fixarray len 10 | ||
var arrayHeader = new Buffer([0x9a]); | ||
var fullBuffer = arrayHeader; | ||
for (var j = 0; j < 10; j++) { | ||
// fixext 2 -- 0xd5 | ||
var header = new Buffer([0xd5, type]); | ||
fullBuffer = Buffer.concat([fullBuffer, header, content(j)]); | ||
} | ||
var decoded = msgpack.decode(fullBuffer); | ||
assert.equal(true, decoded instanceof Array); | ||
assert.equal(decoded.length, 10); | ||
for (j = 0; j < 10; j++) { | ||
assert.equal(decoded[j].type, type); | ||
assert.equal(decoded[j].buffer.length, 2); | ||
assert.deepEqual(decoded[j].buffer, content(j)); | ||
} | ||
var encoded = msgpack.encode(decoded); | ||
assert.deepEqual(encoded, fullBuffer); | ||
} | ||
}); | ||
function toArray(array) { | ||
if (HAS_UINT8ARRAY && array instanceof ArrayBuffer) array = new Uint8Array(array); | ||
return Array.prototype.slice.call(array); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
201160
68
4040
434
21
2
Updatedieee754@^1.1.8
Updatedint64-buffer@^0.1.9