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

@jprochazk/cbor

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jprochazk/cbor - npm Package Compare versions

Comparing version 0.4.7 to 0.4.8

coverage/clover.xml

1

dist/common/view.d.ts
export declare class OutOfBoundsError extends Error {
private what;
constructor(offset: number, length: number);
toString(): string;
}

@@ -6,0 +5,0 @@ export declare class View {

export declare enum ErrorCode {
UNEXPECTED_EOF = 0,
REACHED_MAX_NESTING_DEPTH = 1,
EMPTY_STACK = 2,
UNEXPECTED_OBJECT_END = 3,
UNEXPECTED_ARRAY_END = 4,
UNSUPPORTED_BYTE_STRING = 5,
WRONG_STRING_FORMAT = 6,
UNSUPPORTED_HALF = 7,
UNEXPECTED_TOKEN = 8,
UNEXPECTED_VALUE = 9,
UNSUPPORTED_64_BIT = 10
REACHED_MAX_NESTING_DEPTH = 0,
EMPTY_STACK = 1,
UNEXPECTED_OBJECT_END = 2,
UNEXPECTED_ARRAY_END = 3,
UNSUPPORTED_BYTE_STRING = 4,
UNSUPPORTED_HALF = 5,
UNEXPECTED_VALUE = 6,
UNSUPPORTED_64_BIT = 7
}
export declare class ParseError extends Error {
private what;
private constructor();
toString(): string;
static build(code: ErrorCode, info?: {

@@ -19,0 +14,0 @@ [index: string]: any;

@@ -1,1 +0,1 @@

"use strict";var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};function e(e,i){function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}var i,s=function(t){function i(e,i){var s=t.call(this,"View offset out of bounds: "+e+" > "+i)||this;return s.what="View offset out of bounds: "+e+" > "+i,s}return e(i,t),i.prototype.toString=function(){return"OutOfBoundsError: "+this.what},i}(Error),r=function(){function t(t,e){void 0===e&&(e=0),this.buffer=t,this.offset=e,this.view=new DataView(this.buffer,0,this.buffer.byteLength),this.arrayView=new Uint8Array(this.buffer)}return t.prototype.slice=function(t,e){return this.buffer.slice(t,e)},t.prototype.getFloat32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat32(this.offset-4,!1)},t.prototype.getFloat64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat64(this.offset-8,!1)},t.prototype.getInt8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt8(this.offset-1)},t.prototype.getInt16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt16(this.offset-2,!1)},t.prototype.getInt32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt32(this.offset-4,!1)},t.prototype.getInt64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigInt64(this.offset-8,!1)},t.prototype.getUint8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint8(this.offset-1)},t.prototype.getUint16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint16(this.offset-2,!1)},t.prototype.getUint32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint32(this.offset-4,!1)},t.prototype.getUint64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigUint64(this.offset-8,!1)},t.prototype.getBytes=function(t){if(this.offset+=t,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return new Uint8Array(this.buffer.slice(this.offset-t,this.offset))},t.prototype.setFloat32=function(t){this.offset+=4,this.resize(this.offset),this.view.setFloat32(this.offset-4,t,!1)},t.prototype.setFloat64=function(t){this.offset+=8,this.resize(this.offset),this.view.setFloat64(this.offset-8,t,!1)},t.prototype.setInt8=function(t){this.offset+=1,this.resize(this.offset),this.view.setInt8(this.offset-1,t)},t.prototype.setInt16=function(t){this.offset+=2,this.resize(this.offset),this.view.setInt16(this.offset-2,t,!1)},t.prototype.setInt32=function(t){this.offset+=4,this.resize(this.offset),this.view.setInt32(this.offset-4,t,!1)},t.prototype.setInt64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigInt64(this.offset-8,t,!1)},t.prototype.setUint8=function(t){this.offset+=1,this.resize(this.offset),this.view.setUint8(this.offset-1,t)},t.prototype.setUint16=function(t){this.offset+=2,this.resize(this.offset),this.view.setUint16(this.offset-2,t,!1)},t.prototype.setUint32=function(t){this.offset+=4,this.resize(this.offset),this.view.setUint32(this.offset-4,t,!1)},t.prototype.setUint64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigUint64(this.offset-8,t,!1)},t.prototype.setBytes=function(t){this.offset+=t.byteLength,this.resize(this.offset),this.arrayView.set(t,this.offset-t.byteLength)},t.prototype.resize=function(t){if(!(this.buffer.byteLength>t)){var e=this.buffer;this.buffer=new ArrayBuffer(2*t),this.arrayView=new Uint8Array(this.buffer),this.arrayView.set(new Uint8Array(e)),this.view=new DataView(this.buffer)}},t}();!function(t){t[t.UNEXPECTED_EOF=0]="UNEXPECTED_EOF",t[t.REACHED_MAX_NESTING_DEPTH=1]="REACHED_MAX_NESTING_DEPTH",t[t.EMPTY_STACK=2]="EMPTY_STACK",t[t.UNEXPECTED_OBJECT_END=3]="UNEXPECTED_OBJECT_END",t[t.UNEXPECTED_ARRAY_END=4]="UNEXPECTED_ARRAY_END",t[t.UNSUPPORTED_BYTE_STRING=5]="UNSUPPORTED_BYTE_STRING",t[t.WRONG_STRING_FORMAT=6]="WRONG_STRING_FORMAT",t[t.UNSUPPORTED_HALF=7]="UNSUPPORTED_HALF",t[t.UNEXPECTED_TOKEN=8]="UNEXPECTED_TOKEN",t[t.UNEXPECTED_VALUE=9]="UNEXPECTED_VALUE",t[t.UNSUPPORTED_64_BIT=10]="UNSUPPORTED_64_BIT"}(i||(i={}));var n,h=function(t){function s(e){var i=t.call(this,e)||this;return i.what=e,i}return e(s,t),s.prototype.toString=function(){return"ParseError: "+this.what},s.build=function(t,e){switch(t){case i.UNEXPECTED_EOF:return new s("Unexpected EOF at offset "+(e?"":e.offset));case i.REACHED_MAX_NESTING_DEPTH:return new s("Max recursion depth reached: "+(e?"":e.depth));case i.EMPTY_STACK:return new s("Unexpected value before the start of an object or array");case i.UNEXPECTED_OBJECT_END:return new s("Unexpected end of object before the start of an object");case i.UNEXPECTED_ARRAY_END:return new s("Unexpected end of array before the start of an array");case i.UNSUPPORTED_BYTE_STRING:return new s("byte strings are unsupported");case i.WRONG_STRING_FORMAT:return new s("Expected string length value range 0x60 to 0x7F, found: "+e.token);case i.UNSUPPORTED_HALF:return new s("Half (IEEE754 binary16) is unsupported");case i.UNEXPECTED_TOKEN:return new s("Unexpected token: "+e.token);case i.UNEXPECTED_VALUE:return new s("Found value before key in object");case i.UNSUPPORTED_64_BIT:return new s("64-bit values are unsupported");default:return new s("Unknown error code")}},s}(Error),o=function(){function t(t,e){this.type=t,this.value=e}return t.prototype.isArray=function(){return"array"===this.type},t.prototype.isObject=function(){return!this.isArray()},t.prototype.array=function(){return this.value},t.prototype.object=function(){return this.value},t}(),a=function(){function t(){this.stack=[]}return Object.defineProperty(t.prototype,"length",{get:function(){return this.stack.length},enumerable:!1,configurable:!0}),t.prototype.push=function(t,e){this.stack.push(new o(t,e))},t.prototype.pop=function(){return this.stack.pop()},t.prototype.last=function(){return this.stack[this.stack.length-1]},t.prototype.empty=function(){return 0===this.stack.length},t}(),u=function(){function t(t){this.max_depth=t,this.root=null,this.stack=new a,this.last_key=null}return t.prototype.null=function(){return this.handle(null)},t.prototype.undefined=function(){return this.handle(void 0)},t.prototype.boolean=function(t){return this.handle(t)},t.prototype.number=function(t){return this.handle(t)},t.prototype.string=function(t){return this.handle(t)},t.prototype.begin_object=function(){if(this.stack.push("object",this.handle({})),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.key=function(t){var e=this.stack.last();if(!e)throw h.build(i.EMPTY_STACK);e.object()[t]=null,this.last_key=t},t.prototype.end_object=function(){if(this.stack.empty()||!this.stack.last().isObject())throw h.build(i.UNEXPECTED_OBJECT_END);return this.stack.pop().object()},t.prototype.begin_array=function(){if(this.stack.push("array",this.handle([])),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.end_array=function(){if(this.stack.empty()||!this.stack.last().isArray())throw h.build(i.UNEXPECTED_ARRAY_END);return this.stack.pop().array()},t.prototype.handle=function(t){if(0===this.stack.length&&null===this.root)return this.root=t,t;var e=this.stack.last();if(e.isArray())return e.array().push(t),t;if(e.isObject()){if(!this.last_key)throw h.build(i.UNEXPECTED_VALUE);return e.object()[this.last_key]=t,t}},t}(),f=new TextDecoder,c=function(){function t(t,e){void 0===e&&(e=100),this.view=t,this.sax=new u(e),this.textDecoder=f}return t.prototype.parse=function(){switch(this.get(),!0){case this.current_value<0:throw h.build(i.UNEXPECTED_EOF,{offset:this.view.offset});case this.current_value<=23:return this.sax.number(this.current_value);case 24===this.current_value:return this.sax.number(this.view.getUint8());case 25===this.current_value:return this.sax.number(this.view.getUint16());case 26===this.current_value:return this.sax.number(this.view.getUint32());case 27===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=55:return this.sax.number(-(1+(31&this.current_value)));case 56===this.current_value:return this.sax.number(-(1+this.view.getUint8()));case 57===this.current_value:return this.sax.number(-(1+this.view.getUint16()));case 58===this.current_value:return this.sax.number(-(1+this.view.getUint32()));case 59===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=95:throw h.build(i.UNSUPPORTED_BYTE_STRING);case this.current_value<=127:return this.sax.string(this.get_string());case this.current_value<=159:return this.get_array();case this.current_value<=191:return this.get_object();case 244===this.current_value:return this.sax.boolean(!1);case 245===this.current_value:return this.sax.boolean(!0);case 246===this.current_value:return this.sax.null();case 247===this.current_value:return this.sax.undefined();case 249===this.current_value:throw h.build(i.UNSUPPORTED_HALF);case 250===this.current_value:return this.sax.number(this.view.getFloat32());case 251===this.current_value:return this.sax.number(this.view.getFloat64())}},t.prototype.get=function(){return this.current_value=this.view.getUint8(),this.current_value},t.prototype.get_string=function(){var t=-1;switch(!0){case this.current_value<=119:t=31&this.current_value;break;case 120===this.current_value:t=this.view.getUint8();break;case 121===this.current_value:t=this.view.getUint16();break;case 122===this.current_value:t=this.view.getUint32();break;case 123===this.current_value:t=this.view.getUint64();break;case 127===this.current_value:break;default:throw h.build(i.WRONG_STRING_FORMAT,{token:"0x"+this.current_value.toString(16).toUpperCase()})}var e=[];if(t>-1)if("bigint"==typeof t){for(var s=[],r=0;r<t;r++)s.push(this.get());e.push(this.textDecoder.decode(new Uint8Array(s)))}else{(s=this.view.getBytes(t)).length>0&&e.push(this.textDecoder.decode(s))}else{for(var n=[];255!==this.get();)n.push(this.get_string());e.push.apply(e,n)}return e.join("")},t.prototype.get_array=function(){this.sax.begin_array();var t=-1;switch(!0){case this.current_value<=151:t=31&this.current_value;break;case 152===this.current_value:t=this.view.getUint8();break;case 153===this.current_value:t=this.view.getUint16();break;case 154===this.current_value:t=this.view.getUint32();break;case 155===this.current_value:t=this.view.getUint64();break;case 159===this.current_value:break;default:throw h.build(i.UNEXPECTED_TOKEN,{token:"0x"+this.current_value.toString(16).toUpperCase()})}if(t>-1)for(var e=0;e<t;e++)this.parse();else for(;255!==this.current_value;)this.parse();return this.sax.end_array()},t.prototype.get_object=function(){this.sax.begin_object();var t=-1;switch(!0){case this.current_value<=183:t=31&this.current_value;break;case 184===this.current_value:t=this.view.getUint8();break;case 185===this.current_value:t=this.view.getUint16();break;case 186===this.current_value:t=this.view.getUint32();break;case 187===this.current_value:t=this.view.getUint64()}if(t>-1)for(var e=0;e<t;e++)this.get(),this.sax.key(this.get_string()),this.parse();else for(;255!==this.get();)this.sax.key(this.get_string()),this.parse();return this.sax.end_object()},t}();!function(t){t[t.UNEXPECTED_TOKEN=0]="UNEXPECTED_TOKEN",t[t.UNSUPPORTED_BIGINT=1]="UNSUPPORTED_BIGINT",t[t.STRING_TOO_LARGE=2]="STRING_TOO_LARGE",t[t.ARRAY_TOO_LARGE=3]="ARRAY_TOO_LARGE",t[t.OBJECT_TOO_LARGE=4]="OBJECT_TOO_LARGE",t[t.NUMBER_TOO_LARGE=5]="NUMBER_TOO_LARGE"}(n||(n={}));var w=function(t){function i(e){var i=t.call(this,e)||this;return i.what=e,i}return e(i,t),i.prototype.toString=function(){return"ParseError: "+this.what},i.build=function(t,e){switch(t){case n.UNEXPECTED_TOKEN:return new i("Unexpected token: "+e.token.toString());case n.UNSUPPORTED_BIGINT:return new i("BigInt is unsupported");case n.STRING_TOO_LARGE:return new i("Max String length is 4294967295, found: "+e.size);case n.ARRAY_TOO_LARGE:return new i("Max Array length is 4294967295, found: "+e.size);case n.OBJECT_TOO_LARGE:return new i("Max Object length is 4294967295, found: "+e.size);case n.NUMBER_TOO_LARGE:return new i("Max Number is "+Number.MAX_SAFE_INTEGER+", found: "+e.number);default:return new i("Unknown error code")}},i}(Error),_=new TextEncoder,l=function(){function t(t){this.view=new r(t),this.textEncoder=_}return t.prototype.finalize=function(){return this.view.slice(0,this.view.offset)},t.prototype.write=function(t){switch(this.getType(t)){case 0:this.view.setUint8(247);break;case 1:this.view.setUint8(246);break;case 2:this.view.setUint8(t?245:244);break;case 3:if(Number.isSafeInteger(t))if(t>=0)if(t<=23)this.view.setUint8(t);else if(t<=255)this.view.setUint8(24),this.view.setUint8(t);else if(t<=65535)this.view.setUint8(25),this.view.setUint16(t);else{if(!(t<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(26),this.view.setUint32(t)}else{var e=-1-t;if(t>=-24)this.view.setUint8(32+e);else if(e<=255)this.view.setUint8(56),this.view.setUint8(e);else if(e<=65535)this.view.setUint8(57),this.view.setUint16(e);else{if(!(e<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(58),this.view.setUint32(e)}}else isNaN(t)||!isFinite(t)||-8388607<=t&&t<=8388607?(this.view.setUint8(250),this.view.setFloat32(t)):(this.view.setUint8(251),this.view.setFloat64(t));break;case 4:var i=this.textEncoder.encode(t);if((o=i.length)<=23)this.view.setUint8(96+o);else if(o<=255)this.view.setUint8(120),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(121),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.STRING_TOO_LARGE,{size:o});this.view.setUint8(122),this.view.setUint32(o)}o>0&&this.view.setBytes(i);break;case 5:if((o=t.length)<=23)this.view.setUint8(128+o);else if(o<=255)this.view.setUint8(152),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(153),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.ARRAY_TOO_LARGE,{size:o});this.view.setUint8(154),this.view.setUint32(o)}for(var s=0,r=t;s<r.length;s++){var h=r[s];this.write(h)}break;case 6:var o;if((o=Object.keys(t).length)<=23)this.view.setUint8(160+o);else if(o<=255)this.view.setUint8(184),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(185),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.OBJECT_TOO_LARGE,{size:o});this.view.setUint8(186),this.view.setUint32(o)}for(var a=0,u=Object.entries(t);a<u.length;a++){var f=u[a],c=f[0],_=f[1];this.write(c),this.write(_)}}},t.prototype.getType=function(t){switch(!0){case void 0===t:return 0;case null===t:return 1;case"boolean"==typeof t:return 2;case"number"==typeof t:return 3;case"bigint"==typeof t:throw w.build(n.UNSUPPORTED_BIGINT);case"string"==typeof t:return 4;case Array.isArray(t):return 5;case"object"==typeof t:return 6;default:throw w.build(n.UNEXPECTED_TOKEN,{token:t})}},t}();function p(t,e,i){var s=i||new ArrayBuffer(1024),r=new l(s);if(e)r.write(t);else try{r.write(t)}catch(t){return null}return r.finalize()}var E=function(){function t(){}return t.decode=function(t,e){return void 0===e&&(e=!1),function(t,e){if(void 0===e&&(e=!1),e)return new c(new r(t)).parse();try{return new c(new r(t)).parse()}catch(t){return null}}(t,e)},t.encode=function(t,e){return void 0===e&&(e=!1),p(t,e)},t.encodeInto=function(t,e,i){return void 0===i&&(i=!1),p(e,i,t)},t}();module.exports=E;
"use strict";var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};function e(e,i){function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}var i,s=function(t){function i(e,i){var s=t.call(this,"View offset out of bounds: "+e+" > "+i)||this;return s.what="View offset out of bounds: "+e+" > "+i,s}return e(i,t),i}(Error),r=function(){function t(t,e){void 0===e&&(e=0),this.buffer=t,this.offset=e,this.view=new DataView(this.buffer,0,this.buffer.byteLength),this.arrayView=new Uint8Array(this.buffer)}return t.prototype.slice=function(t,e){return this.buffer.slice(t,e)},t.prototype.getFloat32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat32(this.offset-4,!1)},t.prototype.getFloat64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat64(this.offset-8,!1)},t.prototype.getInt8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt8(this.offset-1)},t.prototype.getInt16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt16(this.offset-2,!1)},t.prototype.getInt32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt32(this.offset-4,!1)},t.prototype.getInt64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigInt64(this.offset-8,!1)},t.prototype.getUint8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint8(this.offset-1)},t.prototype.getUint16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint16(this.offset-2,!1)},t.prototype.getUint32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint32(this.offset-4,!1)},t.prototype.getUint64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigUint64(this.offset-8,!1)},t.prototype.getBytes=function(t){if(this.offset+=t,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return new Uint8Array(this.buffer.slice(this.offset-t,this.offset))},t.prototype.setFloat32=function(t){this.offset+=4,this.resize(this.offset),this.view.setFloat32(this.offset-4,t,!1)},t.prototype.setFloat64=function(t){this.offset+=8,this.resize(this.offset),this.view.setFloat64(this.offset-8,t,!1)},t.prototype.setInt8=function(t){this.offset+=1,this.resize(this.offset),this.view.setInt8(this.offset-1,t)},t.prototype.setInt16=function(t){this.offset+=2,this.resize(this.offset),this.view.setInt16(this.offset-2,t,!1)},t.prototype.setInt32=function(t){this.offset+=4,this.resize(this.offset),this.view.setInt32(this.offset-4,t,!1)},t.prototype.setInt64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigInt64(this.offset-8,t,!1)},t.prototype.setUint8=function(t){this.offset+=1,this.resize(this.offset),this.view.setUint8(this.offset-1,t)},t.prototype.setUint16=function(t){this.offset+=2,this.resize(this.offset),this.view.setUint16(this.offset-2,t,!1)},t.prototype.setUint32=function(t){this.offset+=4,this.resize(this.offset),this.view.setUint32(this.offset-4,t,!1)},t.prototype.setUint64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigUint64(this.offset-8,t,!1)},t.prototype.setBytes=function(t){this.offset+=t.byteLength,this.resize(this.offset),this.arrayView.set(t,this.offset-t.byteLength)},t.prototype.resize=function(t){if(!(this.buffer.byteLength>t)){var e=this.buffer;this.buffer=new ArrayBuffer(2*t),this.arrayView=new Uint8Array(this.buffer),this.arrayView.set(new Uint8Array(e)),this.view=new DataView(this.buffer)}},t}();!function(t){t[t.REACHED_MAX_NESTING_DEPTH=0]="REACHED_MAX_NESTING_DEPTH",t[t.EMPTY_STACK=1]="EMPTY_STACK",t[t.UNEXPECTED_OBJECT_END=2]="UNEXPECTED_OBJECT_END",t[t.UNEXPECTED_ARRAY_END=3]="UNEXPECTED_ARRAY_END",t[t.UNSUPPORTED_BYTE_STRING=4]="UNSUPPORTED_BYTE_STRING",t[t.UNSUPPORTED_HALF=5]="UNSUPPORTED_HALF",t[t.UNEXPECTED_VALUE=6]="UNEXPECTED_VALUE",t[t.UNSUPPORTED_64_BIT=7]="UNSUPPORTED_64_BIT"}(i||(i={}));var n,h=function(t){function s(e){return t.call(this,e)||this}return e(s,t),s.build=function(t,e){switch(t){case i.REACHED_MAX_NESTING_DEPTH:return new s("Max recursion depth reached: "+(e?"":e.depth));case i.EMPTY_STACK:return new s("Unexpected key/value before the start of an object or array");case i.UNEXPECTED_OBJECT_END:return new s("Unexpected end of object before the start of an object");case i.UNEXPECTED_ARRAY_END:return new s("Unexpected end of array before the start of an array");case i.UNSUPPORTED_BYTE_STRING:return new s("byte strings are unsupported");case i.UNSUPPORTED_HALF:return new s("Half (IEEE754 binary16) is unsupported");case i.UNEXPECTED_VALUE:return new s("Found value before key in object");case i.UNSUPPORTED_64_BIT:return new s("64-bit values are unsupported");default:return new s("Unknown error code")}},s}(Error),o=function(){function t(t,e){this.type=t,this.value=e}return t.prototype.isArray=function(){return"array"===this.type},t.prototype.isObject=function(){return!this.isArray()},t.prototype.array=function(){return this.value},t.prototype.object=function(){return this.value},t}(),a=function(){function t(){this.stack=[]}return Object.defineProperty(t.prototype,"length",{get:function(){return this.stack.length},enumerable:!1,configurable:!0}),t.prototype.push=function(t,e){this.stack.push(new o(t,e))},t.prototype.pop=function(){return this.stack.pop()},t.prototype.last=function(){return this.stack[this.stack.length-1]},t.prototype.empty=function(){return 0===this.stack.length},t}(),u=function(){function t(t){this.max_depth=t,this.root=null,this.stack=new a,this.last_key=null}return t.prototype.null=function(){return this.handle(null)},t.prototype.undefined=function(){return this.handle(void 0)},t.prototype.boolean=function(t){return this.handle(t)},t.prototype.number=function(t){return this.handle(t)},t.prototype.string=function(t){return this.handle(t)},t.prototype.begin_object=function(){if(this.stack.push("object",this.handle({})),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.key=function(t){var e=this.stack.last();if(!e)throw h.build(i.EMPTY_STACK);e.object()[t]=null,this.last_key=t},t.prototype.end_object=function(){if(this.stack.empty()||!this.stack.last().isObject())throw h.build(i.UNEXPECTED_OBJECT_END);return this.stack.pop().object()},t.prototype.begin_array=function(){if(this.stack.push("array",this.handle([])),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.end_array=function(){if(this.stack.empty()||!this.stack.last().isArray())throw h.build(i.UNEXPECTED_ARRAY_END);return this.stack.pop().array()},t.prototype.handle=function(t){if(0===this.stack.length&&null===this.root)return this.root=t,t;var e=this.stack.last();if(e.isArray())return e.array().push(t),t;if(e.isObject()){if(!this.last_key)throw h.build(i.UNEXPECTED_VALUE);return e.object()[this.last_key]=t,t}},t}(),f=new TextDecoder,c=function(){function t(t,e){void 0===e&&(e=100),this.view=t,this.sax=new u(e),this.textDecoder=f}return t.prototype.parse=function(){switch(this.get(),!0){case this.current_value<=23:return this.sax.number(this.current_value);case 24===this.current_value:return this.sax.number(this.view.getUint8());case 25===this.current_value:return this.sax.number(this.view.getUint16());case 26===this.current_value:return this.sax.number(this.view.getUint32());case 27===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=55:return this.sax.number(-(1+(31&this.current_value)));case 56===this.current_value:return this.sax.number(-(1+this.view.getUint8()));case 57===this.current_value:return this.sax.number(-(1+this.view.getUint16()));case 58===this.current_value:return this.sax.number(-(1+this.view.getUint32()));case 59===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=95:throw h.build(i.UNSUPPORTED_BYTE_STRING);case this.current_value<=127:return this.sax.string(this.get_string());case this.current_value<=159:return this.get_array();case this.current_value<=191:return this.get_object();case 244===this.current_value:return this.sax.boolean(!1);case 245===this.current_value:return this.sax.boolean(!0);case 246===this.current_value:return this.sax.null();case 247===this.current_value:return this.sax.undefined();case 249===this.current_value:throw h.build(i.UNSUPPORTED_HALF);case 250===this.current_value:return this.sax.number(this.view.getFloat32());case 251===this.current_value:return this.sax.number(this.view.getFloat64())}},t.prototype.get=function(){return this.current_value=this.view.getUint8(),this.current_value},t.prototype.get_string=function(){var t=-1;switch(!0){case this.current_value<=119:t=31&this.current_value;break;case 120===this.current_value:t=this.view.getUint8();break;case 121===this.current_value:t=this.view.getUint16();break;case 122===this.current_value:t=this.view.getUint32();break;case 123===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case 127===this.current_value:}var e=[];if(t>-1){var s=this.view.getBytes(t);s.length>0&&e.push(this.textDecoder.decode(s))}else{for(var r=[];255!==this.get();)r.push(this.get_string());e.push.apply(e,r)}return e.join("")},t.prototype.get_array=function(){this.sax.begin_array();var t=-1;switch(!0){case this.current_value<=151:t=31&this.current_value;break;case 152===this.current_value:t=this.view.getUint8();break;case 153===this.current_value:t=this.view.getUint16();break;case 154===this.current_value:t=this.view.getUint32();break;case 155===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case 159===this.current_value:}if(t>-1)for(var e=0;e<t;e++)this.parse();else for(;255!==this.current_value;)this.parse();return this.sax.end_array()},t.prototype.get_object=function(){this.sax.begin_object();var t=-1;switch(!0){case this.current_value<=183:t=31&this.current_value;break;case 184===this.current_value:t=this.view.getUint8();break;case 185===this.current_value:t=this.view.getUint16();break;case 186===this.current_value:t=this.view.getUint32();break;case 187===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT)}if(t>-1)for(var e=0;e<t;e++)this.get(),this.sax.key(this.get_string()),this.parse();else for(;255!==this.get();)this.sax.key(this.get_string()),this.parse();return this.sax.end_object()},t}();!function(t){t[t.UNEXPECTED_TOKEN=0]="UNEXPECTED_TOKEN",t[t.UNSUPPORTED_BIGINT=1]="UNSUPPORTED_BIGINT",t[t.STRING_TOO_LARGE=2]="STRING_TOO_LARGE",t[t.ARRAY_TOO_LARGE=3]="ARRAY_TOO_LARGE",t[t.OBJECT_TOO_LARGE=4]="OBJECT_TOO_LARGE",t[t.NUMBER_TOO_LARGE=5]="NUMBER_TOO_LARGE"}(n||(n={}));var w=function(t){function i(e){var i=t.call(this,e)||this;return i.what=e,i}return e(i,t),i.prototype.toString=function(){return"ParseError: "+this.what},i.build=function(t,e){switch(void 0===e&&(e={}),t){case n.UNEXPECTED_TOKEN:return new i("Unexpected token: "+e.token);case n.UNSUPPORTED_BIGINT:return new i("BigInt is unsupported");case n.STRING_TOO_LARGE:return new i("Max String length is 4294967295, found: "+e.size);case n.ARRAY_TOO_LARGE:return new i("Max Array length is 4294967295, found: "+e.size);case n.OBJECT_TOO_LARGE:return new i("Max Object length is 4294967295, found: "+e.size);case n.NUMBER_TOO_LARGE:return new i("Max Number is "+Number.MAX_SAFE_INTEGER+", found: "+e.number);default:return new i("Unknown error code")}},i}(Error),_=new TextEncoder,l=function(){function t(t){this.view=new r(t),this.textEncoder=_}return t.prototype.finalize=function(){return this.view.slice(0,this.view.offset)},t.prototype.write=function(t){switch(this.getType(t)){case 0:this.view.setUint8(247);break;case 1:this.view.setUint8(246);break;case 2:this.view.setUint8(t?245:244);break;case 3:if(Number.isSafeInteger(t))if(t>=0)if(t<=23)this.view.setUint8(t);else if(t<=255)this.view.setUint8(24),this.view.setUint8(t);else if(t<=65535)this.view.setUint8(25),this.view.setUint16(t);else{if(!(t<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(26),this.view.setUint32(t)}else{var e=-1-t;if(t>=-24)this.view.setUint8(32+e);else if(e<=255)this.view.setUint8(56),this.view.setUint8(e);else if(e<=65535)this.view.setUint8(57),this.view.setUint16(e);else{if(!(e<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(58),this.view.setUint32(e)}}else isNaN(t)||!isFinite(t)||-8388607<=t&&t<=8388607?(this.view.setUint8(250),this.view.setFloat32(t)):(this.view.setUint8(251),this.view.setFloat64(t));break;case 4:var i=this.textEncoder.encode(t);if((o=i.length)<=23)this.view.setUint8(96+o);else if(o<=255)this.view.setUint8(120),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(121),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.STRING_TOO_LARGE,{size:o});this.view.setUint8(122),this.view.setUint32(o)}o>0&&this.view.setBytes(i);break;case 5:if((o=t.length)<=23)this.view.setUint8(128+o);else if(o<=255)this.view.setUint8(152),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(153),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.ARRAY_TOO_LARGE,{size:o});this.view.setUint8(154),this.view.setUint32(o)}for(var s=0,r=t;s<r.length;s++){var h=r[s];this.write(h)}break;case 6:var o;if((o=Object.keys(t).length)<=23)this.view.setUint8(160+o);else if(o<=255)this.view.setUint8(184),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(185),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.OBJECT_TOO_LARGE,{size:o});this.view.setUint8(186),this.view.setUint32(o)}for(var a=0,u=Object.entries(t);a<u.length;a++){var f=u[a],c=f[0],_=f[1];this.write(c),this.write(_)}}},t.prototype.getType=function(t){switch(!0){case void 0===t:return 0;case null===t:return 1;case"boolean"==typeof t:return 2;case"number"==typeof t:return 3;case"bigint"==typeof t:throw w.build(n.UNSUPPORTED_BIGINT);case"string"==typeof t:return 4;case Array.isArray(t):return 5;case"object"==typeof t:return 6;default:throw w.build(n.UNEXPECTED_TOKEN,{token:t})}},t}();function p(t,e,i){var s=i||new ArrayBuffer(1024),r=new l(s);if(e)r.write(t);else try{r.write(t)}catch(t){return null}return r.finalize()}var v=function(){function t(){}return t.decode=function(t,e){return void 0===e&&(e=!1),function(t,e){if(void 0===e&&(e=!1),e)return new c(new r(t)).parse();try{return new c(new r(t)).parse()}catch(t){return null}}(t,e)},t.encode=function(t,e){return void 0===e&&(e=!1),p(t,e)},t.encodeInto=function(t,e,i){return void 0===i&&(i=!1),p(e,i,t)},t}();module.exports=v;

@@ -1,1 +0,1 @@

var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};function e(e,i){function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}var i,s=function(t){function i(e,i){var s=t.call(this,"View offset out of bounds: "+e+" > "+i)||this;return s.what="View offset out of bounds: "+e+" > "+i,s}return e(i,t),i.prototype.toString=function(){return"OutOfBoundsError: "+this.what},i}(Error),r=function(){function t(t,e){void 0===e&&(e=0),this.buffer=t,this.offset=e,this.view=new DataView(this.buffer,0,this.buffer.byteLength),this.arrayView=new Uint8Array(this.buffer)}return t.prototype.slice=function(t,e){return this.buffer.slice(t,e)},t.prototype.getFloat32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat32(this.offset-4,!1)},t.prototype.getFloat64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat64(this.offset-8,!1)},t.prototype.getInt8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt8(this.offset-1)},t.prototype.getInt16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt16(this.offset-2,!1)},t.prototype.getInt32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt32(this.offset-4,!1)},t.prototype.getInt64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigInt64(this.offset-8,!1)},t.prototype.getUint8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint8(this.offset-1)},t.prototype.getUint16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint16(this.offset-2,!1)},t.prototype.getUint32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint32(this.offset-4,!1)},t.prototype.getUint64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigUint64(this.offset-8,!1)},t.prototype.getBytes=function(t){if(this.offset+=t,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return new Uint8Array(this.buffer.slice(this.offset-t,this.offset))},t.prototype.setFloat32=function(t){this.offset+=4,this.resize(this.offset),this.view.setFloat32(this.offset-4,t,!1)},t.prototype.setFloat64=function(t){this.offset+=8,this.resize(this.offset),this.view.setFloat64(this.offset-8,t,!1)},t.prototype.setInt8=function(t){this.offset+=1,this.resize(this.offset),this.view.setInt8(this.offset-1,t)},t.prototype.setInt16=function(t){this.offset+=2,this.resize(this.offset),this.view.setInt16(this.offset-2,t,!1)},t.prototype.setInt32=function(t){this.offset+=4,this.resize(this.offset),this.view.setInt32(this.offset-4,t,!1)},t.prototype.setInt64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigInt64(this.offset-8,t,!1)},t.prototype.setUint8=function(t){this.offset+=1,this.resize(this.offset),this.view.setUint8(this.offset-1,t)},t.prototype.setUint16=function(t){this.offset+=2,this.resize(this.offset),this.view.setUint16(this.offset-2,t,!1)},t.prototype.setUint32=function(t){this.offset+=4,this.resize(this.offset),this.view.setUint32(this.offset-4,t,!1)},t.prototype.setUint64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigUint64(this.offset-8,t,!1)},t.prototype.setBytes=function(t){this.offset+=t.byteLength,this.resize(this.offset),this.arrayView.set(t,this.offset-t.byteLength)},t.prototype.resize=function(t){if(!(this.buffer.byteLength>t)){var e=this.buffer;this.buffer=new ArrayBuffer(2*t),this.arrayView=new Uint8Array(this.buffer),this.arrayView.set(new Uint8Array(e)),this.view=new DataView(this.buffer)}},t}();!function(t){t[t.UNEXPECTED_EOF=0]="UNEXPECTED_EOF",t[t.REACHED_MAX_NESTING_DEPTH=1]="REACHED_MAX_NESTING_DEPTH",t[t.EMPTY_STACK=2]="EMPTY_STACK",t[t.UNEXPECTED_OBJECT_END=3]="UNEXPECTED_OBJECT_END",t[t.UNEXPECTED_ARRAY_END=4]="UNEXPECTED_ARRAY_END",t[t.UNSUPPORTED_BYTE_STRING=5]="UNSUPPORTED_BYTE_STRING",t[t.WRONG_STRING_FORMAT=6]="WRONG_STRING_FORMAT",t[t.UNSUPPORTED_HALF=7]="UNSUPPORTED_HALF",t[t.UNEXPECTED_TOKEN=8]="UNEXPECTED_TOKEN",t[t.UNEXPECTED_VALUE=9]="UNEXPECTED_VALUE",t[t.UNSUPPORTED_64_BIT=10]="UNSUPPORTED_64_BIT"}(i||(i={}));var n,h=function(t){function s(e){var i=t.call(this,e)||this;return i.what=e,i}return e(s,t),s.prototype.toString=function(){return"ParseError: "+this.what},s.build=function(t,e){switch(t){case i.UNEXPECTED_EOF:return new s("Unexpected EOF at offset "+(e?"":e.offset));case i.REACHED_MAX_NESTING_DEPTH:return new s("Max recursion depth reached: "+(e?"":e.depth));case i.EMPTY_STACK:return new s("Unexpected value before the start of an object or array");case i.UNEXPECTED_OBJECT_END:return new s("Unexpected end of object before the start of an object");case i.UNEXPECTED_ARRAY_END:return new s("Unexpected end of array before the start of an array");case i.UNSUPPORTED_BYTE_STRING:return new s("byte strings are unsupported");case i.WRONG_STRING_FORMAT:return new s("Expected string length value range 0x60 to 0x7F, found: "+e.token);case i.UNSUPPORTED_HALF:return new s("Half (IEEE754 binary16) is unsupported");case i.UNEXPECTED_TOKEN:return new s("Unexpected token: "+e.token);case i.UNEXPECTED_VALUE:return new s("Found value before key in object");case i.UNSUPPORTED_64_BIT:return new s("64-bit values are unsupported");default:return new s("Unknown error code")}},s}(Error),o=function(){function t(t,e){this.type=t,this.value=e}return t.prototype.isArray=function(){return"array"===this.type},t.prototype.isObject=function(){return!this.isArray()},t.prototype.array=function(){return this.value},t.prototype.object=function(){return this.value},t}(),a=function(){function t(){this.stack=[]}return Object.defineProperty(t.prototype,"length",{get:function(){return this.stack.length},enumerable:!1,configurable:!0}),t.prototype.push=function(t,e){this.stack.push(new o(t,e))},t.prototype.pop=function(){return this.stack.pop()},t.prototype.last=function(){return this.stack[this.stack.length-1]},t.prototype.empty=function(){return 0===this.stack.length},t}(),u=function(){function t(t){this.max_depth=t,this.root=null,this.stack=new a,this.last_key=null}return t.prototype.null=function(){return this.handle(null)},t.prototype.undefined=function(){return this.handle(void 0)},t.prototype.boolean=function(t){return this.handle(t)},t.prototype.number=function(t){return this.handle(t)},t.prototype.string=function(t){return this.handle(t)},t.prototype.begin_object=function(){if(this.stack.push("object",this.handle({})),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.key=function(t){var e=this.stack.last();if(!e)throw h.build(i.EMPTY_STACK);e.object()[t]=null,this.last_key=t},t.prototype.end_object=function(){if(this.stack.empty()||!this.stack.last().isObject())throw h.build(i.UNEXPECTED_OBJECT_END);return this.stack.pop().object()},t.prototype.begin_array=function(){if(this.stack.push("array",this.handle([])),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.end_array=function(){if(this.stack.empty()||!this.stack.last().isArray())throw h.build(i.UNEXPECTED_ARRAY_END);return this.stack.pop().array()},t.prototype.handle=function(t){if(0===this.stack.length&&null===this.root)return this.root=t,t;var e=this.stack.last();if(e.isArray())return e.array().push(t),t;if(e.isObject()){if(!this.last_key)throw h.build(i.UNEXPECTED_VALUE);return e.object()[this.last_key]=t,t}},t}(),f=new TextDecoder,c=function(){function t(t,e){void 0===e&&(e=100),this.view=t,this.sax=new u(e),this.textDecoder=f}return t.prototype.parse=function(){switch(this.get(),!0){case this.current_value<0:throw h.build(i.UNEXPECTED_EOF,{offset:this.view.offset});case this.current_value<=23:return this.sax.number(this.current_value);case 24===this.current_value:return this.sax.number(this.view.getUint8());case 25===this.current_value:return this.sax.number(this.view.getUint16());case 26===this.current_value:return this.sax.number(this.view.getUint32());case 27===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=55:return this.sax.number(-(1+(31&this.current_value)));case 56===this.current_value:return this.sax.number(-(1+this.view.getUint8()));case 57===this.current_value:return this.sax.number(-(1+this.view.getUint16()));case 58===this.current_value:return this.sax.number(-(1+this.view.getUint32()));case 59===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=95:throw h.build(i.UNSUPPORTED_BYTE_STRING);case this.current_value<=127:return this.sax.string(this.get_string());case this.current_value<=159:return this.get_array();case this.current_value<=191:return this.get_object();case 244===this.current_value:return this.sax.boolean(!1);case 245===this.current_value:return this.sax.boolean(!0);case 246===this.current_value:return this.sax.null();case 247===this.current_value:return this.sax.undefined();case 249===this.current_value:throw h.build(i.UNSUPPORTED_HALF);case 250===this.current_value:return this.sax.number(this.view.getFloat32());case 251===this.current_value:return this.sax.number(this.view.getFloat64())}},t.prototype.get=function(){return this.current_value=this.view.getUint8(),this.current_value},t.prototype.get_string=function(){var t=-1;switch(!0){case this.current_value<=119:t=31&this.current_value;break;case 120===this.current_value:t=this.view.getUint8();break;case 121===this.current_value:t=this.view.getUint16();break;case 122===this.current_value:t=this.view.getUint32();break;case 123===this.current_value:t=this.view.getUint64();break;case 127===this.current_value:break;default:throw h.build(i.WRONG_STRING_FORMAT,{token:"0x"+this.current_value.toString(16).toUpperCase()})}var e=[];if(t>-1)if("bigint"==typeof t){for(var s=[],r=0;r<t;r++)s.push(this.get());e.push(this.textDecoder.decode(new Uint8Array(s)))}else{(s=this.view.getBytes(t)).length>0&&e.push(this.textDecoder.decode(s))}else{for(var n=[];255!==this.get();)n.push(this.get_string());e.push.apply(e,n)}return e.join("")},t.prototype.get_array=function(){this.sax.begin_array();var t=-1;switch(!0){case this.current_value<=151:t=31&this.current_value;break;case 152===this.current_value:t=this.view.getUint8();break;case 153===this.current_value:t=this.view.getUint16();break;case 154===this.current_value:t=this.view.getUint32();break;case 155===this.current_value:t=this.view.getUint64();break;case 159===this.current_value:break;default:throw h.build(i.UNEXPECTED_TOKEN,{token:"0x"+this.current_value.toString(16).toUpperCase()})}if(t>-1)for(var e=0;e<t;e++)this.parse();else for(;255!==this.current_value;)this.parse();return this.sax.end_array()},t.prototype.get_object=function(){this.sax.begin_object();var t=-1;switch(!0){case this.current_value<=183:t=31&this.current_value;break;case 184===this.current_value:t=this.view.getUint8();break;case 185===this.current_value:t=this.view.getUint16();break;case 186===this.current_value:t=this.view.getUint32();break;case 187===this.current_value:t=this.view.getUint64()}if(t>-1)for(var e=0;e<t;e++)this.get(),this.sax.key(this.get_string()),this.parse();else for(;255!==this.get();)this.sax.key(this.get_string()),this.parse();return this.sax.end_object()},t}();!function(t){t[t.UNEXPECTED_TOKEN=0]="UNEXPECTED_TOKEN",t[t.UNSUPPORTED_BIGINT=1]="UNSUPPORTED_BIGINT",t[t.STRING_TOO_LARGE=2]="STRING_TOO_LARGE",t[t.ARRAY_TOO_LARGE=3]="ARRAY_TOO_LARGE",t[t.OBJECT_TOO_LARGE=4]="OBJECT_TOO_LARGE",t[t.NUMBER_TOO_LARGE=5]="NUMBER_TOO_LARGE"}(n||(n={}));var w=function(t){function i(e){var i=t.call(this,e)||this;return i.what=e,i}return e(i,t),i.prototype.toString=function(){return"ParseError: "+this.what},i.build=function(t,e){switch(t){case n.UNEXPECTED_TOKEN:return new i("Unexpected token: "+e.token.toString());case n.UNSUPPORTED_BIGINT:return new i("BigInt is unsupported");case n.STRING_TOO_LARGE:return new i("Max String length is 4294967295, found: "+e.size);case n.ARRAY_TOO_LARGE:return new i("Max Array length is 4294967295, found: "+e.size);case n.OBJECT_TOO_LARGE:return new i("Max Object length is 4294967295, found: "+e.size);case n.NUMBER_TOO_LARGE:return new i("Max Number is "+Number.MAX_SAFE_INTEGER+", found: "+e.number);default:return new i("Unknown error code")}},i}(Error),_=new TextEncoder,l=function(){function t(t){this.view=new r(t),this.textEncoder=_}return t.prototype.finalize=function(){return this.view.slice(0,this.view.offset)},t.prototype.write=function(t){switch(this.getType(t)){case 0:this.view.setUint8(247);break;case 1:this.view.setUint8(246);break;case 2:this.view.setUint8(t?245:244);break;case 3:if(Number.isSafeInteger(t))if(t>=0)if(t<=23)this.view.setUint8(t);else if(t<=255)this.view.setUint8(24),this.view.setUint8(t);else if(t<=65535)this.view.setUint8(25),this.view.setUint16(t);else{if(!(t<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(26),this.view.setUint32(t)}else{var e=-1-t;if(t>=-24)this.view.setUint8(32+e);else if(e<=255)this.view.setUint8(56),this.view.setUint8(e);else if(e<=65535)this.view.setUint8(57),this.view.setUint16(e);else{if(!(e<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(58),this.view.setUint32(e)}}else isNaN(t)||!isFinite(t)||-8388607<=t&&t<=8388607?(this.view.setUint8(250),this.view.setFloat32(t)):(this.view.setUint8(251),this.view.setFloat64(t));break;case 4:var i=this.textEncoder.encode(t);if((o=i.length)<=23)this.view.setUint8(96+o);else if(o<=255)this.view.setUint8(120),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(121),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.STRING_TOO_LARGE,{size:o});this.view.setUint8(122),this.view.setUint32(o)}o>0&&this.view.setBytes(i);break;case 5:if((o=t.length)<=23)this.view.setUint8(128+o);else if(o<=255)this.view.setUint8(152),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(153),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.ARRAY_TOO_LARGE,{size:o});this.view.setUint8(154),this.view.setUint32(o)}for(var s=0,r=t;s<r.length;s++){var h=r[s];this.write(h)}break;case 6:var o;if((o=Object.keys(t).length)<=23)this.view.setUint8(160+o);else if(o<=255)this.view.setUint8(184),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(185),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.OBJECT_TOO_LARGE,{size:o});this.view.setUint8(186),this.view.setUint32(o)}for(var a=0,u=Object.entries(t);a<u.length;a++){var f=u[a],c=f[0],_=f[1];this.write(c),this.write(_)}}},t.prototype.getType=function(t){switch(!0){case void 0===t:return 0;case null===t:return 1;case"boolean"==typeof t:return 2;case"number"==typeof t:return 3;case"bigint"==typeof t:throw w.build(n.UNSUPPORTED_BIGINT);case"string"==typeof t:return 4;case Array.isArray(t):return 5;case"object"==typeof t:return 6;default:throw w.build(n.UNEXPECTED_TOKEN,{token:t})}},t}();function p(t,e,i){var s=i||new ArrayBuffer(1024),r=new l(s);if(e)r.write(t);else try{r.write(t)}catch(t){return null}return r.finalize()}var E=function(){function t(){}return t.decode=function(t,e){return void 0===e&&(e=!1),function(t,e){if(void 0===e&&(e=!1),e)return new c(new r(t)).parse();try{return new c(new r(t)).parse()}catch(t){return null}}(t,e)},t.encode=function(t,e){return void 0===e&&(e=!1),p(t,e)},t.encodeInto=function(t,e,i){return void 0===i&&(i=!1),p(e,i,t)},t}();export default E;
var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};function e(e,i){function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}var i,s=function(t){function i(e,i){var s=t.call(this,"View offset out of bounds: "+e+" > "+i)||this;return s.what="View offset out of bounds: "+e+" > "+i,s}return e(i,t),i}(Error),r=function(){function t(t,e){void 0===e&&(e=0),this.buffer=t,this.offset=e,this.view=new DataView(this.buffer,0,this.buffer.byteLength),this.arrayView=new Uint8Array(this.buffer)}return t.prototype.slice=function(t,e){return this.buffer.slice(t,e)},t.prototype.getFloat32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat32(this.offset-4,!1)},t.prototype.getFloat64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat64(this.offset-8,!1)},t.prototype.getInt8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt8(this.offset-1)},t.prototype.getInt16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt16(this.offset-2,!1)},t.prototype.getInt32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt32(this.offset-4,!1)},t.prototype.getInt64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigInt64(this.offset-8,!1)},t.prototype.getUint8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint8(this.offset-1)},t.prototype.getUint16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint16(this.offset-2,!1)},t.prototype.getUint32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint32(this.offset-4,!1)},t.prototype.getUint64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigUint64(this.offset-8,!1)},t.prototype.getBytes=function(t){if(this.offset+=t,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return new Uint8Array(this.buffer.slice(this.offset-t,this.offset))},t.prototype.setFloat32=function(t){this.offset+=4,this.resize(this.offset),this.view.setFloat32(this.offset-4,t,!1)},t.prototype.setFloat64=function(t){this.offset+=8,this.resize(this.offset),this.view.setFloat64(this.offset-8,t,!1)},t.prototype.setInt8=function(t){this.offset+=1,this.resize(this.offset),this.view.setInt8(this.offset-1,t)},t.prototype.setInt16=function(t){this.offset+=2,this.resize(this.offset),this.view.setInt16(this.offset-2,t,!1)},t.prototype.setInt32=function(t){this.offset+=4,this.resize(this.offset),this.view.setInt32(this.offset-4,t,!1)},t.prototype.setInt64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigInt64(this.offset-8,t,!1)},t.prototype.setUint8=function(t){this.offset+=1,this.resize(this.offset),this.view.setUint8(this.offset-1,t)},t.prototype.setUint16=function(t){this.offset+=2,this.resize(this.offset),this.view.setUint16(this.offset-2,t,!1)},t.prototype.setUint32=function(t){this.offset+=4,this.resize(this.offset),this.view.setUint32(this.offset-4,t,!1)},t.prototype.setUint64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigUint64(this.offset-8,t,!1)},t.prototype.setBytes=function(t){this.offset+=t.byteLength,this.resize(this.offset),this.arrayView.set(t,this.offset-t.byteLength)},t.prototype.resize=function(t){if(!(this.buffer.byteLength>t)){var e=this.buffer;this.buffer=new ArrayBuffer(2*t),this.arrayView=new Uint8Array(this.buffer),this.arrayView.set(new Uint8Array(e)),this.view=new DataView(this.buffer)}},t}();!function(t){t[t.REACHED_MAX_NESTING_DEPTH=0]="REACHED_MAX_NESTING_DEPTH",t[t.EMPTY_STACK=1]="EMPTY_STACK",t[t.UNEXPECTED_OBJECT_END=2]="UNEXPECTED_OBJECT_END",t[t.UNEXPECTED_ARRAY_END=3]="UNEXPECTED_ARRAY_END",t[t.UNSUPPORTED_BYTE_STRING=4]="UNSUPPORTED_BYTE_STRING",t[t.UNSUPPORTED_HALF=5]="UNSUPPORTED_HALF",t[t.UNEXPECTED_VALUE=6]="UNEXPECTED_VALUE",t[t.UNSUPPORTED_64_BIT=7]="UNSUPPORTED_64_BIT"}(i||(i={}));var n,h=function(t){function s(e){return t.call(this,e)||this}return e(s,t),s.build=function(t,e){switch(t){case i.REACHED_MAX_NESTING_DEPTH:return new s("Max recursion depth reached: "+(e?"":e.depth));case i.EMPTY_STACK:return new s("Unexpected key/value before the start of an object or array");case i.UNEXPECTED_OBJECT_END:return new s("Unexpected end of object before the start of an object");case i.UNEXPECTED_ARRAY_END:return new s("Unexpected end of array before the start of an array");case i.UNSUPPORTED_BYTE_STRING:return new s("byte strings are unsupported");case i.UNSUPPORTED_HALF:return new s("Half (IEEE754 binary16) is unsupported");case i.UNEXPECTED_VALUE:return new s("Found value before key in object");case i.UNSUPPORTED_64_BIT:return new s("64-bit values are unsupported");default:return new s("Unknown error code")}},s}(Error),o=function(){function t(t,e){this.type=t,this.value=e}return t.prototype.isArray=function(){return"array"===this.type},t.prototype.isObject=function(){return!this.isArray()},t.prototype.array=function(){return this.value},t.prototype.object=function(){return this.value},t}(),a=function(){function t(){this.stack=[]}return Object.defineProperty(t.prototype,"length",{get:function(){return this.stack.length},enumerable:!1,configurable:!0}),t.prototype.push=function(t,e){this.stack.push(new o(t,e))},t.prototype.pop=function(){return this.stack.pop()},t.prototype.last=function(){return this.stack[this.stack.length-1]},t.prototype.empty=function(){return 0===this.stack.length},t}(),u=function(){function t(t){this.max_depth=t,this.root=null,this.stack=new a,this.last_key=null}return t.prototype.null=function(){return this.handle(null)},t.prototype.undefined=function(){return this.handle(void 0)},t.prototype.boolean=function(t){return this.handle(t)},t.prototype.number=function(t){return this.handle(t)},t.prototype.string=function(t){return this.handle(t)},t.prototype.begin_object=function(){if(this.stack.push("object",this.handle({})),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.key=function(t){var e=this.stack.last();if(!e)throw h.build(i.EMPTY_STACK);e.object()[t]=null,this.last_key=t},t.prototype.end_object=function(){if(this.stack.empty()||!this.stack.last().isObject())throw h.build(i.UNEXPECTED_OBJECT_END);return this.stack.pop().object()},t.prototype.begin_array=function(){if(this.stack.push("array",this.handle([])),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.end_array=function(){if(this.stack.empty()||!this.stack.last().isArray())throw h.build(i.UNEXPECTED_ARRAY_END);return this.stack.pop().array()},t.prototype.handle=function(t){if(0===this.stack.length&&null===this.root)return this.root=t,t;var e=this.stack.last();if(e.isArray())return e.array().push(t),t;if(e.isObject()){if(!this.last_key)throw h.build(i.UNEXPECTED_VALUE);return e.object()[this.last_key]=t,t}},t}(),f=new TextDecoder,c=function(){function t(t,e){void 0===e&&(e=100),this.view=t,this.sax=new u(e),this.textDecoder=f}return t.prototype.parse=function(){switch(this.get(),!0){case this.current_value<=23:return this.sax.number(this.current_value);case 24===this.current_value:return this.sax.number(this.view.getUint8());case 25===this.current_value:return this.sax.number(this.view.getUint16());case 26===this.current_value:return this.sax.number(this.view.getUint32());case 27===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=55:return this.sax.number(-(1+(31&this.current_value)));case 56===this.current_value:return this.sax.number(-(1+this.view.getUint8()));case 57===this.current_value:return this.sax.number(-(1+this.view.getUint16()));case 58===this.current_value:return this.sax.number(-(1+this.view.getUint32()));case 59===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=95:throw h.build(i.UNSUPPORTED_BYTE_STRING);case this.current_value<=127:return this.sax.string(this.get_string());case this.current_value<=159:return this.get_array();case this.current_value<=191:return this.get_object();case 244===this.current_value:return this.sax.boolean(!1);case 245===this.current_value:return this.sax.boolean(!0);case 246===this.current_value:return this.sax.null();case 247===this.current_value:return this.sax.undefined();case 249===this.current_value:throw h.build(i.UNSUPPORTED_HALF);case 250===this.current_value:return this.sax.number(this.view.getFloat32());case 251===this.current_value:return this.sax.number(this.view.getFloat64())}},t.prototype.get=function(){return this.current_value=this.view.getUint8(),this.current_value},t.prototype.get_string=function(){var t=-1;switch(!0){case this.current_value<=119:t=31&this.current_value;break;case 120===this.current_value:t=this.view.getUint8();break;case 121===this.current_value:t=this.view.getUint16();break;case 122===this.current_value:t=this.view.getUint32();break;case 123===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case 127===this.current_value:}var e=[];if(t>-1){var s=this.view.getBytes(t);s.length>0&&e.push(this.textDecoder.decode(s))}else{for(var r=[];255!==this.get();)r.push(this.get_string());e.push.apply(e,r)}return e.join("")},t.prototype.get_array=function(){this.sax.begin_array();var t=-1;switch(!0){case this.current_value<=151:t=31&this.current_value;break;case 152===this.current_value:t=this.view.getUint8();break;case 153===this.current_value:t=this.view.getUint16();break;case 154===this.current_value:t=this.view.getUint32();break;case 155===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case 159===this.current_value:}if(t>-1)for(var e=0;e<t;e++)this.parse();else for(;255!==this.current_value;)this.parse();return this.sax.end_array()},t.prototype.get_object=function(){this.sax.begin_object();var t=-1;switch(!0){case this.current_value<=183:t=31&this.current_value;break;case 184===this.current_value:t=this.view.getUint8();break;case 185===this.current_value:t=this.view.getUint16();break;case 186===this.current_value:t=this.view.getUint32();break;case 187===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT)}if(t>-1)for(var e=0;e<t;e++)this.get(),this.sax.key(this.get_string()),this.parse();else for(;255!==this.get();)this.sax.key(this.get_string()),this.parse();return this.sax.end_object()},t}();!function(t){t[t.UNEXPECTED_TOKEN=0]="UNEXPECTED_TOKEN",t[t.UNSUPPORTED_BIGINT=1]="UNSUPPORTED_BIGINT",t[t.STRING_TOO_LARGE=2]="STRING_TOO_LARGE",t[t.ARRAY_TOO_LARGE=3]="ARRAY_TOO_LARGE",t[t.OBJECT_TOO_LARGE=4]="OBJECT_TOO_LARGE",t[t.NUMBER_TOO_LARGE=5]="NUMBER_TOO_LARGE"}(n||(n={}));var w=function(t){function i(e){var i=t.call(this,e)||this;return i.what=e,i}return e(i,t),i.prototype.toString=function(){return"ParseError: "+this.what},i.build=function(t,e){switch(void 0===e&&(e={}),t){case n.UNEXPECTED_TOKEN:return new i("Unexpected token: "+e.token);case n.UNSUPPORTED_BIGINT:return new i("BigInt is unsupported");case n.STRING_TOO_LARGE:return new i("Max String length is 4294967295, found: "+e.size);case n.ARRAY_TOO_LARGE:return new i("Max Array length is 4294967295, found: "+e.size);case n.OBJECT_TOO_LARGE:return new i("Max Object length is 4294967295, found: "+e.size);case n.NUMBER_TOO_LARGE:return new i("Max Number is "+Number.MAX_SAFE_INTEGER+", found: "+e.number);default:return new i("Unknown error code")}},i}(Error),_=new TextEncoder,l=function(){function t(t){this.view=new r(t),this.textEncoder=_}return t.prototype.finalize=function(){return this.view.slice(0,this.view.offset)},t.prototype.write=function(t){switch(this.getType(t)){case 0:this.view.setUint8(247);break;case 1:this.view.setUint8(246);break;case 2:this.view.setUint8(t?245:244);break;case 3:if(Number.isSafeInteger(t))if(t>=0)if(t<=23)this.view.setUint8(t);else if(t<=255)this.view.setUint8(24),this.view.setUint8(t);else if(t<=65535)this.view.setUint8(25),this.view.setUint16(t);else{if(!(t<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(26),this.view.setUint32(t)}else{var e=-1-t;if(t>=-24)this.view.setUint8(32+e);else if(e<=255)this.view.setUint8(56),this.view.setUint8(e);else if(e<=65535)this.view.setUint8(57),this.view.setUint16(e);else{if(!(e<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(58),this.view.setUint32(e)}}else isNaN(t)||!isFinite(t)||-8388607<=t&&t<=8388607?(this.view.setUint8(250),this.view.setFloat32(t)):(this.view.setUint8(251),this.view.setFloat64(t));break;case 4:var i=this.textEncoder.encode(t);if((o=i.length)<=23)this.view.setUint8(96+o);else if(o<=255)this.view.setUint8(120),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(121),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.STRING_TOO_LARGE,{size:o});this.view.setUint8(122),this.view.setUint32(o)}o>0&&this.view.setBytes(i);break;case 5:if((o=t.length)<=23)this.view.setUint8(128+o);else if(o<=255)this.view.setUint8(152),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(153),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.ARRAY_TOO_LARGE,{size:o});this.view.setUint8(154),this.view.setUint32(o)}for(var s=0,r=t;s<r.length;s++){var h=r[s];this.write(h)}break;case 6:var o;if((o=Object.keys(t).length)<=23)this.view.setUint8(160+o);else if(o<=255)this.view.setUint8(184),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(185),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.OBJECT_TOO_LARGE,{size:o});this.view.setUint8(186),this.view.setUint32(o)}for(var a=0,u=Object.entries(t);a<u.length;a++){var f=u[a],c=f[0],_=f[1];this.write(c),this.write(_)}}},t.prototype.getType=function(t){switch(!0){case void 0===t:return 0;case null===t:return 1;case"boolean"==typeof t:return 2;case"number"==typeof t:return 3;case"bigint"==typeof t:throw w.build(n.UNSUPPORTED_BIGINT);case"string"==typeof t:return 4;case Array.isArray(t):return 5;case"object"==typeof t:return 6;default:throw w.build(n.UNEXPECTED_TOKEN,{token:t})}},t}();function p(t,e,i){var s=i||new ArrayBuffer(1024),r=new l(s);if(e)r.write(t);else try{r.write(t)}catch(t){return null}return r.finalize()}var v=function(){function t(){}return t.decode=function(t,e){return void 0===e&&(e=!1),function(t,e){if(void 0===e&&(e=!1),e)return new c(new r(t)).parse();try{return new c(new r(t)).parse()}catch(t){return null}}(t,e)},t.encode=function(t,e){return void 0===e&&(e=!1),p(t,e)},t.encodeInto=function(t,e,i){return void 0===i&&(i=!1),p(e,i,t)},t}();export default v;

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).CBOR=e()}(this,(function(){"use strict";var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};function e(e,i){function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}var i,s=function(t){function i(e,i){var s=t.call(this,"View offset out of bounds: "+e+" > "+i)||this;return s.what="View offset out of bounds: "+e+" > "+i,s}return e(i,t),i.prototype.toString=function(){return"OutOfBoundsError: "+this.what},i}(Error),r=function(){function t(t,e){void 0===e&&(e=0),this.buffer=t,this.offset=e,this.view=new DataView(this.buffer,0,this.buffer.byteLength),this.arrayView=new Uint8Array(this.buffer)}return t.prototype.slice=function(t,e){return this.buffer.slice(t,e)},t.prototype.getFloat32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat32(this.offset-4,!1)},t.prototype.getFloat64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat64(this.offset-8,!1)},t.prototype.getInt8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt8(this.offset-1)},t.prototype.getInt16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt16(this.offset-2,!1)},t.prototype.getInt32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt32(this.offset-4,!1)},t.prototype.getInt64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigInt64(this.offset-8,!1)},t.prototype.getUint8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint8(this.offset-1)},t.prototype.getUint16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint16(this.offset-2,!1)},t.prototype.getUint32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint32(this.offset-4,!1)},t.prototype.getUint64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigUint64(this.offset-8,!1)},t.prototype.getBytes=function(t){if(this.offset+=t,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return new Uint8Array(this.buffer.slice(this.offset-t,this.offset))},t.prototype.setFloat32=function(t){this.offset+=4,this.resize(this.offset),this.view.setFloat32(this.offset-4,t,!1)},t.prototype.setFloat64=function(t){this.offset+=8,this.resize(this.offset),this.view.setFloat64(this.offset-8,t,!1)},t.prototype.setInt8=function(t){this.offset+=1,this.resize(this.offset),this.view.setInt8(this.offset-1,t)},t.prototype.setInt16=function(t){this.offset+=2,this.resize(this.offset),this.view.setInt16(this.offset-2,t,!1)},t.prototype.setInt32=function(t){this.offset+=4,this.resize(this.offset),this.view.setInt32(this.offset-4,t,!1)},t.prototype.setInt64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigInt64(this.offset-8,t,!1)},t.prototype.setUint8=function(t){this.offset+=1,this.resize(this.offset),this.view.setUint8(this.offset-1,t)},t.prototype.setUint16=function(t){this.offset+=2,this.resize(this.offset),this.view.setUint16(this.offset-2,t,!1)},t.prototype.setUint32=function(t){this.offset+=4,this.resize(this.offset),this.view.setUint32(this.offset-4,t,!1)},t.prototype.setUint64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigUint64(this.offset-8,t,!1)},t.prototype.setBytes=function(t){this.offset+=t.byteLength,this.resize(this.offset),this.arrayView.set(t,this.offset-t.byteLength)},t.prototype.resize=function(t){if(!(this.buffer.byteLength>t)){var e=this.buffer;this.buffer=new ArrayBuffer(2*t),this.arrayView=new Uint8Array(this.buffer),this.arrayView.set(new Uint8Array(e)),this.view=new DataView(this.buffer)}},t}();!function(t){t[t.UNEXPECTED_EOF=0]="UNEXPECTED_EOF",t[t.REACHED_MAX_NESTING_DEPTH=1]="REACHED_MAX_NESTING_DEPTH",t[t.EMPTY_STACK=2]="EMPTY_STACK",t[t.UNEXPECTED_OBJECT_END=3]="UNEXPECTED_OBJECT_END",t[t.UNEXPECTED_ARRAY_END=4]="UNEXPECTED_ARRAY_END",t[t.UNSUPPORTED_BYTE_STRING=5]="UNSUPPORTED_BYTE_STRING",t[t.WRONG_STRING_FORMAT=6]="WRONG_STRING_FORMAT",t[t.UNSUPPORTED_HALF=7]="UNSUPPORTED_HALF",t[t.UNEXPECTED_TOKEN=8]="UNEXPECTED_TOKEN",t[t.UNEXPECTED_VALUE=9]="UNEXPECTED_VALUE",t[t.UNSUPPORTED_64_BIT=10]="UNSUPPORTED_64_BIT"}(i||(i={}));var n,h=function(t){function s(e){var i=t.call(this,e)||this;return i.what=e,i}return e(s,t),s.prototype.toString=function(){return"ParseError: "+this.what},s.build=function(t,e){switch(t){case i.UNEXPECTED_EOF:return new s("Unexpected EOF at offset "+(e?"":e.offset));case i.REACHED_MAX_NESTING_DEPTH:return new s("Max recursion depth reached: "+(e?"":e.depth));case i.EMPTY_STACK:return new s("Unexpected value before the start of an object or array");case i.UNEXPECTED_OBJECT_END:return new s("Unexpected end of object before the start of an object");case i.UNEXPECTED_ARRAY_END:return new s("Unexpected end of array before the start of an array");case i.UNSUPPORTED_BYTE_STRING:return new s("byte strings are unsupported");case i.WRONG_STRING_FORMAT:return new s("Expected string length value range 0x60 to 0x7F, found: "+e.token);case i.UNSUPPORTED_HALF:return new s("Half (IEEE754 binary16) is unsupported");case i.UNEXPECTED_TOKEN:return new s("Unexpected token: "+e.token);case i.UNEXPECTED_VALUE:return new s("Found value before key in object");case i.UNSUPPORTED_64_BIT:return new s("64-bit values are unsupported");default:return new s("Unknown error code")}},s}(Error),o=function(){function t(t,e){this.type=t,this.value=e}return t.prototype.isArray=function(){return"array"===this.type},t.prototype.isObject=function(){return!this.isArray()},t.prototype.array=function(){return this.value},t.prototype.object=function(){return this.value},t}(),a=function(){function t(){this.stack=[]}return Object.defineProperty(t.prototype,"length",{get:function(){return this.stack.length},enumerable:!1,configurable:!0}),t.prototype.push=function(t,e){this.stack.push(new o(t,e))},t.prototype.pop=function(){return this.stack.pop()},t.prototype.last=function(){return this.stack[this.stack.length-1]},t.prototype.empty=function(){return 0===this.stack.length},t}(),u=function(){function t(t){this.max_depth=t,this.root=null,this.stack=new a,this.last_key=null}return t.prototype.null=function(){return this.handle(null)},t.prototype.undefined=function(){return this.handle(void 0)},t.prototype.boolean=function(t){return this.handle(t)},t.prototype.number=function(t){return this.handle(t)},t.prototype.string=function(t){return this.handle(t)},t.prototype.begin_object=function(){if(this.stack.push("object",this.handle({})),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.key=function(t){var e=this.stack.last();if(!e)throw h.build(i.EMPTY_STACK);e.object()[t]=null,this.last_key=t},t.prototype.end_object=function(){if(this.stack.empty()||!this.stack.last().isObject())throw h.build(i.UNEXPECTED_OBJECT_END);return this.stack.pop().object()},t.prototype.begin_array=function(){if(this.stack.push("array",this.handle([])),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.end_array=function(){if(this.stack.empty()||!this.stack.last().isArray())throw h.build(i.UNEXPECTED_ARRAY_END);return this.stack.pop().array()},t.prototype.handle=function(t){if(0===this.stack.length&&null===this.root)return this.root=t,t;var e=this.stack.last();if(e.isArray())return e.array().push(t),t;if(e.isObject()){if(!this.last_key)throw h.build(i.UNEXPECTED_VALUE);return e.object()[this.last_key]=t,t}},t}(),f=new TextDecoder,c=function(){function t(t,e){void 0===e&&(e=100),this.view=t,this.sax=new u(e),this.textDecoder=f}return t.prototype.parse=function(){switch(this.get(),!0){case this.current_value<0:throw h.build(i.UNEXPECTED_EOF,{offset:this.view.offset});case this.current_value<=23:return this.sax.number(this.current_value);case 24===this.current_value:return this.sax.number(this.view.getUint8());case 25===this.current_value:return this.sax.number(this.view.getUint16());case 26===this.current_value:return this.sax.number(this.view.getUint32());case 27===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=55:return this.sax.number(-(1+(31&this.current_value)));case 56===this.current_value:return this.sax.number(-(1+this.view.getUint8()));case 57===this.current_value:return this.sax.number(-(1+this.view.getUint16()));case 58===this.current_value:return this.sax.number(-(1+this.view.getUint32()));case 59===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=95:throw h.build(i.UNSUPPORTED_BYTE_STRING);case this.current_value<=127:return this.sax.string(this.get_string());case this.current_value<=159:return this.get_array();case this.current_value<=191:return this.get_object();case 244===this.current_value:return this.sax.boolean(!1);case 245===this.current_value:return this.sax.boolean(!0);case 246===this.current_value:return this.sax.null();case 247===this.current_value:return this.sax.undefined();case 249===this.current_value:throw h.build(i.UNSUPPORTED_HALF);case 250===this.current_value:return this.sax.number(this.view.getFloat32());case 251===this.current_value:return this.sax.number(this.view.getFloat64())}},t.prototype.get=function(){return this.current_value=this.view.getUint8(),this.current_value},t.prototype.get_string=function(){var t=-1;switch(!0){case this.current_value<=119:t=31&this.current_value;break;case 120===this.current_value:t=this.view.getUint8();break;case 121===this.current_value:t=this.view.getUint16();break;case 122===this.current_value:t=this.view.getUint32();break;case 123===this.current_value:t=this.view.getUint64();break;case 127===this.current_value:break;default:throw h.build(i.WRONG_STRING_FORMAT,{token:"0x"+this.current_value.toString(16).toUpperCase()})}var e=[];if(t>-1)if("bigint"==typeof t){for(var s=[],r=0;r<t;r++)s.push(this.get());e.push(this.textDecoder.decode(new Uint8Array(s)))}else{(s=this.view.getBytes(t)).length>0&&e.push(this.textDecoder.decode(s))}else{for(var n=[];255!==this.get();)n.push(this.get_string());e.push.apply(e,n)}return e.join("")},t.prototype.get_array=function(){this.sax.begin_array();var t=-1;switch(!0){case this.current_value<=151:t=31&this.current_value;break;case 152===this.current_value:t=this.view.getUint8();break;case 153===this.current_value:t=this.view.getUint16();break;case 154===this.current_value:t=this.view.getUint32();break;case 155===this.current_value:t=this.view.getUint64();break;case 159===this.current_value:break;default:throw h.build(i.UNEXPECTED_TOKEN,{token:"0x"+this.current_value.toString(16).toUpperCase()})}if(t>-1)for(var e=0;e<t;e++)this.parse();else for(;255!==this.current_value;)this.parse();return this.sax.end_array()},t.prototype.get_object=function(){this.sax.begin_object();var t=-1;switch(!0){case this.current_value<=183:t=31&this.current_value;break;case 184===this.current_value:t=this.view.getUint8();break;case 185===this.current_value:t=this.view.getUint16();break;case 186===this.current_value:t=this.view.getUint32();break;case 187===this.current_value:t=this.view.getUint64()}if(t>-1)for(var e=0;e<t;e++)this.get(),this.sax.key(this.get_string()),this.parse();else for(;255!==this.get();)this.sax.key(this.get_string()),this.parse();return this.sax.end_object()},t}();!function(t){t[t.UNEXPECTED_TOKEN=0]="UNEXPECTED_TOKEN",t[t.UNSUPPORTED_BIGINT=1]="UNSUPPORTED_BIGINT",t[t.STRING_TOO_LARGE=2]="STRING_TOO_LARGE",t[t.ARRAY_TOO_LARGE=3]="ARRAY_TOO_LARGE",t[t.OBJECT_TOO_LARGE=4]="OBJECT_TOO_LARGE",t[t.NUMBER_TOO_LARGE=5]="NUMBER_TOO_LARGE"}(n||(n={}));var w=function(t){function i(e){var i=t.call(this,e)||this;return i.what=e,i}return e(i,t),i.prototype.toString=function(){return"ParseError: "+this.what},i.build=function(t,e){switch(t){case n.UNEXPECTED_TOKEN:return new i("Unexpected token: "+e.token.toString());case n.UNSUPPORTED_BIGINT:return new i("BigInt is unsupported");case n.STRING_TOO_LARGE:return new i("Max String length is 4294967295, found: "+e.size);case n.ARRAY_TOO_LARGE:return new i("Max Array length is 4294967295, found: "+e.size);case n.OBJECT_TOO_LARGE:return new i("Max Object length is 4294967295, found: "+e.size);case n.NUMBER_TOO_LARGE:return new i("Max Number is "+Number.MAX_SAFE_INTEGER+", found: "+e.number);default:return new i("Unknown error code")}},i}(Error),_=new TextEncoder,l=function(){function t(t){this.view=new r(t),this.textEncoder=_}return t.prototype.finalize=function(){return this.view.slice(0,this.view.offset)},t.prototype.write=function(t){switch(this.getType(t)){case 0:this.view.setUint8(247);break;case 1:this.view.setUint8(246);break;case 2:this.view.setUint8(t?245:244);break;case 3:if(Number.isSafeInteger(t))if(t>=0)if(t<=23)this.view.setUint8(t);else if(t<=255)this.view.setUint8(24),this.view.setUint8(t);else if(t<=65535)this.view.setUint8(25),this.view.setUint16(t);else{if(!(t<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(26),this.view.setUint32(t)}else{var e=-1-t;if(t>=-24)this.view.setUint8(32+e);else if(e<=255)this.view.setUint8(56),this.view.setUint8(e);else if(e<=65535)this.view.setUint8(57),this.view.setUint16(e);else{if(!(e<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(58),this.view.setUint32(e)}}else isNaN(t)||!isFinite(t)||-8388607<=t&&t<=8388607?(this.view.setUint8(250),this.view.setFloat32(t)):(this.view.setUint8(251),this.view.setFloat64(t));break;case 4:var i=this.textEncoder.encode(t);if((o=i.length)<=23)this.view.setUint8(96+o);else if(o<=255)this.view.setUint8(120),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(121),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.STRING_TOO_LARGE,{size:o});this.view.setUint8(122),this.view.setUint32(o)}o>0&&this.view.setBytes(i);break;case 5:if((o=t.length)<=23)this.view.setUint8(128+o);else if(o<=255)this.view.setUint8(152),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(153),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.ARRAY_TOO_LARGE,{size:o});this.view.setUint8(154),this.view.setUint32(o)}for(var s=0,r=t;s<r.length;s++){var h=r[s];this.write(h)}break;case 6:var o;if((o=Object.keys(t).length)<=23)this.view.setUint8(160+o);else if(o<=255)this.view.setUint8(184),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(185),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.OBJECT_TOO_LARGE,{size:o});this.view.setUint8(186),this.view.setUint32(o)}for(var a=0,u=Object.entries(t);a<u.length;a++){var f=u[a],c=f[0],_=f[1];this.write(c),this.write(_)}}},t.prototype.getType=function(t){switch(!0){case void 0===t:return 0;case null===t:return 1;case"boolean"==typeof t:return 2;case"number"==typeof t:return 3;case"bigint"==typeof t:throw w.build(n.UNSUPPORTED_BIGINT);case"string"==typeof t:return 4;case Array.isArray(t):return 5;case"object"==typeof t:return 6;default:throw w.build(n.UNEXPECTED_TOKEN,{token:t})}},t}();function p(t,e,i){var s=i||new ArrayBuffer(1024),r=new l(s);if(e)r.write(t);else try{r.write(t)}catch(t){return null}return r.finalize()}return function(){function t(){}return t.decode=function(t,e){return void 0===e&&(e=!1),function(t,e){if(void 0===e&&(e=!1),e)return new c(new r(t)).parse();try{return new c(new r(t)).parse()}catch(t){return null}}(t,e)},t.encode=function(t,e){return void 0===e&&(e=!1),p(t,e)},t.encodeInto=function(t,e,i){return void 0===i&&(i=!1),p(e,i,t)},t}()}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).CBOR=e()}(this,(function(){"use strict";var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};function e(e,i){function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}var i,s=function(t){function i(e,i){var s=t.call(this,"View offset out of bounds: "+e+" > "+i)||this;return s.what="View offset out of bounds: "+e+" > "+i,s}return e(i,t),i}(Error),r=function(){function t(t,e){void 0===e&&(e=0),this.buffer=t,this.offset=e,this.view=new DataView(this.buffer,0,this.buffer.byteLength),this.arrayView=new Uint8Array(this.buffer)}return t.prototype.slice=function(t,e){return this.buffer.slice(t,e)},t.prototype.getFloat32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat32(this.offset-4,!1)},t.prototype.getFloat64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getFloat64(this.offset-8,!1)},t.prototype.getInt8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt8(this.offset-1)},t.prototype.getInt16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt16(this.offset-2,!1)},t.prototype.getInt32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getInt32(this.offset-4,!1)},t.prototype.getInt64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigInt64(this.offset-8,!1)},t.prototype.getUint8=function(){if(this.offset+=1,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint8(this.offset-1)},t.prototype.getUint16=function(){if(this.offset+=2,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint16(this.offset-2,!1)},t.prototype.getUint32=function(){if(this.offset+=4,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getUint32(this.offset-4,!1)},t.prototype.getUint64=function(){if(this.offset+=8,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return this.view.getBigUint64(this.offset-8,!1)},t.prototype.getBytes=function(t){if(this.offset+=t,this.offset>this.arrayView.byteLength)throw new s(this.offset,this.arrayView.byteLength);return new Uint8Array(this.buffer.slice(this.offset-t,this.offset))},t.prototype.setFloat32=function(t){this.offset+=4,this.resize(this.offset),this.view.setFloat32(this.offset-4,t,!1)},t.prototype.setFloat64=function(t){this.offset+=8,this.resize(this.offset),this.view.setFloat64(this.offset-8,t,!1)},t.prototype.setInt8=function(t){this.offset+=1,this.resize(this.offset),this.view.setInt8(this.offset-1,t)},t.prototype.setInt16=function(t){this.offset+=2,this.resize(this.offset),this.view.setInt16(this.offset-2,t,!1)},t.prototype.setInt32=function(t){this.offset+=4,this.resize(this.offset),this.view.setInt32(this.offset-4,t,!1)},t.prototype.setInt64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigInt64(this.offset-8,t,!1)},t.prototype.setUint8=function(t){this.offset+=1,this.resize(this.offset),this.view.setUint8(this.offset-1,t)},t.prototype.setUint16=function(t){this.offset+=2,this.resize(this.offset),this.view.setUint16(this.offset-2,t,!1)},t.prototype.setUint32=function(t){this.offset+=4,this.resize(this.offset),this.view.setUint32(this.offset-4,t,!1)},t.prototype.setUint64=function(t){this.offset+=8,this.resize(this.offset),this.view.setBigUint64(this.offset-8,t,!1)},t.prototype.setBytes=function(t){this.offset+=t.byteLength,this.resize(this.offset),this.arrayView.set(t,this.offset-t.byteLength)},t.prototype.resize=function(t){if(!(this.buffer.byteLength>t)){var e=this.buffer;this.buffer=new ArrayBuffer(2*t),this.arrayView=new Uint8Array(this.buffer),this.arrayView.set(new Uint8Array(e)),this.view=new DataView(this.buffer)}},t}();!function(t){t[t.REACHED_MAX_NESTING_DEPTH=0]="REACHED_MAX_NESTING_DEPTH",t[t.EMPTY_STACK=1]="EMPTY_STACK",t[t.UNEXPECTED_OBJECT_END=2]="UNEXPECTED_OBJECT_END",t[t.UNEXPECTED_ARRAY_END=3]="UNEXPECTED_ARRAY_END",t[t.UNSUPPORTED_BYTE_STRING=4]="UNSUPPORTED_BYTE_STRING",t[t.UNSUPPORTED_HALF=5]="UNSUPPORTED_HALF",t[t.UNEXPECTED_VALUE=6]="UNEXPECTED_VALUE",t[t.UNSUPPORTED_64_BIT=7]="UNSUPPORTED_64_BIT"}(i||(i={}));var n,h=function(t){function s(e){return t.call(this,e)||this}return e(s,t),s.build=function(t,e){switch(t){case i.REACHED_MAX_NESTING_DEPTH:return new s("Max recursion depth reached: "+(e?"":e.depth));case i.EMPTY_STACK:return new s("Unexpected key/value before the start of an object or array");case i.UNEXPECTED_OBJECT_END:return new s("Unexpected end of object before the start of an object");case i.UNEXPECTED_ARRAY_END:return new s("Unexpected end of array before the start of an array");case i.UNSUPPORTED_BYTE_STRING:return new s("byte strings are unsupported");case i.UNSUPPORTED_HALF:return new s("Half (IEEE754 binary16) is unsupported");case i.UNEXPECTED_VALUE:return new s("Found value before key in object");case i.UNSUPPORTED_64_BIT:return new s("64-bit values are unsupported");default:return new s("Unknown error code")}},s}(Error),o=function(){function t(t,e){this.type=t,this.value=e}return t.prototype.isArray=function(){return"array"===this.type},t.prototype.isObject=function(){return!this.isArray()},t.prototype.array=function(){return this.value},t.prototype.object=function(){return this.value},t}(),a=function(){function t(){this.stack=[]}return Object.defineProperty(t.prototype,"length",{get:function(){return this.stack.length},enumerable:!1,configurable:!0}),t.prototype.push=function(t,e){this.stack.push(new o(t,e))},t.prototype.pop=function(){return this.stack.pop()},t.prototype.last=function(){return this.stack[this.stack.length-1]},t.prototype.empty=function(){return 0===this.stack.length},t}(),u=function(){function t(t){this.max_depth=t,this.root=null,this.stack=new a,this.last_key=null}return t.prototype.null=function(){return this.handle(null)},t.prototype.undefined=function(){return this.handle(void 0)},t.prototype.boolean=function(t){return this.handle(t)},t.prototype.number=function(t){return this.handle(t)},t.prototype.string=function(t){return this.handle(t)},t.prototype.begin_object=function(){if(this.stack.push("object",this.handle({})),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.key=function(t){var e=this.stack.last();if(!e)throw h.build(i.EMPTY_STACK);e.object()[t]=null,this.last_key=t},t.prototype.end_object=function(){if(this.stack.empty()||!this.stack.last().isObject())throw h.build(i.UNEXPECTED_OBJECT_END);return this.stack.pop().object()},t.prototype.begin_array=function(){if(this.stack.push("array",this.handle([])),this.stack.length>this.max_depth)throw h.build(i.REACHED_MAX_NESTING_DEPTH,{depth:this.max_depth})},t.prototype.end_array=function(){if(this.stack.empty()||!this.stack.last().isArray())throw h.build(i.UNEXPECTED_ARRAY_END);return this.stack.pop().array()},t.prototype.handle=function(t){if(0===this.stack.length&&null===this.root)return this.root=t,t;var e=this.stack.last();if(e.isArray())return e.array().push(t),t;if(e.isObject()){if(!this.last_key)throw h.build(i.UNEXPECTED_VALUE);return e.object()[this.last_key]=t,t}},t}(),f=new TextDecoder,c=function(){function t(t,e){void 0===e&&(e=100),this.view=t,this.sax=new u(e),this.textDecoder=f}return t.prototype.parse=function(){switch(this.get(),!0){case this.current_value<=23:return this.sax.number(this.current_value);case 24===this.current_value:return this.sax.number(this.view.getUint8());case 25===this.current_value:return this.sax.number(this.view.getUint16());case 26===this.current_value:return this.sax.number(this.view.getUint32());case 27===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=55:return this.sax.number(-(1+(31&this.current_value)));case 56===this.current_value:return this.sax.number(-(1+this.view.getUint8()));case 57===this.current_value:return this.sax.number(-(1+this.view.getUint16()));case 58===this.current_value:return this.sax.number(-(1+this.view.getUint32()));case 59===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case this.current_value<=95:throw h.build(i.UNSUPPORTED_BYTE_STRING);case this.current_value<=127:return this.sax.string(this.get_string());case this.current_value<=159:return this.get_array();case this.current_value<=191:return this.get_object();case 244===this.current_value:return this.sax.boolean(!1);case 245===this.current_value:return this.sax.boolean(!0);case 246===this.current_value:return this.sax.null();case 247===this.current_value:return this.sax.undefined();case 249===this.current_value:throw h.build(i.UNSUPPORTED_HALF);case 250===this.current_value:return this.sax.number(this.view.getFloat32());case 251===this.current_value:return this.sax.number(this.view.getFloat64())}},t.prototype.get=function(){return this.current_value=this.view.getUint8(),this.current_value},t.prototype.get_string=function(){var t=-1;switch(!0){case this.current_value<=119:t=31&this.current_value;break;case 120===this.current_value:t=this.view.getUint8();break;case 121===this.current_value:t=this.view.getUint16();break;case 122===this.current_value:t=this.view.getUint32();break;case 123===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case 127===this.current_value:}var e=[];if(t>-1){var s=this.view.getBytes(t);s.length>0&&e.push(this.textDecoder.decode(s))}else{for(var r=[];255!==this.get();)r.push(this.get_string());e.push.apply(e,r)}return e.join("")},t.prototype.get_array=function(){this.sax.begin_array();var t=-1;switch(!0){case this.current_value<=151:t=31&this.current_value;break;case 152===this.current_value:t=this.view.getUint8();break;case 153===this.current_value:t=this.view.getUint16();break;case 154===this.current_value:t=this.view.getUint32();break;case 155===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT);case 159===this.current_value:}if(t>-1)for(var e=0;e<t;e++)this.parse();else for(;255!==this.current_value;)this.parse();return this.sax.end_array()},t.prototype.get_object=function(){this.sax.begin_object();var t=-1;switch(!0){case this.current_value<=183:t=31&this.current_value;break;case 184===this.current_value:t=this.view.getUint8();break;case 185===this.current_value:t=this.view.getUint16();break;case 186===this.current_value:t=this.view.getUint32();break;case 187===this.current_value:throw h.build(i.UNSUPPORTED_64_BIT)}if(t>-1)for(var e=0;e<t;e++)this.get(),this.sax.key(this.get_string()),this.parse();else for(;255!==this.get();)this.sax.key(this.get_string()),this.parse();return this.sax.end_object()},t}();!function(t){t[t.UNEXPECTED_TOKEN=0]="UNEXPECTED_TOKEN",t[t.UNSUPPORTED_BIGINT=1]="UNSUPPORTED_BIGINT",t[t.STRING_TOO_LARGE=2]="STRING_TOO_LARGE",t[t.ARRAY_TOO_LARGE=3]="ARRAY_TOO_LARGE",t[t.OBJECT_TOO_LARGE=4]="OBJECT_TOO_LARGE",t[t.NUMBER_TOO_LARGE=5]="NUMBER_TOO_LARGE"}(n||(n={}));var w=function(t){function i(e){var i=t.call(this,e)||this;return i.what=e,i}return e(i,t),i.prototype.toString=function(){return"ParseError: "+this.what},i.build=function(t,e){switch(void 0===e&&(e={}),t){case n.UNEXPECTED_TOKEN:return new i("Unexpected token: "+e.token);case n.UNSUPPORTED_BIGINT:return new i("BigInt is unsupported");case n.STRING_TOO_LARGE:return new i("Max String length is 4294967295, found: "+e.size);case n.ARRAY_TOO_LARGE:return new i("Max Array length is 4294967295, found: "+e.size);case n.OBJECT_TOO_LARGE:return new i("Max Object length is 4294967295, found: "+e.size);case n.NUMBER_TOO_LARGE:return new i("Max Number is "+Number.MAX_SAFE_INTEGER+", found: "+e.number);default:return new i("Unknown error code")}},i}(Error),l=new TextEncoder,_=function(){function t(t){this.view=new r(t),this.textEncoder=l}return t.prototype.finalize=function(){return this.view.slice(0,this.view.offset)},t.prototype.write=function(t){switch(this.getType(t)){case 0:this.view.setUint8(247);break;case 1:this.view.setUint8(246);break;case 2:this.view.setUint8(t?245:244);break;case 3:if(Number.isSafeInteger(t))if(t>=0)if(t<=23)this.view.setUint8(t);else if(t<=255)this.view.setUint8(24),this.view.setUint8(t);else if(t<=65535)this.view.setUint8(25),this.view.setUint16(t);else{if(!(t<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(26),this.view.setUint32(t)}else{var e=-1-t;if(t>=-24)this.view.setUint8(32+e);else if(e<=255)this.view.setUint8(56),this.view.setUint8(e);else if(e<=65535)this.view.setUint8(57),this.view.setUint16(e);else{if(!(e<=4294967295))throw w.build(n.NUMBER_TOO_LARGE,{number:t.toString(10)});this.view.setUint8(58),this.view.setUint32(e)}}else isNaN(t)||!isFinite(t)||-8388607<=t&&t<=8388607?(this.view.setUint8(250),this.view.setFloat32(t)):(this.view.setUint8(251),this.view.setFloat64(t));break;case 4:var i=this.textEncoder.encode(t);if((o=i.length)<=23)this.view.setUint8(96+o);else if(o<=255)this.view.setUint8(120),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(121),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.STRING_TOO_LARGE,{size:o});this.view.setUint8(122),this.view.setUint32(o)}o>0&&this.view.setBytes(i);break;case 5:if((o=t.length)<=23)this.view.setUint8(128+o);else if(o<=255)this.view.setUint8(152),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(153),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.ARRAY_TOO_LARGE,{size:o});this.view.setUint8(154),this.view.setUint32(o)}for(var s=0,r=t;s<r.length;s++){var h=r[s];this.write(h)}break;case 6:var o;if((o=Object.keys(t).length)<=23)this.view.setUint8(160+o);else if(o<=255)this.view.setUint8(184),this.view.setUint8(o);else if(o<=65535)this.view.setUint8(185),this.view.setUint16(o);else{if(!(o<=4294967295))throw w.build(n.OBJECT_TOO_LARGE,{size:o});this.view.setUint8(186),this.view.setUint32(o)}for(var a=0,u=Object.entries(t);a<u.length;a++){var f=u[a],c=f[0],l=f[1];this.write(c),this.write(l)}}},t.prototype.getType=function(t){switch(!0){case void 0===t:return 0;case null===t:return 1;case"boolean"==typeof t:return 2;case"number"==typeof t:return 3;case"bigint"==typeof t:throw w.build(n.UNSUPPORTED_BIGINT);case"string"==typeof t:return 4;case Array.isArray(t):return 5;case"object"==typeof t:return 6;default:throw w.build(n.UNEXPECTED_TOKEN,{token:t})}},t}();function p(t,e,i){var s=i||new ArrayBuffer(1024),r=new _(s);if(e)r.write(t);else try{r.write(t)}catch(t){return null}return r.finalize()}return function(){function t(){}return t.decode=function(t,e){return void 0===e&&(e=!1),function(t,e){if(void 0===e&&(e=!1),e)return new c(new r(t)).parse();try{return new c(new r(t)).parse()}catch(t){return null}}(t,e)},t.encode=function(t,e){return void 0===e&&(e=!1),p(t,e)},t.encodeInto=function(t,e,i){return void 0===i&&(i=!1),p(e,i,t)},t}()}));
{
"name": "@jprochazk/cbor",
"version": "0.4.7",
"version": "0.4.8",
"description": "Partial implementation of RFC 7049 (CBOR)",

@@ -29,16 +29,16 @@ "author": "Jan Procházka",

"devDependencies": {
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-node-resolve": "^8.4.0",
"@types/jest": "^26.0.3",
"@typescript-eslint/eslint-plugin": "^3.2.0",
"@typescript-eslint/parser": "^3.2.0",
"eslint": "^7.2.0",
"jest": "^25.2.1",
"rollup": "^2.23.1",
"rollup-plugin-terser": "^7.0.0",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@types/jest": "^26.0.14",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"eslint": "^7.9.0",
"jest": "^26.4.2",
"rollup": "^2.28.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.27.2",
"ts-jest": "^25.5.0",
"ts-jest": "^26.4.0",
"tslib": "^2.0.1",
"typescript": "^3.9.4"
"typescript": "^4.0.3"
}
}

