@msgpack/msgpack
Advanced tools
Comparing version 1.12.2 to 2.0.0
This is the revision history of @msgpack/msgpack | ||
## v2.0.0 2020/09/06 | ||
https://github.com/msgpack/msgpack-javascript/compare/v1.12.2...v2.0.0 | ||
* Officially introduce direct use of `Encoder` and `Decoder` for better performance | ||
* The major version was bumped because it changed the interface to `Encoder` and `Decoder` | ||
* Build with TypeScript 4.0 | ||
## v1.12.2 2020/05/14 | ||
@@ -4,0 +12,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MessagePack=t():e.MessagePack=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t),r.d(t,"encode",(function(){return I})),r.d(t,"decode",(function(){return N})),r.d(t,"decodeAsync",(function(){return Y})),r.d(t,"decodeArrayStream",(function(){return Z})),r.d(t,"decodeStream",(function(){return $})),r.d(t,"Decoder",(function(){return V})),r.d(t,"Encoder",(function(){return L})),r.d(t,"ExtensionCodec",(function(){return S})),r.d(t,"ExtData",(function(){return p})),r.d(t,"EXT_TIMESTAMP",(function(){return w})),r.d(t,"encodeDateToTimeSpec",(function(){return g})),r.d(t,"encodeTimeSpecToTimestamp",(function(){return v})),r.d(t,"decodeTimestampToTimeSpec",(function(){return x})),r.d(t,"encodeTimestampExtension",(function(){return b})),r.d(t,"decodeTimestampExtension",(function(){return U}));var n=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(n(arguments[t]));return e},o="undefined"!=typeof process&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function s(e){for(var t=e.length,r=0,n=0;n<t;){var i=e.charCodeAt(n++);if(0!=(4294967168&i))if(0==(4294965248&i))r+=2;else{if(i>=55296&&i<=56319&&n<t){var o=e.charCodeAt(n);56320==(64512&o)&&(++n,i=((1023&i)<<10)+(1023&o)+65536)}r+=0==(4294901760&i)?3:4}else r++}return r}var a=o?new TextEncoder:void 0,h="undefined"!=typeof process?200:0;var u=(null==a?void 0:a.encodeInto)?function(e,t,r){a.encodeInto(e,t.subarray(r))}:function(e,t,r){t.set(a.encode(e),r)};function c(e,t,r){for(var n=t,o=n+r,s=[],a="";n<o;){var h=e[n++];if(0==(128&h))s.push(h);else if(192==(224&h)){var u=63&e[n++];s.push((31&h)<<6|u)}else if(224==(240&h)){u=63&e[n++];var c=63&e[n++];s.push((31&h)<<12|u<<6|c)}else if(240==(248&h)){var f=(7&h)<<18|(u=63&e[n++])<<12|(c=63&e[n++])<<6|63&e[n++];f>65535&&(f-=65536,s.push(f>>>10&1023|55296),f=56320|1023&f),s.push(f)}else s.push(h);s.length>=4096&&(a+=String.fromCharCode.apply(String,i(s)),s.length=0)}return s.length>0&&(a+=String.fromCharCode.apply(String,i(s))),a}var f=o?new TextDecoder:null,l="undefined"!=typeof process?200:0;var p=function(e,t){this.type=e,this.data=t};function d(e,t,r){var n=Math.floor(r/4294967296),i=r;e.setUint32(t,n),e.setUint32(t+4,i)}function y(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}var w=-1;function v(e){var t=e.sec,r=e.nsec;if(t>=0&&r>=0&&t<=17179869183){if(0===r&&t<=4294967295){var n=new Uint8Array(4);return(s=new DataView(n.buffer)).setUint32(0,t),n}var i=t/4294967296,o=4294967295&t;n=new Uint8Array(8);return(s=new DataView(n.buffer)).setUint32(0,r<<2|3&i),s.setUint32(4,o),n}var s;n=new Uint8Array(12);return(s=new DataView(n.buffer)).setUint32(0,r),d(s,4,t),n}function g(e){var t=e.getTime(),r=Math.floor(t/1e3),n=1e6*(t-1e3*r),i=Math.floor(n/1e9);return{sec:r+i,nsec:n-1e9*i}}function b(e){return e instanceof Date?v(g(e)):null}function x(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:var r=t.getUint32(0);return{sec:4294967296*(3&r)+t.getUint32(4),nsec:r>>>2};case 12:return{sec:y(t,4),nsec:t.getUint32(0)};default:throw new Error("Unrecognized data size for timestamp: "+e.length)}}function U(e){var t=x(e);return new Date(1e3*t.sec+t.nsec/1e6)}var m={type:w,encode:b,decode:U},S=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(m)}return e.prototype.register=function(e){var t=e.type,r=e.encode,n=e.decode;if(t>=0)this.encoders[t]=r,this.decoders[t]=n;else{var i=1+t;this.builtInEncoders[i]=r,this.builtInDecoders[i]=n}},e.prototype.tryToEncode=function(e,t){for(var r=0;r<this.builtInEncoders.length;r++){if(null!=(n=this.builtInEncoders[r]))if(null!=(i=n(e,t)))return new p(-1-r,i)}for(r=0;r<this.encoders.length;r++){var n,i;if(null!=(n=this.encoders[r]))if(null!=(i=n(e,t)))return new p(r,i)}return e instanceof p?e:null},e.prototype.decode=function(e,t,r){var n=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return n?n(e,t,r):new p(t,e)},e.defaultCodec=new e,e}();function E(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}var B=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},L=function(){function e(e,t,r,n,i,o,s){void 0===e&&(e=S.defaultCodec),void 0===r&&(r=100),void 0===n&&(n=2048),void 0===i&&(i=!1),void 0===o&&(o=!1),void 0===s&&(s=!1),this.extensionCodec=e,this.context=t,this.maxDepth=r,this.initialBufferSize=n,this.sortKeys=i,this.forceFloat32=o,this.ignoreUndefined=s,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}return e.prototype.encode=function(e,t){if(t>this.maxDepth)throw new Error("Too deep objects in depth "+t);null==e?this.encodeNil():"boolean"==typeof e?this.encodeBoolean(e):"number"==typeof e?this.encodeNumber(e):"string"==typeof e?this.encodeString(e):this.encodeObject(e,t)},e.prototype.getUint8Array=function(){return this.bytes.subarray(0,this.pos)},e.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(2*t)},e.prototype.resizeBuffer=function(e){var t=new ArrayBuffer(e),r=new Uint8Array(t),n=new DataView(t);r.set(this.bytes),this.view=n,this.bytes=r},e.prototype.encodeNil=function(){this.writeU8(192)},e.prototype.encodeBoolean=function(e){!1===e?this.writeU8(194):this.writeU8(195)},e.prototype.encodeNumber=function(e){Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},e.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else{if(!(e<4294967296))throw new Error("Too long string: "+e+" bytes in UTF-8");this.writeU8(219),this.writeU32(e)}},e.prototype.encodeString=function(e){var t=e.length;if(o&&t>h){var r=s(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),u(e,this.bytes,this.pos),this.pos+=r}else{r=s(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),function(e,t,r){for(var n=e.length,i=r,o=0;o<n;){var s=e.charCodeAt(o++);if(0!=(4294967168&s)){if(0==(4294965248&s))t[i++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<n){var a=e.charCodeAt(o);56320==(64512&a)&&(++o,s=((1023&s)<<10)+(1023&a)+65536)}0==(4294901760&s)?(t[i++]=s>>12&15|224,t[i++]=s>>6&63|128):(t[i++]=s>>18&7|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128)}t[i++]=63&s|128}else t[i++]=s}}(e,this.bytes,this.pos),this.pos+=r}},e.prototype.encodeObject=function(e,t){var r=this.extensionCodec.tryToEncode(e,this.context);if(null!=r)this.encodeExtension(r);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else{if("object"!=typeof e)throw new Error("Unrecognized object: "+Object.prototype.toString.apply(e));this.encodeMap(e,t)}},e.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large binary: "+t);this.writeU8(198),this.writeU32(t)}var r=E(e);this.writeU8a(r)},e.prototype.encodeArray=function(e,t){var r,n,i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else{if(!(i<4294967296))throw new Error("Too large array: "+i);this.writeU8(221),this.writeU32(i)}try{for(var o=B(e),s=o.next();!s.done;s=o.next()){var a=s.value;this.encode(a,t+1)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}},e.prototype.countWithoutUndefined=function(e,t){var r,n,i=0;try{for(var o=B(t),s=o.next();!s.done;s=o.next()){void 0!==e[s.value]&&i++}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},e.prototype.encodeMap=function(e,t){var r,n,i=Object.keys(e);this.sortKeys&&i.sort();var o=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.length;if(o<16)this.writeU8(128+o);else if(o<65536)this.writeU8(222),this.writeU16(o);else{if(!(o<4294967296))throw new Error("Too large map object: "+o);this.writeU8(223),this.writeU32(o)}try{for(var s=B(i),a=s.next();!a.done;a=s.next()){var h=a.value,u=e[h];this.ignoreUndefined&&void 0===u||(this.encodeString(h),this.encode(u,t+1))}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}},e.prototype.encodeExtension=function(e){var t=e.data.length;if(1===t)this.writeU8(212);else if(2===t)this.writeU8(213);else if(4===t)this.writeU8(214);else if(8===t)this.writeU8(215);else if(16===t)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large extension object: "+t);this.writeU8(201),this.writeU32(t)}this.writeI8(e.type),this.writeU8a(e.data)},e.prototype.writeU8=function(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++},e.prototype.writeU8a=function(e){var t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t},e.prototype.writeI8=function(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++},e.prototype.writeU16=function(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2},e.prototype.writeI16=function(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2},e.prototype.writeU32=function(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4},e.prototype.writeI32=function(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4},e.prototype.writeF32=function(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4},e.prototype.writeF64=function(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8},e.prototype.writeU64=function(e){this.ensureBufferSizeToWrite(8),function(e,t,r){var n=r/4294967296,i=r;e.setUint32(t,n),e.setUint32(t+4,i)}(this.view,this.pos,e),this.pos+=8},e.prototype.writeI64=function(e){this.ensureBufferSizeToWrite(8),d(this.view,this.pos,e),this.pos+=8},e}(),A={};function I(e,t){void 0===t&&(t=A);var r=new L(t.extensionCodec,t.context,t.maxDepth,t.initialBufferSize,t.sortKeys,t.forceFloat32,t.ignoreUndefined);return r.encode(e,1),r.getUint8Array()}function T(e){return(e<0?"-":"")+"0x"+Math.abs(e).toString(16).padStart(2,"0")}var k=function(){function e(e,t){void 0===e&&(e=16),void 0===t&&(t=16),this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(var r=0;r<this.maxKeyLength;r++)this.caches.push([])}return e.prototype.canBeCached=function(e){return e>0&&e<=this.maxKeyLength},e.prototype.get=function(e,t,r){var n=this.caches[r-1],i=n.length;e:for(var o=0;o<i;o++){for(var s=n[o],a=s.bytes,h=0;h<r;h++)if(a[h]!==e[t+h])continue e;return s.value}return null},e.prototype.store=function(e,t){var r=this.caches[e.length-1],n={bytes:e,value:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=n:r.push(n)},e.prototype.decode=function(e,t,r){var n=this.get(e,t,r);if(null!=n)return n;var i=c(e,t,r),o=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(o,i),i},e}(),M=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}h((n=n.apply(e,t||[])).next())}))},z=function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},C=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,i,(t=e[r](t)).done,t.value)}))}}},D=function(e){return this instanceof D?(this.v=e,this):new D(e)},P=function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n;function s(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){o.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=i[e](t)).value instanceof D?Promise.resolve(r.value.v).then(h,u):c(o[0][2],r)}catch(e){c(o[0][3],e)}var r}function h(e){a("next",e)}function u(e){a("throw",e)}function c(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}},j=new DataView(new ArrayBuffer(0)),F=new Uint8Array(j.buffer),W=function(){try{j.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")}(),O=new W("Insufficient data"),K=new k,V=function(){function e(e,t,r,n,i,o,s,a){void 0===e&&(e=S.defaultCodec),void 0===r&&(r=4294967295),void 0===n&&(n=4294967295),void 0===i&&(i=4294967295),void 0===o&&(o=4294967295),void 0===s&&(s=4294967295),void 0===a&&(a=K),this.extensionCodec=e,this.context=t,this.maxStrLength=r,this.maxBinLength=n,this.maxArrayLength=i,this.maxMapLength=o,this.maxExtLength=s,this.cachedKeyDecoder=a,this.totalPos=0,this.pos=0,this.view=j,this.bytes=F,this.headByte=-1,this.stack=[]}return e.prototype.setBuffer=function(e){this.bytes=E(e),this.view=function(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=E(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}(this.bytes),this.pos=0},e.prototype.appendBuffer=function(e){if(-1!==this.headByte||this.hasRemaining()){var t=this.bytes.subarray(this.pos),r=E(e),n=new Uint8Array(t.length+r.length);n.set(t),n.set(r,t.length),this.setBuffer(n)}else this.setBuffer(e)},e.prototype.hasRemaining=function(e){return void 0===e&&(e=1),this.view.byteLength-this.pos>=e},e.prototype.createNoExtraBytesError=function(e){var t=this.view,r=this.pos;return new RangeError("Extra "+(t.byteLength-r)+" byte(s) found at buffer["+e+"]")},e.prototype.decodeSingleSync=function(){var e=this.decodeSync();if(this.hasRemaining())throw this.createNoExtraBytesError(this.pos);return e},e.prototype.decodeSingleAsync=function(e){var t,r,n,i;return M(this,void 0,void 0,(function(){var o,s,a,h,u,c,f,l;return z(this,(function(p){switch(p.label){case 0:o=!1,p.label=1;case 1:p.trys.push([1,6,7,12]),t=C(e),p.label=2;case 2:return[4,t.next()];case 3:if((r=p.sent()).done)return[3,5];if(a=r.value,o)throw this.createNoExtraBytesError(this.totalPos);this.appendBuffer(a);try{s=this.decodeSync(),o=!0}catch(e){if(!(e instanceof W))throw e}this.totalPos+=this.pos,p.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return h=p.sent(),n={error:h},[3,12];case 7:return p.trys.push([7,,10,11]),r&&!r.done&&(i=t.return)?[4,i.call(t)]:[3,9];case 8:p.sent(),p.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:if(o){if(this.hasRemaining())throw this.createNoExtraBytesError(this.totalPos);return[2,s]}throw c=(u=this).headByte,f=u.pos,l=u.totalPos,new RangeError("Insufficient data in parcing "+T(c)+" at "+l+" ("+f+" in the current buffer)")}}))}))},e.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},e.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},e.prototype.decodeMultiAsync=function(e,t){return P(this,arguments,(function(){var r,n,i,o,s,a,h,u,c;return z(this,(function(f){switch(f.label){case 0:r=t,n=-1,f.label=1;case 1:f.trys.push([1,13,14,19]),i=C(e),f.label=2;case 2:return[4,D(i.next())];case 3:if((o=f.sent()).done)return[3,12];if(s=o.value,t&&0===n)throw this.createNoExtraBytesError(this.totalPos);this.appendBuffer(s),r&&(n=this.readArraySize(),r=!1,this.complete()),f.label=4;case 4:f.trys.push([4,9,,10]),f.label=5;case 5:return[4,D(this.decodeSync())];case 6:return[4,f.sent()];case 7:return f.sent(),0==--n?[3,8]:[3,5];case 8:return[3,10];case 9:if(!((a=f.sent())instanceof W))throw a;return[3,10];case 10:this.totalPos+=this.pos,f.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return h=f.sent(),u={error:h},[3,19];case 14:return f.trys.push([14,,17,18]),o&&!o.done&&(c=i.return)?[4,D(c.call(i))]:[3,16];case 15:f.sent(),f.label=16;case 16:return[3,18];case 17:if(u)throw u.error;return[7];case 18:return[7];case 19:return[2]}}))}))},e.prototype.decodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){if(0!==(n=e-128)){this.pushMapState(n),this.complete();continue e}t={}}else if(e<160){if(0!==(n=e-144)){this.pushArrayState(n),this.complete();continue e}t=[]}else{var r=e-160;t=this.decodeUtf8String(r,0)}else if(192===e)t=null;else if(194===e)t=!1;else if(195===e)t=!0;else if(202===e)t=this.readF32();else if(203===e)t=this.readF64();else if(204===e)t=this.readU8();else if(205===e)t=this.readU16();else if(206===e)t=this.readU32();else if(207===e)t=this.readU64();else if(208===e)t=this.readI8();else if(209===e)t=this.readI16();else if(210===e)t=this.readI32();else if(211===e)t=this.readI64();else if(217===e){r=this.lookU8();t=this.decodeUtf8String(r,1)}else if(218===e){r=this.lookU16();t=this.decodeUtf8String(r,2)}else if(219===e){r=this.lookU32();t=this.decodeUtf8String(r,4)}else if(220===e){if(0!==(n=this.readU16())){this.pushArrayState(n),this.complete();continue e}t=[]}else if(221===e){if(0!==(n=this.readU32())){this.pushArrayState(n),this.complete();continue e}t=[]}else if(222===e){if(0!==(n=this.readU16())){this.pushMapState(n),this.complete();continue e}t={}}else if(223===e){if(0!==(n=this.readU32())){this.pushMapState(n),this.complete();continue e}t={}}else if(196===e){var n=this.lookU8();t=this.decodeBinary(n,1)}else if(197===e){n=this.lookU16();t=this.decodeBinary(n,2)}else if(198===e){n=this.lookU32();t=this.decodeBinary(n,4)}else if(212===e)t=this.decodeExtension(1,0);else if(213===e)t=this.decodeExtension(2,0);else if(214===e)t=this.decodeExtension(4,0);else if(215===e)t=this.decodeExtension(8,0);else if(216===e)t=this.decodeExtension(16,0);else if(199===e){n=this.lookU8();t=this.decodeExtension(n,1)}else if(200===e){n=this.lookU16();t=this.decodeExtension(n,2)}else{if(201!==e)throw new Error("Unrecognized type byte: "+T(e));n=this.lookU32();t=this.decodeExtension(n,4)}this.complete();for(var i=this.stack;i.length>0;){var o=i[i.length-1];if(0===o.type){if(o.array[o.position]=t,o.position++,o.position!==o.size)continue e;i.pop(),t=o.array}else{if(1===o.type){if(s=void 0,"string"!==(s=typeof t)&&"number"!==s)throw new Error("The type of key must be string or number but "+typeof t);o.key=t,o.type=2;continue e}if(o.map[o.key]=t,o.readCount++,o.readCount!==o.size){o.key=null,o.type=1;continue e}i.pop(),t=o.map}}return t}var s},e.prototype.readHeadByte=function(){return-1===this.headByte&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=-1},e.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new Error("Unrecognized array type byte: "+T(e))}},e.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new Error("Max length exceeded: map length ("+e+") > maxMapLengthLength ("+this.maxMapLength+")");this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new Error("Max length exceeded: array length ("+e+") > maxArrayLength ("+this.maxArrayLength+")");this.stack.push({type:0,size:e,array:new Array(e),position:0})},e.prototype.decodeUtf8String=function(e,t){var r;if(e>this.maxStrLength)throw new Error("Max length exceeded: UTF-8 byte length ("+e+") > maxStrLength ("+this.maxStrLength+")");if(this.bytes.byteLength<this.pos+t+e)throw O;var n,i=this.pos+t;return n=this.stateIsMapKey()&&(null===(r=this.cachedKeyDecoder)||void 0===r?void 0:r.canBeCached(e))?this.cachedKeyDecoder.decode(this.bytes,i,e):o&&e>l?function(e,t,r){var n=e.subarray(t,t+r);return f.decode(n)}(this.bytes,i,e):c(this.bytes,i,e),this.pos+=t+e,n},e.prototype.stateIsMapKey=function(){return this.stack.length>0&&1===this.stack[this.stack.length-1].type},e.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new Error("Max length exceeded: bin length ("+e+") > maxBinLength ("+this.maxBinLength+")");if(!this.hasRemaining(e+t))throw O;var r=this.pos+t,n=this.bytes.subarray(r,r+e);return this.pos+=t+e,n},e.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new Error("Max length exceeded: ext length ("+e+") > maxExtLength ("+this.maxExtLength+")");var r=this.view.getInt8(this.pos+t),n=this.decodeBinary(e,t+1);return this.extensionCodec.decode(n,r,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},e.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},e.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},e.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},e.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},e.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},e.prototype.readU64=function(){var e,t,r=(e=this.view,t=this.pos,4294967296*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,r},e.prototype.readI64=function(){var e=y(this.view,this.pos);return this.pos+=8,e},e.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},e.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},e}(),_={};function N(e,t){void 0===t&&(t=_);var r=new V(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength);return r.setBuffer(e),r.decodeSingleSync()}var R=function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},H=function(e){return this instanceof H?(this.v=e,this):new H(e)},G=function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n;function s(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){o.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=i[e](t)).value instanceof H?Promise.resolve(r.value.v).then(h,u):c(o[0][2],r)}catch(e){c(o[0][3],e)}var r}function h(e){a("next",e)}function u(e){a("throw",e)}function c(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}};function X(e){if(null==e)throw new Error("Assertion Failure: value must not be null nor undefined")}function q(e){return null!=e[Symbol.asyncIterator]?e:function(e){return G(this,arguments,(function(){var t,r,n,i;return R(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,H(t.read())];case 3:return r=o.sent(),n=r.done,i=r.value,n?[4,H(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return X(i),[4,H(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e)}var J=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}h((n=n.apply(e,t||[])).next())}))},Q=function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};function Y(e,t){return void 0===t&&(t=_),J(this,void 0,void 0,(function(){var r;return Q(this,(function(n){return r=q(e),[2,new V(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeSingleAsync(r)]}))}))}function Z(e,t){void 0===t&&(t=_);var r=q(e);return new V(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeArrayStream(r)}function $(e,t){void 0===t&&(t=_);var r=q(e);return new V(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeStream(r)}}])})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MessagePack=t():e.MessagePack=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t),r.d(t,"encode",(function(){return I})),r.d(t,"decode",(function(){return N})),r.d(t,"decodeAsync",(function(){return Y})),r.d(t,"decodeArrayStream",(function(){return Z})),r.d(t,"decodeStream",(function(){return $})),r.d(t,"Decoder",(function(){return _})),r.d(t,"Encoder",(function(){return L})),r.d(t,"ExtensionCodec",(function(){return S})),r.d(t,"ExtData",(function(){return d})),r.d(t,"EXT_TIMESTAMP",(function(){return w})),r.d(t,"encodeDateToTimeSpec",(function(){return g})),r.d(t,"encodeTimeSpecToTimestamp",(function(){return v})),r.d(t,"decodeTimestampToTimeSpec",(function(){return x})),r.d(t,"encodeTimestampExtension",(function(){return b})),r.d(t,"decodeTimestampExtension",(function(){return m}));var n=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(n(arguments[t]));return e},o="undefined"!=typeof process&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function s(e){for(var t=e.length,r=0,n=0;n<t;){var i=e.charCodeAt(n++);if(0!=(4294967168&i))if(0==(4294965248&i))r+=2;else{if(i>=55296&&i<=56319&&n<t){var o=e.charCodeAt(n);56320==(64512&o)&&(++n,i=((1023&i)<<10)+(1023&o)+65536)}r+=0==(4294901760&i)?3:4}else r++}return r}var a=o?new TextEncoder:void 0,h="undefined"!=typeof process?200:0;var u=(null==a?void 0:a.encodeInto)?function(e,t,r){a.encodeInto(e,t.subarray(r))}:function(e,t,r){t.set(a.encode(e),r)};function c(e,t,r){for(var n=t,o=n+r,s=[],a="";n<o;){var h=e[n++];if(0==(128&h))s.push(h);else if(192==(224&h)){var u=63&e[n++];s.push((31&h)<<6|u)}else if(224==(240&h)){u=63&e[n++];var c=63&e[n++];s.push((31&h)<<12|u<<6|c)}else if(240==(248&h)){var f=(7&h)<<18|(u=63&e[n++])<<12|(c=63&e[n++])<<6|63&e[n++];f>65535&&(f-=65536,s.push(f>>>10&1023|55296),f=56320|1023&f),s.push(f)}else s.push(h);s.length>=4096&&(a+=String.fromCharCode.apply(String,i(s)),s.length=0)}return s.length>0&&(a+=String.fromCharCode.apply(String,i(s))),a}var f=o?new TextDecoder:null,l="undefined"!=typeof process?200:0;var d=function(e,t){this.type=e,this.data=t};function p(e,t,r){var n=Math.floor(r/4294967296),i=r;e.setUint32(t,n),e.setUint32(t+4,i)}function y(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}var w=-1;function v(e){var t=e.sec,r=e.nsec;if(t>=0&&r>=0&&t<=17179869183){if(0===r&&t<=4294967295){var n=new Uint8Array(4);return(s=new DataView(n.buffer)).setUint32(0,t),n}var i=t/4294967296,o=4294967295&t;n=new Uint8Array(8);return(s=new DataView(n.buffer)).setUint32(0,r<<2|3&i),s.setUint32(4,o),n}var s;n=new Uint8Array(12);return(s=new DataView(n.buffer)).setUint32(0,r),p(s,4,t),n}function g(e){var t=e.getTime(),r=Math.floor(t/1e3),n=1e6*(t-1e3*r),i=Math.floor(n/1e9);return{sec:r+i,nsec:n-1e9*i}}function b(e){return e instanceof Date?v(g(e)):null}function x(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:var r=t.getUint32(0);return{sec:4294967296*(3&r)+t.getUint32(4),nsec:r>>>2};case 12:return{sec:y(t,4),nsec:t.getUint32(0)};default:throw new Error("Unrecognized data size for timestamp: "+e.length)}}function m(e){var t=x(e);return new Date(1e3*t.sec+t.nsec/1e6)}var U={type:w,encode:b,decode:m},S=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(U)}return e.prototype.register=function(e){var t=e.type,r=e.encode,n=e.decode;if(t>=0)this.encoders[t]=r,this.decoders[t]=n;else{var i=1+t;this.builtInEncoders[i]=r,this.builtInDecoders[i]=n}},e.prototype.tryToEncode=function(e,t){for(var r=0;r<this.builtInEncoders.length;r++){if(null!=(n=this.builtInEncoders[r]))if(null!=(i=n(e,t)))return new d(-1-r,i)}for(r=0;r<this.encoders.length;r++){var n,i;if(null!=(n=this.encoders[r]))if(null!=(i=n(e,t)))return new d(r,i)}return e instanceof d?e:null},e.prototype.decode=function(e,t,r){var n=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return n?n(e,t,r):new d(t,e)},e.defaultCodec=new e,e}();function E(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}var B=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},L=function(){function e(e,t,r,n,i,o,s){void 0===e&&(e=S.defaultCodec),void 0===t&&(t=void 0),void 0===r&&(r=100),void 0===n&&(n=2048),void 0===i&&(i=!1),void 0===o&&(o=!1),void 0===s&&(s=!1),this.extensionCodec=e,this.context=t,this.maxDepth=r,this.initialBufferSize=n,this.sortKeys=i,this.forceFloat32=o,this.ignoreUndefined=s,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}return e.prototype.getUint8Array=function(){return this.bytes.subarray(0,this.pos)},e.prototype.reinitializeState=function(){this.pos=0},e.prototype.encode=function(e){return this.reinitializeState(),this.doEncode(e,1),this.getUint8Array()},e.prototype.doEncode=function(e,t){if(t>this.maxDepth)throw new Error("Too deep objects in depth "+t);null==e?this.encodeNil():"boolean"==typeof e?this.encodeBoolean(e):"number"==typeof e?this.encodeNumber(e):"string"==typeof e?this.encodeString(e):this.encodeObject(e,t)},e.prototype.ensureBufferSizeToWrite=function(e){var t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(2*t)},e.prototype.resizeBuffer=function(e){var t=new ArrayBuffer(e),r=new Uint8Array(t),n=new DataView(t);r.set(this.bytes),this.view=n,this.bytes=r},e.prototype.encodeNil=function(){this.writeU8(192)},e.prototype.encodeBoolean=function(e){!1===e?this.writeU8(194):this.writeU8(195)},e.prototype.encodeNumber=function(e){Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):(this.writeU8(211),this.writeI64(e)):this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))},e.prototype.writeStringHeader=function(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else{if(!(e<4294967296))throw new Error("Too long string: "+e+" bytes in UTF-8");this.writeU8(219),this.writeU32(e)}},e.prototype.encodeString=function(e){var t=e.length;if(o&&t>h){var r=s(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),u(e,this.bytes,this.pos),this.pos+=r}else{r=s(e);this.ensureBufferSizeToWrite(5+r),this.writeStringHeader(r),function(e,t,r){for(var n=e.length,i=r,o=0;o<n;){var s=e.charCodeAt(o++);if(0!=(4294967168&s)){if(0==(4294965248&s))t[i++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<n){var a=e.charCodeAt(o);56320==(64512&a)&&(++o,s=((1023&s)<<10)+(1023&a)+65536)}0==(4294901760&s)?(t[i++]=s>>12&15|224,t[i++]=s>>6&63|128):(t[i++]=s>>18&7|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128)}t[i++]=63&s|128}else t[i++]=s}}(e,this.bytes,this.pos),this.pos+=r}},e.prototype.encodeObject=function(e,t){var r=this.extensionCodec.tryToEncode(e,this.context);if(null!=r)this.encodeExtension(r);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else{if("object"!=typeof e)throw new Error("Unrecognized object: "+Object.prototype.toString.apply(e));this.encodeMap(e,t)}},e.prototype.encodeBinary=function(e){var t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large binary: "+t);this.writeU8(198),this.writeU32(t)}var r=E(e);this.writeU8a(r)},e.prototype.encodeArray=function(e,t){var r,n,i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else{if(!(i<4294967296))throw new Error("Too large array: "+i);this.writeU8(221),this.writeU32(i)}try{for(var o=B(e),s=o.next();!s.done;s=o.next()){var a=s.value;this.doEncode(a,t+1)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}},e.prototype.countWithoutUndefined=function(e,t){var r,n,i=0;try{for(var o=B(t),s=o.next();!s.done;s=o.next()){void 0!==e[s.value]&&i++}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},e.prototype.encodeMap=function(e,t){var r,n,i=Object.keys(e);this.sortKeys&&i.sort();var o=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.length;if(o<16)this.writeU8(128+o);else if(o<65536)this.writeU8(222),this.writeU16(o);else{if(!(o<4294967296))throw new Error("Too large map object: "+o);this.writeU8(223),this.writeU32(o)}try{for(var s=B(i),a=s.next();!a.done;a=s.next()){var h=a.value,u=e[h];this.ignoreUndefined&&void 0===u||(this.encodeString(h),this.doEncode(u,t+1))}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}},e.prototype.encodeExtension=function(e){var t=e.data.length;if(1===t)this.writeU8(212);else if(2===t)this.writeU8(213);else if(4===t)this.writeU8(214);else if(8===t)this.writeU8(215);else if(16===t)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else{if(!(t<4294967296))throw new Error("Too large extension object: "+t);this.writeU8(201),this.writeU32(t)}this.writeI8(e.type),this.writeU8a(e.data)},e.prototype.writeU8=function(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++},e.prototype.writeU8a=function(e){var t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t},e.prototype.writeI8=function(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++},e.prototype.writeU16=function(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2},e.prototype.writeI16=function(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2},e.prototype.writeU32=function(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4},e.prototype.writeI32=function(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4},e.prototype.writeF32=function(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4},e.prototype.writeF64=function(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8},e.prototype.writeU64=function(e){this.ensureBufferSizeToWrite(8),function(e,t,r){var n=r/4294967296,i=r;e.setUint32(t,n),e.setUint32(t+4,i)}(this.view,this.pos,e),this.pos+=8},e.prototype.writeI64=function(e){this.ensureBufferSizeToWrite(8),p(this.view,this.pos,e),this.pos+=8},e}(),A={};function I(e,t){return void 0===t&&(t=A),new L(t.extensionCodec,t.context,t.maxDepth,t.initialBufferSize,t.sortKeys,t.forceFloat32,t.ignoreUndefined).encode(e)}function T(e){return(e<0?"-":"")+"0x"+Math.abs(e).toString(16).padStart(2,"0")}var k=function(){function e(e,t){void 0===e&&(e=16),void 0===t&&(t=16),this.maxKeyLength=e,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(var r=0;r<this.maxKeyLength;r++)this.caches.push([])}return e.prototype.canBeCached=function(e){return e>0&&e<=this.maxKeyLength},e.prototype.get=function(e,t,r){var n=this.caches[r-1],i=n.length;e:for(var o=0;o<i;o++){for(var s=n[o],a=s.bytes,h=0;h<r;h++)if(a[h]!==e[t+h])continue e;return s.value}return null},e.prototype.store=function(e,t){var r=this.caches[e.length-1],n={bytes:e,value:t};r.length>=this.maxLengthPerKey?r[Math.random()*r.length|0]=n:r.push(n)},e.prototype.decode=function(e,t,r){var n=this.get(e,t,r);if(null!=n)return this.hit++,n;this.miss++;var i=c(e,t,r),o=Uint8Array.prototype.slice.call(e,t,t+r);return this.store(o,i),i},e}(),M=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}h((n=n.apply(e,t||[])).next())}))},z=function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},D=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,i,(t=e[r](t)).done,t.value)}))}}},C=function(e){return this instanceof C?(this.v=e,this):new C(e)},P=function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n;function s(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){o.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=i[e](t)).value instanceof C?Promise.resolve(r.value.v).then(h,u):c(o[0][2],r)}catch(e){c(o[0][3],e)}var r}function h(e){a("next",e)}function u(e){a("throw",e)}function c(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}},j=new DataView(new ArrayBuffer(0)),F=new Uint8Array(j.buffer),W=function(){try{j.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")}(),O=new W("Insufficient data"),V=new k,_=function(){function e(e,t,r,n,i,o,s,a){void 0===e&&(e=S.defaultCodec),void 0===t&&(t=void 0),void 0===r&&(r=4294967295),void 0===n&&(n=4294967295),void 0===i&&(i=4294967295),void 0===o&&(o=4294967295),void 0===s&&(s=4294967295),void 0===a&&(a=V),this.extensionCodec=e,this.context=t,this.maxStrLength=r,this.maxBinLength=n,this.maxArrayLength=i,this.maxMapLength=o,this.maxExtLength=s,this.keyDecoder=a,this.totalPos=0,this.pos=0,this.view=j,this.bytes=F,this.headByte=-1,this.stack=[]}return e.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=-1},e.prototype.setBuffer=function(e){this.bytes=E(e),this.view=function(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=E(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}(this.bytes),this.pos=0},e.prototype.appendBuffer=function(e){if(-1!==this.headByte||this.hasRemaining()){var t=this.bytes.subarray(this.pos),r=E(e),n=new Uint8Array(t.length+r.length);n.set(t),n.set(r,t.length),this.setBuffer(n)}else this.setBuffer(e)},e.prototype.hasRemaining=function(e){return void 0===e&&(e=1),this.view.byteLength-this.pos>=e},e.prototype.createNoExtraBytesError=function(e){var t=this.view,r=this.pos;return new RangeError("Extra "+(t.byteLength-r)+" of "+t.byteLength+" byte(s) found at buffer["+e+"]")},e.prototype.decode=function(e){return this.reinitializeState(),this.setBuffer(e),this.doDecodeSingleSync()},e.prototype.doDecodeSingleSync=function(){var e=this.doDecodeSync();if(this.hasRemaining())throw this.createNoExtraBytesError(this.pos);return e},e.prototype.decodeAsync=function(e){var t,r,n,i;return M(this,void 0,void 0,(function(){var o,s,a,h,u,c,f,l;return z(this,(function(d){switch(d.label){case 0:o=!1,d.label=1;case 1:d.trys.push([1,6,7,12]),t=D(e),d.label=2;case 2:return[4,t.next()];case 3:if((r=d.sent()).done)return[3,5];if(a=r.value,o)throw this.createNoExtraBytesError(this.totalPos);this.appendBuffer(a);try{s=this.doDecodeSync(),o=!0}catch(e){if(!(e instanceof W))throw e}this.totalPos+=this.pos,d.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return h=d.sent(),n={error:h},[3,12];case 7:return d.trys.push([7,,10,11]),r&&!r.done&&(i=t.return)?[4,i.call(t)]:[3,9];case 8:d.sent(),d.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:if(o){if(this.hasRemaining())throw this.createNoExtraBytesError(this.totalPos);return[2,s]}throw c=(u=this).headByte,f=u.pos,l=u.totalPos,new RangeError("Insufficient data in parcing "+T(c)+" at "+l+" ("+f+" in the current buffer)")}}))}))},e.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},e.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},e.prototype.decodeMultiAsync=function(e,t){return P(this,arguments,(function(){var r,n,i,o,s,a,h,u,c;return z(this,(function(f){switch(f.label){case 0:r=t,n=-1,f.label=1;case 1:f.trys.push([1,13,14,19]),i=D(e),f.label=2;case 2:return[4,C(i.next())];case 3:if((o=f.sent()).done)return[3,12];if(s=o.value,t&&0===n)throw this.createNoExtraBytesError(this.totalPos);this.appendBuffer(s),r&&(n=this.readArraySize(),r=!1,this.complete()),f.label=4;case 4:f.trys.push([4,9,,10]),f.label=5;case 5:return[4,C(this.doDecodeSync())];case 6:return[4,f.sent()];case 7:return f.sent(),0==--n?[3,8]:[3,5];case 8:return[3,10];case 9:if(!((a=f.sent())instanceof W))throw a;return[3,10];case 10:this.totalPos+=this.pos,f.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return h=f.sent(),u={error:h},[3,19];case 14:return f.trys.push([14,,17,18]),o&&!o.done&&(c=i.return)?[4,C(c.call(i))]:[3,16];case 15:f.sent(),f.label=16;case 16:return[3,18];case 17:if(u)throw u.error;return[7];case 18:return[7];case 19:return[2]}}))}))},e.prototype.doDecodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){if(0!==(n=e-128)){this.pushMapState(n),this.complete();continue e}t={}}else if(e<160){if(0!==(n=e-144)){this.pushArrayState(n),this.complete();continue e}t=[]}else{var r=e-160;t=this.decodeUtf8String(r,0)}else if(192===e)t=null;else if(194===e)t=!1;else if(195===e)t=!0;else if(202===e)t=this.readF32();else if(203===e)t=this.readF64();else if(204===e)t=this.readU8();else if(205===e)t=this.readU16();else if(206===e)t=this.readU32();else if(207===e)t=this.readU64();else if(208===e)t=this.readI8();else if(209===e)t=this.readI16();else if(210===e)t=this.readI32();else if(211===e)t=this.readI64();else if(217===e){r=this.lookU8();t=this.decodeUtf8String(r,1)}else if(218===e){r=this.lookU16();t=this.decodeUtf8String(r,2)}else if(219===e){r=this.lookU32();t=this.decodeUtf8String(r,4)}else if(220===e){if(0!==(n=this.readU16())){this.pushArrayState(n),this.complete();continue e}t=[]}else if(221===e){if(0!==(n=this.readU32())){this.pushArrayState(n),this.complete();continue e}t=[]}else if(222===e){if(0!==(n=this.readU16())){this.pushMapState(n),this.complete();continue e}t={}}else if(223===e){if(0!==(n=this.readU32())){this.pushMapState(n),this.complete();continue e}t={}}else if(196===e){var n=this.lookU8();t=this.decodeBinary(n,1)}else if(197===e){n=this.lookU16();t=this.decodeBinary(n,2)}else if(198===e){n=this.lookU32();t=this.decodeBinary(n,4)}else if(212===e)t=this.decodeExtension(1,0);else if(213===e)t=this.decodeExtension(2,0);else if(214===e)t=this.decodeExtension(4,0);else if(215===e)t=this.decodeExtension(8,0);else if(216===e)t=this.decodeExtension(16,0);else if(199===e){n=this.lookU8();t=this.decodeExtension(n,1)}else if(200===e){n=this.lookU16();t=this.decodeExtension(n,2)}else{if(201!==e)throw new Error("Unrecognized type byte: "+T(e));n=this.lookU32();t=this.decodeExtension(n,4)}this.complete();for(var i=this.stack;i.length>0;){var o=i[i.length-1];if(0===o.type){if(o.array[o.position]=t,o.position++,o.position!==o.size)continue e;i.pop(),t=o.array}else{if(1===o.type){if(s=void 0,"string"!==(s=typeof t)&&"number"!==s)throw new Error("The type of key must be string or number but "+typeof t);o.key=t,o.type=2;continue e}if(o.map[o.key]=t,o.readCount++,o.readCount!==o.size){o.key=null,o.type=1;continue e}i.pop(),t=o.map}}return t}var s},e.prototype.readHeadByte=function(){return-1===this.headByte&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=-1},e.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new Error("Unrecognized array type byte: "+T(e))}},e.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new Error("Max length exceeded: map length ("+e+") > maxMapLengthLength ("+this.maxMapLength+")");this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new Error("Max length exceeded: array length ("+e+") > maxArrayLength ("+this.maxArrayLength+")");this.stack.push({type:0,size:e,array:new Array(e),position:0})},e.prototype.decodeUtf8String=function(e,t){var r;if(e>this.maxStrLength)throw new Error("Max length exceeded: UTF-8 byte length ("+e+") > maxStrLength ("+this.maxStrLength+")");if(this.bytes.byteLength<this.pos+t+e)throw O;var n,i=this.pos+t;return n=this.stateIsMapKey()&&(null===(r=this.keyDecoder)||void 0===r?void 0:r.canBeCached(e))?this.keyDecoder.decode(this.bytes,i,e):o&&e>l?function(e,t,r){var n=e.subarray(t,t+r);return f.decode(n)}(this.bytes,i,e):c(this.bytes,i,e),this.pos+=t+e,n},e.prototype.stateIsMapKey=function(){return this.stack.length>0&&1===this.stack[this.stack.length-1].type},e.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new Error("Max length exceeded: bin length ("+e+") > maxBinLength ("+this.maxBinLength+")");if(!this.hasRemaining(e+t))throw O;var r=this.pos+t,n=this.bytes.subarray(r,r+e);return this.pos+=t+e,n},e.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new Error("Max length exceeded: ext length ("+e+") > maxExtLength ("+this.maxExtLength+")");var r=this.view.getInt8(this.pos+t),n=this.decodeBinary(e,t+1);return this.extensionCodec.decode(n,r,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},e.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},e.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},e.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},e.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},e.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},e.prototype.readU64=function(){var e,t,r=(e=this.view,t=this.pos,4294967296*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,r},e.prototype.readI64=function(){var e=y(this.view,this.pos);return this.pos+=8,e},e.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},e.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},e}(),K={};function N(e,t){return void 0===t&&(t=K),new _(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decode(e)}var R=function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},H=function(e){return this instanceof H?(this.v=e,this):new H(e)},G=function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(e,t||[]),o=[];return n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n;function s(e){i[e]&&(n[e]=function(t){return new Promise((function(r,n){o.push([e,t,r,n])>1||a(e,t)}))})}function a(e,t){try{(r=i[e](t)).value instanceof H?Promise.resolve(r.value.v).then(h,u):c(o[0][2],r)}catch(e){c(o[0][3],e)}var r}function h(e){a("next",e)}function u(e){a("throw",e)}function c(e,t){e(t),o.shift(),o.length&&a(o[0][0],o[0][1])}};function X(e){if(null==e)throw new Error("Assertion Failure: value must not be null nor undefined")}function q(e){return null!=e[Symbol.asyncIterator]?e:function(e){return G(this,arguments,(function(){var t,r,n,i;return R(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,H(t.read())];case 3:return r=o.sent(),n=r.done,i=r.value,n?[4,H(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return X(i),[4,H(i)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e)}var J=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{h(n.next(e))}catch(e){o(e)}}function a(e){try{h(n.throw(e))}catch(e){o(e)}}function h(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}h((n=n.apply(e,t||[])).next())}))},Q=function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};function Y(e,t){return void 0===t&&(t=K),J(this,void 0,void 0,(function(){var r;return Q(this,(function(n){return r=q(e),[2,new _(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeAsync(r)]}))}))}function Z(e,t){void 0===t&&(t=K);var r=q(e);return new _(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeArrayStream(r)}function $(e,t){void 0===t&&(t=K);var r=q(e);return new _(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeStream(r)}}])})); | ||
//# sourceMappingURL=msgpack.min.js.map |
@@ -1,4 +0,10 @@ | ||
export declare class CachedKeyDecoder { | ||
export interface KeyDecoder { | ||
canBeCached(byteLength: number): boolean; | ||
decode(bytes: Uint8Array, inputOffset: number, byteLength: number): string; | ||
} | ||
export declare class CachedKeyDecoder implements KeyDecoder { | ||
readonly maxKeyLength: number; | ||
readonly maxLengthPerKey: number; | ||
hit: number; | ||
miss: number; | ||
private readonly caches; | ||
@@ -5,0 +11,0 @@ constructor(maxKeyLength?: number, maxLengthPerKey?: number); |
@@ -11,2 +11,4 @@ "use strict"; | ||
this.maxLengthPerKey = maxLengthPerKey; | ||
this.hit = 0; | ||
this.miss = 0; | ||
// avoid `new Array(N)` to create a non-sparse array for performance. | ||
@@ -51,4 +53,6 @@ this.caches = []; | ||
if (cachedValue != null) { | ||
this.hit++; | ||
return cachedValue; | ||
} | ||
this.miss++; | ||
const value = utf8_1.utf8DecodeJs(bytes, inputOffset, byteLength); | ||
@@ -55,0 +59,0 @@ // Ensure to copy a slice of bytes because the byte may be NodeJS Buffer and Buffer#slice() returns a reference to its internal ArrayBuffer. |
"use strict"; | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=context.js.map |
@@ -13,6 +13,5 @@ "use strict"; | ||
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength); | ||
decoder.setBuffer(buffer); // decodeSync() requires only one buffer | ||
return decoder.decodeSingleSync(); | ||
return decoder.decode(buffer); | ||
} | ||
exports.decode = decode; | ||
//# sourceMappingURL=decode.js.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength); | ||
return decoder.decodeSingleAsync(stream); | ||
return decoder.decodeAsync(stream); | ||
} | ||
@@ -13,0 +13,0 @@ exports.decodeAsync = decodeAsync; |
import { ExtensionCodecType } from "./ExtensionCodec"; | ||
import { CachedKeyDecoder } from "./CachedKeyDecoder"; | ||
declare const enum State { | ||
ARRAY = 0, | ||
MAP_KEY = 1, | ||
MAP_VALUE = 2 | ||
} | ||
declare type MapKeyType = string | number; | ||
declare type StackMapState = { | ||
type: State.MAP_KEY | State.MAP_VALUE; | ||
size: number; | ||
key: MapKeyType | null; | ||
readCount: number; | ||
map: Record<string, unknown>; | ||
}; | ||
declare type StackArrayState = { | ||
type: State.ARRAY; | ||
size: number; | ||
array: Array<unknown>; | ||
position: number; | ||
}; | ||
declare type StackState = StackArrayState | StackMapState; | ||
import { KeyDecoder } from "./CachedKeyDecoder"; | ||
export declare const DataViewIndexOutOfBoundsError: typeof Error; | ||
export declare class Decoder<ContextType> { | ||
readonly extensionCodec: ExtensionCodecType<ContextType>; | ||
readonly context: ContextType; | ||
readonly maxStrLength: number; | ||
readonly maxBinLength: number; | ||
readonly maxArrayLength: number; | ||
readonly maxMapLength: number; | ||
readonly maxExtLength: number; | ||
readonly cachedKeyDecoder: CachedKeyDecoder | null; | ||
totalPos: number; | ||
pos: number; | ||
view: DataView; | ||
bytes: Uint8Array; | ||
headByte: number; | ||
readonly stack: Array<StackState>; | ||
constructor(extensionCodec: ExtensionCodecType<ContextType>, context: ContextType, maxStrLength?: number, maxBinLength?: number, maxArrayLength?: number, maxMapLength?: number, maxExtLength?: number, cachedKeyDecoder?: CachedKeyDecoder | null); | ||
setBuffer(buffer: ArrayLike<number> | ArrayBuffer): void; | ||
appendBuffer(buffer: ArrayLike<number>): void; | ||
hasRemaining(size?: number): boolean; | ||
createNoExtraBytesError(posToShow: number): Error; | ||
decodeSingleSync(): unknown; | ||
decodeSingleAsync(stream: AsyncIterable<ArrayLike<number>>): Promise<unknown>; | ||
private readonly extensionCodec; | ||
private readonly context; | ||
private readonly maxStrLength; | ||
private readonly maxBinLength; | ||
private readonly maxArrayLength; | ||
private readonly maxMapLength; | ||
private readonly maxExtLength; | ||
private readonly keyDecoder; | ||
private totalPos; | ||
private pos; | ||
private view; | ||
private bytes; | ||
private headByte; | ||
private readonly stack; | ||
constructor(extensionCodec?: ExtensionCodecType<ContextType>, context?: ContextType, maxStrLength?: number, maxBinLength?: number, maxArrayLength?: number, maxMapLength?: number, maxExtLength?: number, keyDecoder?: KeyDecoder | null); | ||
private reinitializeState; | ||
private setBuffer; | ||
private appendBuffer; | ||
private hasRemaining; | ||
private createNoExtraBytesError; | ||
decode(buffer: ArrayLike<number> | ArrayBuffer): unknown; | ||
private doDecodeSingleSync; | ||
decodeAsync(stream: AsyncIterable<ArrayLike<number>>): Promise<unknown>; | ||
decodeArrayStream(stream: AsyncIterable<ArrayLike<number>>): AsyncGenerator<unknown, void, unknown>; | ||
decodeStream(stream: AsyncIterable<ArrayLike<number>>): AsyncGenerator<unknown, void, unknown>; | ||
private decodeMultiAsync; | ||
decodeSync(): unknown; | ||
readHeadByte(): number; | ||
complete(): void; | ||
readArraySize(): number; | ||
pushMapState(size: number): void; | ||
pushArrayState(size: number): void; | ||
decodeUtf8String(byteLength: number, headerOffset: number): string; | ||
stateIsMapKey(): boolean; | ||
decodeBinary(byteLength: number, headOffset: number): Uint8Array; | ||
decodeExtension(size: number, headOffset: number): unknown; | ||
lookU8(): number; | ||
lookU16(): number; | ||
lookU32(): number; | ||
readU8(): number; | ||
readI8(): number; | ||
readU16(): number; | ||
readI16(): number; | ||
readU32(): number; | ||
readI32(): number; | ||
readU64(): number; | ||
readI64(): number; | ||
readF32(): number; | ||
readF64(): number; | ||
private doDecodeSync; | ||
private readHeadByte; | ||
private complete; | ||
private readArraySize; | ||
private pushMapState; | ||
private pushArrayState; | ||
private decodeUtf8String; | ||
private stateIsMapKey; | ||
private decodeBinary; | ||
private decodeExtension; | ||
private lookU8; | ||
private lookU16; | ||
private lookU32; | ||
private readU8; | ||
private readI8; | ||
private readU16; | ||
private readI16; | ||
private readU32; | ||
private readI32; | ||
private readU64; | ||
private readI64; | ||
private readF32; | ||
private readF64; | ||
} | ||
export {}; |
@@ -34,3 +34,3 @@ "use strict"; | ||
class Decoder { | ||
constructor(extensionCodec = ExtensionCodec_1.ExtensionCodec.defaultCodec, context, maxStrLength = DEFAULT_MAX_LENGTH, maxBinLength = DEFAULT_MAX_LENGTH, maxArrayLength = DEFAULT_MAX_LENGTH, maxMapLength = DEFAULT_MAX_LENGTH, maxExtLength = DEFAULT_MAX_LENGTH, cachedKeyDecoder = sharedCachedKeyDecoder) { | ||
constructor(extensionCodec = ExtensionCodec_1.ExtensionCodec.defaultCodec, context = undefined, maxStrLength = DEFAULT_MAX_LENGTH, maxBinLength = DEFAULT_MAX_LENGTH, maxArrayLength = DEFAULT_MAX_LENGTH, maxMapLength = DEFAULT_MAX_LENGTH, maxExtLength = DEFAULT_MAX_LENGTH, keyDecoder = sharedCachedKeyDecoder) { | ||
this.extensionCodec = extensionCodec; | ||
@@ -43,3 +43,3 @@ this.context = context; | ||
this.maxExtLength = maxExtLength; | ||
this.cachedKeyDecoder = cachedKeyDecoder; | ||
this.keyDecoder = keyDecoder; | ||
this.totalPos = 0; | ||
@@ -52,2 +52,6 @@ this.pos = 0; | ||
} | ||
reinitializeState() { | ||
this.totalPos = 0; | ||
this.headByte = HEAD_BYTE_REQUIRED; | ||
} | ||
setBuffer(buffer) { | ||
@@ -77,6 +81,11 @@ this.bytes = typedArrays_1.ensureUint8Array(buffer); | ||
const { view, pos } = this; | ||
return new RangeError(`Extra ${view.byteLength - pos} byte(s) found at buffer[${posToShow}]`); | ||
return new RangeError(`Extra ${view.byteLength - pos} of ${view.byteLength} byte(s) found at buffer[${posToShow}]`); | ||
} | ||
decodeSingleSync() { | ||
const object = this.decodeSync(); | ||
decode(buffer) { | ||
this.reinitializeState(); | ||
this.setBuffer(buffer); | ||
return this.doDecodeSingleSync(); | ||
} | ||
doDecodeSingleSync() { | ||
const object = this.doDecodeSync(); | ||
if (this.hasRemaining()) { | ||
@@ -87,3 +96,3 @@ throw this.createNoExtraBytesError(this.pos); | ||
} | ||
async decodeSingleAsync(stream) { | ||
async decodeAsync(stream) { | ||
let decoded = false; | ||
@@ -97,3 +106,3 @@ let object; | ||
try { | ||
object = this.decodeSync(); | ||
object = this.doDecodeSync(); | ||
decoded = true; | ||
@@ -139,3 +148,3 @@ } | ||
while (true) { | ||
yield this.decodeSync(); | ||
yield this.doDecodeSync(); | ||
if (--arrayItemsLeft === 0) { | ||
@@ -155,3 +164,3 @@ break; | ||
} | ||
decodeSync() { | ||
doDecodeSync() { | ||
DECODE: while (true) { | ||
@@ -470,4 +479,4 @@ const headByte = this.readHeadByte(); | ||
let object; | ||
if (this.stateIsMapKey() && ((_a = this.cachedKeyDecoder) === null || _a === void 0 ? void 0 : _a.canBeCached(byteLength))) { | ||
object = this.cachedKeyDecoder.decode(this.bytes, offset, byteLength); | ||
if (this.stateIsMapKey() && ((_a = this.keyDecoder) === null || _a === void 0 ? void 0 : _a.canBeCached(byteLength))) { | ||
object = this.keyDecoder.decode(this.bytes, offset, byteLength); | ||
} | ||
@@ -474,0 +483,0 @@ else if (utf8_1.TEXT_ENCODING_AVAILABLE && byteLength > utf8_1.TEXT_DECODER_THRESHOLD) { |
@@ -14,6 +14,5 @@ "use strict"; | ||
const encoder = new Encoder_1.Encoder(options.extensionCodec, options.context, options.maxDepth, options.initialBufferSize, options.sortKeys, options.forceFloat32, options.ignoreUndefined); | ||
encoder.encode(value, 1); | ||
return encoder.getUint8Array(); | ||
return encoder.encode(value); | ||
} | ||
exports.encode = encode; | ||
//# sourceMappingURL=encode.js.map |
import { ExtensionCodecType } from "./ExtensionCodec"; | ||
import { ExtData } from "./ExtData"; | ||
export declare const DEFAULT_MAX_DEPTH = 100; | ||
export declare const DEFAULT_INITIAL_BUFFER_SIZE = 2048; | ||
export declare class Encoder<ContextType> { | ||
readonly extensionCodec: ExtensionCodecType<ContextType>; | ||
readonly context: ContextType; | ||
readonly maxDepth: number; | ||
readonly initialBufferSize: number; | ||
readonly sortKeys: boolean; | ||
readonly forceFloat32: boolean; | ||
readonly ignoreUndefined: boolean; | ||
private readonly extensionCodec; | ||
private readonly context; | ||
private readonly maxDepth; | ||
private readonly initialBufferSize; | ||
private readonly sortKeys; | ||
private readonly forceFloat32; | ||
private readonly ignoreUndefined; | ||
private pos; | ||
private view; | ||
private bytes; | ||
constructor(extensionCodec: ExtensionCodecType<ContextType>, context: ContextType, maxDepth?: number, initialBufferSize?: number, sortKeys?: boolean, forceFloat32?: boolean, ignoreUndefined?: boolean); | ||
encode(object: unknown, depth: number): void; | ||
getUint8Array(): Uint8Array; | ||
ensureBufferSizeToWrite(sizeToWrite: number): void; | ||
resizeBuffer(newSize: number): void; | ||
encodeNil(): void; | ||
encodeBoolean(object: boolean): void; | ||
encodeNumber(object: number): void; | ||
writeStringHeader(byteLength: number): void; | ||
encodeString(object: string): void; | ||
encodeObject(object: unknown, depth: number): void; | ||
encodeBinary(object: ArrayBufferView): void; | ||
encodeArray(object: Array<unknown>, depth: number): void; | ||
countWithoutUndefined(object: Record<string, unknown>, keys: ReadonlyArray<string>): number; | ||
encodeMap(object: Record<string, unknown>, depth: number): void; | ||
encodeExtension(ext: ExtData): void; | ||
writeU8(value: number): void; | ||
writeU8a(values: ArrayLike<number>): void; | ||
writeI8(value: number): void; | ||
writeU16(value: number): void; | ||
writeI16(value: number): void; | ||
writeU32(value: number): void; | ||
writeI32(value: number): void; | ||
writeF32(value: number): void; | ||
writeF64(value: number): void; | ||
writeU64(value: number): void; | ||
writeI64(value: number): void; | ||
constructor(extensionCodec?: ExtensionCodecType<ContextType>, context?: ContextType, maxDepth?: number, initialBufferSize?: number, sortKeys?: boolean, forceFloat32?: boolean, ignoreUndefined?: boolean); | ||
private getUint8Array; | ||
private reinitializeState; | ||
encode(object: unknown): Uint8Array; | ||
private doEncode; | ||
private ensureBufferSizeToWrite; | ||
private resizeBuffer; | ||
private encodeNil; | ||
private encodeBoolean; | ||
private encodeNumber; | ||
private writeStringHeader; | ||
private encodeString; | ||
private encodeObject; | ||
private encodeBinary; | ||
private encodeArray; | ||
private countWithoutUndefined; | ||
private encodeMap; | ||
private encodeExtension; | ||
private writeU8; | ||
private writeU8a; | ||
private writeI8; | ||
private writeU16; | ||
private writeI16; | ||
private writeU32; | ||
private writeI32; | ||
private writeF32; | ||
private writeF64; | ||
private writeU64; | ||
private writeI64; | ||
} |
@@ -11,3 +11,3 @@ "use strict"; | ||
class Encoder { | ||
constructor(extensionCodec = ExtensionCodec_1.ExtensionCodec.defaultCodec, context, maxDepth = exports.DEFAULT_MAX_DEPTH, initialBufferSize = exports.DEFAULT_INITIAL_BUFFER_SIZE, sortKeys = false, forceFloat32 = false, ignoreUndefined = false) { | ||
constructor(extensionCodec = ExtensionCodec_1.ExtensionCodec.defaultCodec, context = undefined, maxDepth = exports.DEFAULT_MAX_DEPTH, initialBufferSize = exports.DEFAULT_INITIAL_BUFFER_SIZE, sortKeys = false, forceFloat32 = false, ignoreUndefined = false) { | ||
this.extensionCodec = extensionCodec; | ||
@@ -24,3 +24,14 @@ this.context = context; | ||
} | ||
encode(object, depth) { | ||
getUint8Array() { | ||
return this.bytes.subarray(0, this.pos); | ||
} | ||
reinitializeState() { | ||
this.pos = 0; | ||
} | ||
encode(object) { | ||
this.reinitializeState(); | ||
this.doEncode(object, 1); | ||
return this.getUint8Array(); | ||
} | ||
doEncode(object, depth) { | ||
if (depth > this.maxDepth) { | ||
@@ -45,5 +56,2 @@ throw new Error(`Too deep objects in depth ${depth}`); | ||
} | ||
getUint8Array() { | ||
return this.bytes.subarray(0, this.pos); | ||
} | ||
ensureBufferSizeToWrite(sizeToWrite) { | ||
@@ -248,3 +256,3 @@ const requiredSize = this.pos + sizeToWrite; | ||
for (const item of object) { | ||
this.encode(item, depth + 1); | ||
this.doEncode(item, depth + 1); | ||
} | ||
@@ -288,3 +296,3 @@ } | ||
this.encodeString(key); | ||
this.encode(value, depth + 1); | ||
this.doEncode(value, depth + 1); | ||
} | ||
@@ -291,0 +299,0 @@ } |
@@ -7,70 +7,67 @@ "use strict"; | ||
const timestamp_1 = require("./timestamp"); | ||
let ExtensionCodec = /** @class */ (() => { | ||
class ExtensionCodec { | ||
constructor() { | ||
// built-in extensions | ||
this.builtInEncoders = []; | ||
this.builtInDecoders = []; | ||
class ExtensionCodec { | ||
constructor() { | ||
// built-in extensions | ||
this.builtInEncoders = []; | ||
this.builtInDecoders = []; | ||
// custom extensions | ||
this.encoders = []; | ||
this.decoders = []; | ||
this.register(timestamp_1.timestampExtension); | ||
} | ||
register({ type, encode, decode, }) { | ||
if (type >= 0) { | ||
// custom extensions | ||
this.encoders = []; | ||
this.decoders = []; | ||
this.register(timestamp_1.timestampExtension); | ||
this.encoders[type] = encode; | ||
this.decoders[type] = decode; | ||
} | ||
register({ type, encode, decode, }) { | ||
if (type >= 0) { | ||
// custom extensions | ||
this.encoders[type] = encode; | ||
this.decoders[type] = decode; | ||
} | ||
else { | ||
// built-in extensions | ||
const index = 1 + type; | ||
this.builtInEncoders[index] = encode; | ||
this.builtInDecoders[index] = decode; | ||
} | ||
else { | ||
// built-in extensions | ||
const index = 1 + type; | ||
this.builtInEncoders[index] = encode; | ||
this.builtInDecoders[index] = decode; | ||
} | ||
tryToEncode(object, context) { | ||
// built-in extensions | ||
for (let i = 0; i < this.builtInEncoders.length; i++) { | ||
const encoder = this.builtInEncoders[i]; | ||
if (encoder != null) { | ||
const data = encoder(object, context); | ||
if (data != null) { | ||
const type = -1 - i; | ||
return new ExtData_1.ExtData(type, data); | ||
} | ||
} | ||
tryToEncode(object, context) { | ||
// built-in extensions | ||
for (let i = 0; i < this.builtInEncoders.length; i++) { | ||
const encoder = this.builtInEncoders[i]; | ||
if (encoder != null) { | ||
const data = encoder(object, context); | ||
if (data != null) { | ||
const type = -1 - i; | ||
return new ExtData_1.ExtData(type, data); | ||
} | ||
} | ||
// custom extensions | ||
for (let i = 0; i < this.encoders.length; i++) { | ||
const encoder = this.encoders[i]; | ||
if (encoder != null) { | ||
const data = encoder(object, context); | ||
if (data != null) { | ||
const type = i; | ||
return new ExtData_1.ExtData(type, data); | ||
} | ||
} | ||
// custom extensions | ||
for (let i = 0; i < this.encoders.length; i++) { | ||
const encoder = this.encoders[i]; | ||
if (encoder != null) { | ||
const data = encoder(object, context); | ||
if (data != null) { | ||
const type = i; | ||
return new ExtData_1.ExtData(type, data); | ||
} | ||
} | ||
if (object instanceof ExtData_1.ExtData) { | ||
// to keep ExtData as is | ||
return object; | ||
} | ||
return null; | ||
} | ||
decode(data, type, context) { | ||
const decoder = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type]; | ||
if (decoder) { | ||
return decoder(data, type, context); | ||
} | ||
else { | ||
// decode() does not fail, returns ExtData instead. | ||
return new ExtData_1.ExtData(type, data); | ||
} | ||
if (object instanceof ExtData_1.ExtData) { | ||
// to keep ExtData as is | ||
return object; | ||
} | ||
return null; | ||
} | ||
ExtensionCodec.defaultCodec = new ExtensionCodec(); | ||
return ExtensionCodec; | ||
})(); | ||
decode(data, type, context) { | ||
const decoder = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type]; | ||
if (decoder) { | ||
return decoder(data, type, context); | ||
} | ||
else { | ||
// decode() does not fail, returns ExtData instead. | ||
return new ExtData_1.ExtData(type, data); | ||
} | ||
} | ||
} | ||
exports.ExtensionCodec = ExtensionCodec; | ||
ExtensionCodec.defaultCodec = new ExtensionCodec(); | ||
//# sourceMappingURL=ExtensionCodec.js.map |
"use strict"; | ||
// Main Functions: | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decodeTimestampExtension = exports.encodeTimestampExtension = exports.decodeTimestampToTimeSpec = exports.encodeTimeSpecToTimestamp = exports.encodeDateToTimeSpec = exports.EXT_TIMESTAMP = exports.ExtData = exports.ExtensionCodec = exports.Encoder = exports.Decoder = exports.decodeStream = exports.decodeArrayStream = exports.decodeAsync = exports.decode = exports.encode = void 0; | ||
var encode_1 = require("./encode"); | ||
@@ -5,0 +6,0 @@ Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return encode_1.encode; } }); |
export declare type ReadableStreamLike<T> = AsyncIterable<T> | ReadableStream<T>; | ||
export declare function isAsyncIterable<T>(object: object): object is AsyncIterable<T>; | ||
export declare function isAsyncIterable<T>(object: ReadableStreamLike<T>): object is AsyncIterable<T>; | ||
export declare function asyncIterableFromStream<T>(stream: ReadableStream<T>): AsyncIterable<T>; | ||
export declare function ensureAsyncIterabe<T>(streamLike: ReadableStreamLike<T>): AsyncIterable<T>; |
{ | ||
"name": "@msgpack/msgpack", | ||
"version": "1.12.2", | ||
"version": "2.0.0", | ||
"description": "MessagePack for JavaScript/ECMA-262", | ||
@@ -33,3 +33,3 @@ "author": "The MessagePack community", | ||
"lint:print-config": "eslint --print-config .eslintrc.js", | ||
"update-dependencies": "rimraf node_modules/ package-lock.json && npm install && npm dedupe" | ||
"update-dependencies": "npx rimraf node_modules/ package-lock.json && npm install && npm dedupe" | ||
}, | ||
@@ -36,0 +36,0 @@ "homepage": "https://msgpack.org/", |
@@ -52,4 +52,5 @@ # MessagePack for JavaScript/ECMA-262 | ||
- [`decodeStream(stream: AsyncIterable<ArrayLike<number>> | ReadableStream<ArrayLike<number>>, options?: DecodeAsyncOptions): AsyncIterable<unknown>`](#decodestreamstream-asynciterablearraylikenumber--readablestreamarraylikenumber-options-decodeasyncoptions-asynciterableunknown) | ||
- [Extension Types](#extension-types) | ||
- [Codec context](#codec-context) | ||
- [Reusing Encoder and Decoder instances](#reusing-encoder-and-decoder-instances) | ||
- [Extension Types](#extension-types) | ||
- [ExtensionCodec context](#extensioncodec-context) | ||
- [Handling BigInt with ExtensionCodec](#handling-bigint-with-extensioncodec) | ||
@@ -216,4 +217,24 @@ - [The temporal module as timestamp extensions](#the-temporal-module-as-timestamp-extensions) | ||
### Extension Types | ||
### Reusing Encoder and Decoder instances | ||
`Encoder` and `Decoder` classes is provided for better performance: | ||
```typescript | ||
import { deepStrictEqual } from "assert"; | ||
import { Encoder, Decoder } from "@msgpack/msgpack"; | ||
const encoder = new Encoder(); | ||
const decoder = new Decoder(); | ||
const encoded: Uint8Array = encoder.encode(object); | ||
deepStrictEqual(decoder.decode(encoded), object); | ||
``` | ||
According to our benchmark, reusing `Encoder` instance is about 2% faster | ||
than `encode()` function, and reusing `Decoder` instance is about 35% faster | ||
than `decode()` function. Note that the result should vary in environments | ||
and data structure. | ||
## Extension Types | ||
To handle [MessagePack Extension Types](https://github.com/msgpack/msgpack/blob/master/spec.md#extension-types), this library provides `ExtensionCodec` class. | ||
@@ -271,3 +292,3 @@ | ||
#### Codec context | ||
#### ExtensionCodec context | ||
@@ -401,11 +422,11 @@ When using an extension codec, it may be necessary to keep encoding/decoding state, to keep track of which objects got encoded/re-created. To do this, pass a `context` to the `EncodeOptions` and `DecodeOptions` (and if using typescript, type the `ExtensionCodec` too). Don't forget to pass the `{extensionCodec, context}` along recursive encoding/decoding: | ||
```typescript | ||
// (1) Blob#arrayBuffer(): Promise<ArrayBuffer> | ||
async function f(blob: Blob) { | ||
const object = decode(await blob.arrayBuffer()); | ||
async function decodeFromBlob(blob: Blob): unknown { | ||
if (blob.stream) { | ||
// Blob#stream(): ReadableStream<Uint8Array> (recommended) | ||
return await decodeAsync(blob.stream()); | ||
} else { | ||
// Blob#arrayBuffer(): Promise<ArrayBuffer> (if stream() is not available) | ||
return decode(await blob.arrayBuffer()); | ||
} | ||
} | ||
// (2) Blob#stream(): ReadableStream<Uint8Array> | ||
async function g(blob: Blob) { | ||
const object = await decodeAsync(blob.stream()); | ||
} | ||
``` | ||
@@ -412,0 +433,0 @@ |
@@ -11,3 +11,10 @@ import { utf8DecodeJs } from "./utils/utf8"; | ||
export class CachedKeyDecoder { | ||
export interface KeyDecoder { | ||
canBeCached(byteLength: number): boolean; | ||
decode(bytes: Uint8Array, inputOffset: number, byteLength: number): string; | ||
} | ||
export class CachedKeyDecoder implements KeyDecoder { | ||
hit = 0; | ||
miss = 0; | ||
private readonly caches: Array<Array<KeyCacheRecord>>; | ||
@@ -61,4 +68,6 @@ | ||
if (cachedValue != null) { | ||
this.hit++; | ||
return cachedValue; | ||
} | ||
this.miss++; | ||
@@ -65,0 +74,0 @@ const value = utf8DecodeJs(bytes, inputOffset, byteLength); |
@@ -0,1 +1,3 @@ | ||
/* eslint-disable @typescript-eslint/ban-types */ | ||
export type SplitTypes<T, U> = U extends T ? U : Exclude<T, U>; | ||
@@ -2,0 +4,0 @@ export type SplitUndefined<T> = SplitTypes<T, undefined>; |
@@ -58,4 +58,3 @@ import { ExtensionCodecType } from "./ExtensionCodec"; | ||
); | ||
decoder.setBuffer(buffer); // decodeSync() requires only one buffer | ||
return decoder.decodeSingleSync(); | ||
return decoder.decode(buffer); | ||
} |
@@ -21,3 +21,3 @@ import { Decoder } from "./Decoder"; | ||
); | ||
return decoder.decodeSingleAsync(stream); | ||
return decoder.decodeAsync(stream); | ||
} | ||
@@ -24,0 +24,0 @@ |
@@ -6,3 +6,3 @@ import { prettyByte } from "./utils/prettyByte"; | ||
import { createDataView, ensureUint8Array } from "./utils/typedArrays"; | ||
import { CachedKeyDecoder } from "./CachedKeyDecoder"; | ||
import { CachedKeyDecoder, KeyDecoder } from "./CachedKeyDecoder"; | ||
@@ -65,22 +65,27 @@ const enum State { | ||
export class Decoder<ContextType> { | ||
totalPos = 0; | ||
pos = 0; | ||
private totalPos = 0; | ||
private pos = 0; | ||
view = EMPTY_VIEW; | ||
bytes = EMPTY_BYTES; | ||
headByte = HEAD_BYTE_REQUIRED; | ||
readonly stack: Array<StackState> = []; | ||
private view = EMPTY_VIEW; | ||
private bytes = EMPTY_BYTES; | ||
private headByte = HEAD_BYTE_REQUIRED; | ||
private readonly stack: Array<StackState> = []; | ||
constructor( | ||
readonly extensionCodec: ExtensionCodecType<ContextType> = ExtensionCodec.defaultCodec as any, | ||
readonly context: ContextType, | ||
readonly maxStrLength = DEFAULT_MAX_LENGTH, | ||
readonly maxBinLength = DEFAULT_MAX_LENGTH, | ||
readonly maxArrayLength = DEFAULT_MAX_LENGTH, | ||
readonly maxMapLength = DEFAULT_MAX_LENGTH, | ||
readonly maxExtLength = DEFAULT_MAX_LENGTH, | ||
readonly cachedKeyDecoder: CachedKeyDecoder | null = sharedCachedKeyDecoder, | ||
public constructor( | ||
private readonly extensionCodec: ExtensionCodecType<ContextType> = ExtensionCodec.defaultCodec as any, | ||
private readonly context: ContextType = undefined as any, | ||
private readonly maxStrLength = DEFAULT_MAX_LENGTH, | ||
private readonly maxBinLength = DEFAULT_MAX_LENGTH, | ||
private readonly maxArrayLength = DEFAULT_MAX_LENGTH, | ||
private readonly maxMapLength = DEFAULT_MAX_LENGTH, | ||
private readonly maxExtLength = DEFAULT_MAX_LENGTH, | ||
private readonly keyDecoder: KeyDecoder | null = sharedCachedKeyDecoder, | ||
) {} | ||
setBuffer(buffer: ArrayLike<number> | ArrayBuffer): void { | ||
private reinitializeState() { | ||
this.totalPos = 0; | ||
this.headByte = HEAD_BYTE_REQUIRED; | ||
} | ||
private setBuffer(buffer: ArrayLike<number> | ArrayBuffer): void { | ||
this.bytes = ensureUint8Array(buffer); | ||
@@ -91,3 +96,3 @@ this.view = createDataView(this.bytes); | ||
appendBuffer(buffer: ArrayLike<number>) { | ||
private appendBuffer(buffer: ArrayLike<number>) { | ||
if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining()) { | ||
@@ -106,13 +111,19 @@ this.setBuffer(buffer); | ||
hasRemaining(size = 1) { | ||
private hasRemaining(size = 1) { | ||
return this.view.byteLength - this.pos >= size; | ||
} | ||
createNoExtraBytesError(posToShow: number): Error { | ||
private createNoExtraBytesError(posToShow: number): Error { | ||
const { view, pos } = this; | ||
return new RangeError(`Extra ${view.byteLength - pos} byte(s) found at buffer[${posToShow}]`); | ||
return new RangeError(`Extra ${view.byteLength - pos} of ${view.byteLength} byte(s) found at buffer[${posToShow}]`); | ||
} | ||
decodeSingleSync(): unknown { | ||
const object = this.decodeSync(); | ||
public decode(buffer: ArrayLike<number> | ArrayBuffer): unknown { | ||
this.reinitializeState(); | ||
this.setBuffer(buffer); | ||
return this.doDecodeSingleSync(); | ||
} | ||
private doDecodeSingleSync(): unknown { | ||
const object = this.doDecodeSync(); | ||
if (this.hasRemaining()) { | ||
@@ -124,3 +135,3 @@ throw this.createNoExtraBytesError(this.pos); | ||
async decodeSingleAsync(stream: AsyncIterable<ArrayLike<number>>): Promise<unknown> { | ||
public async decodeAsync(stream: AsyncIterable<ArrayLike<number>>): Promise<unknown> { | ||
let decoded = false; | ||
@@ -136,3 +147,3 @@ let object: unknown; | ||
try { | ||
object = this.decodeSync(); | ||
object = this.doDecodeSync(); | ||
decoded = true; | ||
@@ -161,7 +172,7 @@ } catch (e) { | ||
decodeArrayStream(stream: AsyncIterable<ArrayLike<number>>) { | ||
public decodeArrayStream(stream: AsyncIterable<ArrayLike<number>>) { | ||
return this.decodeMultiAsync(stream, true); | ||
} | ||
decodeStream(stream: AsyncIterable<ArrayLike<number>>) { | ||
public decodeStream(stream: AsyncIterable<ArrayLike<number>>) { | ||
return this.decodeMultiAsync(stream, false); | ||
@@ -189,3 +200,3 @@ } | ||
while (true) { | ||
yield this.decodeSync(); | ||
yield this.doDecodeSync(); | ||
if (--arrayItemsLeft === 0) { | ||
@@ -205,3 +216,3 @@ break; | ||
decodeSync(): unknown { | ||
private doDecodeSync(): unknown { | ||
DECODE: while (true) { | ||
@@ -422,3 +433,3 @@ const headByte = this.readHeadByte(); | ||
readHeadByte(): number { | ||
private readHeadByte(): number { | ||
if (this.headByte === HEAD_BYTE_REQUIRED) { | ||
@@ -432,7 +443,7 @@ this.headByte = this.readU8(); | ||
complete(): void { | ||
private complete(): void { | ||
this.headByte = HEAD_BYTE_REQUIRED; | ||
} | ||
readArraySize(): number { | ||
private readArraySize(): number { | ||
const headByte = this.readHeadByte(); | ||
@@ -455,3 +466,3 @@ | ||
pushMapState(size: number) { | ||
private pushMapState(size: number) { | ||
if (size > this.maxMapLength) { | ||
@@ -470,3 +481,3 @@ throw new Error(`Max length exceeded: map length (${size}) > maxMapLengthLength (${this.maxMapLength})`); | ||
pushArrayState(size: number) { | ||
private pushArrayState(size: number) { | ||
if (size > this.maxArrayLength) { | ||
@@ -484,3 +495,3 @@ throw new Error(`Max length exceeded: array length (${size}) > maxArrayLength (${this.maxArrayLength})`); | ||
decodeUtf8String(byteLength: number, headerOffset: number): string { | ||
private decodeUtf8String(byteLength: number, headerOffset: number): string { | ||
if (byteLength > this.maxStrLength) { | ||
@@ -496,4 +507,4 @@ throw new Error(`Max length exceeded: UTF-8 byte length (${byteLength}) > maxStrLength (${this.maxStrLength})`); | ||
let object: string; | ||
if (this.stateIsMapKey() && this.cachedKeyDecoder?.canBeCached(byteLength)) { | ||
object = this.cachedKeyDecoder.decode(this.bytes, offset, byteLength); | ||
if (this.stateIsMapKey() && this.keyDecoder?.canBeCached(byteLength)) { | ||
object = this.keyDecoder.decode(this.bytes, offset, byteLength); | ||
} else if (TEXT_ENCODING_AVAILABLE && byteLength > TEXT_DECODER_THRESHOLD) { | ||
@@ -508,3 +519,3 @@ object = utf8DecodeTD(this.bytes, offset, byteLength); | ||
stateIsMapKey(): boolean { | ||
private stateIsMapKey(): boolean { | ||
if (this.stack.length > 0) { | ||
@@ -517,3 +528,3 @@ const state = this.stack[this.stack.length - 1]; | ||
decodeBinary(byteLength: number, headOffset: number): Uint8Array { | ||
private decodeBinary(byteLength: number, headOffset: number): Uint8Array { | ||
if (byteLength > this.maxBinLength) { | ||
@@ -533,3 +544,3 @@ throw new Error(`Max length exceeded: bin length (${byteLength}) > maxBinLength (${this.maxBinLength})`); | ||
decodeExtension(size: number, headOffset: number): unknown { | ||
private decodeExtension(size: number, headOffset: number): unknown { | ||
if (size > this.maxExtLength) { | ||
@@ -544,15 +555,15 @@ throw new Error(`Max length exceeded: ext length (${size}) > maxExtLength (${this.maxExtLength})`); | ||
lookU8() { | ||
private lookU8() { | ||
return this.view.getUint8(this.pos); | ||
} | ||
lookU16() { | ||
private lookU16() { | ||
return this.view.getUint16(this.pos); | ||
} | ||
lookU32() { | ||
private lookU32() { | ||
return this.view.getUint32(this.pos); | ||
} | ||
readU8(): number { | ||
private readU8(): number { | ||
const value = this.view.getUint8(this.pos); | ||
@@ -563,3 +574,3 @@ this.pos++; | ||
readI8(): number { | ||
private readI8(): number { | ||
const value = this.view.getInt8(this.pos); | ||
@@ -570,3 +581,3 @@ this.pos++; | ||
readU16(): number { | ||
private readU16(): number { | ||
const value = this.view.getUint16(this.pos); | ||
@@ -577,3 +588,3 @@ this.pos += 2; | ||
readI16(): number { | ||
private readI16(): number { | ||
const value = this.view.getInt16(this.pos); | ||
@@ -584,3 +595,3 @@ this.pos += 2; | ||
readU32(): number { | ||
private readU32(): number { | ||
const value = this.view.getUint32(this.pos); | ||
@@ -591,3 +602,3 @@ this.pos += 4; | ||
readI32(): number { | ||
private readI32(): number { | ||
const value = this.view.getInt32(this.pos); | ||
@@ -598,3 +609,3 @@ this.pos += 4; | ||
readU64(): number { | ||
private readU64(): number { | ||
const value = getUint64(this.view, this.pos); | ||
@@ -605,3 +616,3 @@ this.pos += 8; | ||
readI64(): number { | ||
private readI64(): number { | ||
const value = getInt64(this.view, this.pos); | ||
@@ -612,3 +623,3 @@ this.pos += 8; | ||
readF32() { | ||
private readF32() { | ||
const value = this.view.getFloat32(this.pos); | ||
@@ -619,3 +630,3 @@ this.pos += 4; | ||
readF64() { | ||
private readF64() { | ||
const value = this.view.getFloat64(this.pos); | ||
@@ -622,0 +633,0 @@ this.pos += 8; |
@@ -51,4 +51,3 @@ import { ExtensionCodecType } from "./ExtensionCodec"; | ||
); | ||
encoder.encode(value, 1); | ||
return encoder.getUint8Array(); | ||
return encoder.encode(value); | ||
} |
@@ -15,13 +15,27 @@ import { utf8EncodeJs, utf8Count, TEXT_ENCODING_AVAILABLE, TEXT_ENCODER_THRESHOLD, utf8EncodeTE } from "./utils/utf8"; | ||
constructor( | ||
readonly extensionCodec: ExtensionCodecType<ContextType> = ExtensionCodec.defaultCodec as any, | ||
readonly context: ContextType, | ||
readonly maxDepth = DEFAULT_MAX_DEPTH, | ||
readonly initialBufferSize = DEFAULT_INITIAL_BUFFER_SIZE, | ||
readonly sortKeys = false, | ||
readonly forceFloat32 = false, | ||
readonly ignoreUndefined = false, | ||
public constructor( | ||
private readonly extensionCodec: ExtensionCodecType<ContextType> = ExtensionCodec.defaultCodec as any, | ||
private readonly context: ContextType = undefined as any, | ||
private readonly maxDepth = DEFAULT_MAX_DEPTH, | ||
private readonly initialBufferSize = DEFAULT_INITIAL_BUFFER_SIZE, | ||
private readonly sortKeys = false, | ||
private readonly forceFloat32 = false, | ||
private readonly ignoreUndefined = false, | ||
) {} | ||
encode(object: unknown, depth: number): void { | ||
private getUint8Array(): Uint8Array { | ||
return this.bytes.subarray(0, this.pos); | ||
} | ||
private reinitializeState() { | ||
this.pos = 0; | ||
} | ||
public encode(object: unknown): Uint8Array { | ||
this.reinitializeState(); | ||
this.doEncode(object, 1); | ||
return this.getUint8Array(); | ||
} | ||
private doEncode(object: unknown, depth: number): void { | ||
if (depth > this.maxDepth) { | ||
@@ -44,7 +58,3 @@ throw new Error(`Too deep objects in depth ${depth}`); | ||
getUint8Array(): Uint8Array { | ||
return this.bytes.subarray(0, this.pos); | ||
} | ||
ensureBufferSizeToWrite(sizeToWrite: number) { | ||
private ensureBufferSizeToWrite(sizeToWrite: number) { | ||
const requiredSize = this.pos + sizeToWrite; | ||
@@ -57,3 +67,3 @@ | ||
resizeBuffer(newSize: number) { | ||
private resizeBuffer(newSize: number) { | ||
const newBuffer = new ArrayBuffer(newSize); | ||
@@ -69,7 +79,7 @@ const newBytes = new Uint8Array(newBuffer); | ||
encodeNil() { | ||
private encodeNil() { | ||
this.writeU8(0xc0); | ||
} | ||
encodeBoolean(object: boolean) { | ||
private encodeBoolean(object: boolean) { | ||
if (object === false) { | ||
@@ -81,3 +91,3 @@ this.writeU8(0xc2); | ||
} | ||
encodeNumber(object: number) { | ||
private encodeNumber(object: number) { | ||
if (Number.isSafeInteger(object)) { | ||
@@ -141,3 +151,3 @@ if (object >= 0) { | ||
writeStringHeader(byteLength: number) { | ||
private writeStringHeader(byteLength: number) { | ||
if (byteLength < 32) { | ||
@@ -163,3 +173,3 @@ // fixstr | ||
encodeString(object: string) { | ||
private encodeString(object: string) { | ||
const maxHeaderSize = 1 + 4; | ||
@@ -183,3 +193,3 @@ const strLength = object.length; | ||
encodeObject(object: unknown, depth: number) { | ||
private encodeObject(object: unknown, depth: number) { | ||
// try to encode objects with custom codec first of non-primitives | ||
@@ -201,3 +211,3 @@ const ext = this.extensionCodec.tryToEncode(object, this.context); | ||
encodeBinary(object: ArrayBufferView) { | ||
private encodeBinary(object: ArrayBufferView) { | ||
const size = object.byteLength; | ||
@@ -223,3 +233,3 @@ if (size < 0x100) { | ||
encodeArray(object: Array<unknown>, depth: number) { | ||
private encodeArray(object: Array<unknown>, depth: number) { | ||
const size = object.length; | ||
@@ -241,7 +251,7 @@ if (size < 16) { | ||
for (const item of object) { | ||
this.encode(item, depth + 1); | ||
this.doEncode(item, depth + 1); | ||
} | ||
} | ||
countWithoutUndefined(object: Record<string, unknown>, keys: ReadonlyArray<string>): number { | ||
private countWithoutUndefined(object: Record<string, unknown>, keys: ReadonlyArray<string>): number { | ||
let count = 0; | ||
@@ -258,3 +268,3 @@ | ||
encodeMap(object: Record<string, unknown>, depth: number) { | ||
private encodeMap(object: Record<string, unknown>, depth: number) { | ||
const keys = Object.keys(object); | ||
@@ -287,3 +297,3 @@ if (this.sortKeys) { | ||
this.encodeString(key); | ||
this.encode(value, depth + 1); | ||
this.doEncode(value, depth + 1); | ||
} | ||
@@ -293,3 +303,3 @@ } | ||
encodeExtension(ext: ExtData) { | ||
private encodeExtension(ext: ExtData) { | ||
const size = ext.data.length; | ||
@@ -330,3 +340,3 @@ if (size === 1) { | ||
writeU8(value: number) { | ||
private writeU8(value: number) { | ||
this.ensureBufferSizeToWrite(1); | ||
@@ -338,3 +348,3 @@ | ||
writeU8a(values: ArrayLike<number>) { | ||
private writeU8a(values: ArrayLike<number>) { | ||
const size = values.length; | ||
@@ -347,3 +357,3 @@ this.ensureBufferSizeToWrite(size); | ||
writeI8(value: number) { | ||
private writeI8(value: number) { | ||
this.ensureBufferSizeToWrite(1); | ||
@@ -355,3 +365,3 @@ | ||
writeU16(value: number) { | ||
private writeU16(value: number) { | ||
this.ensureBufferSizeToWrite(2); | ||
@@ -363,3 +373,3 @@ | ||
writeI16(value: number) { | ||
private writeI16(value: number) { | ||
this.ensureBufferSizeToWrite(2); | ||
@@ -371,3 +381,3 @@ | ||
writeU32(value: number) { | ||
private writeU32(value: number) { | ||
this.ensureBufferSizeToWrite(4); | ||
@@ -379,3 +389,3 @@ | ||
writeI32(value: number) { | ||
private writeI32(value: number) { | ||
this.ensureBufferSizeToWrite(4); | ||
@@ -387,3 +397,3 @@ | ||
writeF32(value: number) { | ||
private writeF32(value: number) { | ||
this.ensureBufferSizeToWrite(4); | ||
@@ -394,3 +404,3 @@ this.view.setFloat32(this.pos, value); | ||
writeF64(value: number) { | ||
private writeF64(value: number) { | ||
this.ensureBufferSizeToWrite(8); | ||
@@ -401,3 +411,3 @@ this.view.setFloat64(this.pos, value); | ||
writeU64(value: number) { | ||
private writeU64(value: number) { | ||
this.ensureBufferSizeToWrite(8); | ||
@@ -409,3 +419,3 @@ | ||
writeI64(value: number) { | ||
private writeI64(value: number) { | ||
this.ensureBufferSizeToWrite(8); | ||
@@ -412,0 +422,0 @@ |
@@ -16,2 +16,3 @@ // ExtensionCodec to handle MessagePack extensions | ||
export type ExtensionCodecType<ContextType> = { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
__brand?: ContextType; | ||
@@ -27,2 +28,3 @@ tryToEncode(object: unknown, context: ContextType): ExtData | null; | ||
// this will make type errors a lot more clear | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
__brand?: ContextType; | ||
@@ -29,0 +31,0 @@ |
@@ -9,3 +9,3 @@ // utility for whatwg streams | ||
export function isAsyncIterable<T>(object: object): object is AsyncIterable<T> { | ||
export function isAsyncIterable<T>(object: ReadableStreamLike<T>): object is AsyncIterable<T> { | ||
return (object as any)[Symbol.asyncIterator] != null; | ||
@@ -12,0 +12,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is 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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
493770
5430
591