@@ -60,3 +60,3 @@ [![Build Status](https://travis-ci.com/jprochazk/cbor.svg?branch=master)](https://travis-ci.com/jprochazk/cbor)

Speed was one of my main concerns when writing this library. Benchmark is available [here](https://jsbench.me/krkdop8101/1).
Benchmark is available [here](https://jsbench.me/krkdop8101/1).

@@ -68,12 +68,6 @@ | Browser | CBOR.decode | CBOR.encode | CBOR.encodeInto |

Results are on a i5-8600k intel processor. Your mileage may vary. The JSON data used in the test is 2 KB decoded and 1.8 KB encoded. I specifically chose this data, because it encodes badly (lots of nested objects with only a single property).
Results are on a i5-8600k intel processor. Your mileage may vary. The JSON data used in the test is 2 KB decoded and 1.8 KB encoded. I specifically chose this data, because it encodes badly (lots of nested objects with only a single property). The benchmark suggests the library can encode/decode around 10 MB/s in Chrome and around 50 MB/s in Firefox. Hopefully, these are meaningful results.
The benchmark suggests the library can decode at 13 MB/s and encode at 10 MB/s in Chrome, and around 2.5~4x as much in Firefox. I haven't run the benchmarks in Safari, because I don't have access to any Apple computers.
### Notes
Because of the ArrayBuffer allocation strategy, the CBOR.encode method is pretty much as fast as CBOR.encodeInto. However, you can still find performance gains when encoding very large objects by preallocating a much larger buffer, or when encoding very small objects (<128 bytes) by allocating a smaller buffer.
Minimum supported Node version is 11.
There are a few things from the specification which are currently unimplemented:

@@ -80,0 +74,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc