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

a-msgpack

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-msgpack - npm Package Compare versions

Comparing version 4.3.0 to 4.3.1

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [4.3.1](https://github.com/aristanetworks/cloudvision/compare/v4.3.0...v4.3.1) (2020-07-07)
**Note:** Version bump only for package a-msgpack
# [4.3.0](https://github.com/aristanetworks/cloudvision/compare/v4.2.0...v4.3.0) (2020-06-08)

@@ -8,0 +16,0 @@

404

dist/MsgPack.js

@@ -22,33 +22,30 @@ (function (global, factory) {

// ExtensionCodec to handle MessagePack extensions
let ExtensionCodec = /** @class */ (() => {
class ExtensionCodec {
constructor() {
// custom extensions
this.encoders = [];
this.decoders = [];
}
register({ type, encode, decode, }) {
this.encoders[type] = encode;
this.decoders[type] = decode;
}
tryToEncode(object) {
// custom extensions
for (let i = 0; i < this.encoders.length; i++) {
const encoder = this.encoders[i];
const data = encoder(object);
if (data != null) {
const type = i;
return new ExtData(type, data);
}
class ExtensionCodec {
constructor() {
// custom extensions
this.encoders = [];
this.decoders = [];
}
register({ type, encode, decode, }) {
this.encoders[type] = encode;
this.decoders[type] = decode;
}
tryToEncode(object) {
// custom extensions
for (let i = 0; i < this.encoders.length; i++) {
const encoder = this.encoders[i];
const data = encoder(object);
if (data != null) {
const type = i;
return new ExtData(type, data);
}
return null;
}
decode(data, type) {
const decoder = this.decoders[type];
return decoder(data, type);
}
return null;
}
ExtensionCodec.defaultCodec = new ExtensionCodec();
return ExtensionCodec;
})();
decode(data, type) {
const decoder = this.decoders[type];
return decoder(data, type);
}
}
ExtensionCodec.defaultCodec = new ExtensionCodec();

@@ -64,186 +61,166 @@ /**

// Copyright (c) 2018, Arista Networks, Inc.
let Float32 = /** @class */ (() => {
class Float32 {
/**
* A class to represent an explicit float32
*/
constructor(value) {
this.type = Float32.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
class Float32 {
/**
* A class to represent an explicit float32
*/
constructor(value) {
this.type = Float32.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
Float32.type = 'float32';
return Float32;
})();
let Float64 = /** @class */ (() => {
class Float64 {
/**
* A class to represent an explicit float64
*/
constructor(value) {
this.type = Float64.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
Float64.type = 'float64';
return Float64;
})();
let Int = /** @class */ (() => {
class Int {
/**
* A class to represent an explicit int
*/
constructor(value, forceJSBI = false) {
this.type = Int.type;
if (typeof value === 'string') {
let BI;
if (typeof BigInt === 'undefined' || forceJSBI) {
BI = JSBI.BigInt;
}
else {
BI = BigInt;
}
this.value =
parseInt(value, 10) > Number.MAX_SAFE_INTEGER ||
parseInt(value, 10) < Number.MAX_SAFE_INTEGER * -1
? BI(value)
: parseInt(value, 10);
}
Float32.type = 'float32';
class Float64 {
/**
* A class to represent an explicit float64
*/
constructor(value) {
this.type = Float64.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
}
Float64.type = 'float64';
class Int {
/**
* A class to represent an explicit int
*/
constructor(value, forceJSBI = false) {
this.type = Int.type;
if (typeof value === 'string') {
let BI;
if (typeof BigInt === 'undefined' || forceJSBI) {
BI = JSBI.BigInt;
}
else if (typeof value === 'bigint' || isJsbi(value)) {
this.value = value;
}
else {
this.value = parseInt(String(value), 10);
BI = BigInt;
}
this.value =
parseInt(value, 10) > Number.MAX_SAFE_INTEGER ||
parseInt(value, 10) < Number.MAX_SAFE_INTEGER * -1
? BI(value)
: parseInt(value, 10);
}
toString() {
return this.value.toString();
else if (typeof value === 'bigint' || isJsbi(value)) {
this.value = value;
}
}
Int.type = 'int';
return Int;
})();
let Bool = /** @class */ (() => {
class Bool {
/**
* A class to represent an explicit boolean
*/
constructor(value) {
this.type = Bool.type;
this.value = !!value;
else {
this.value = parseInt(String(value), 10);
}
toString() {
return this.value ? 'true' : 'false';
}
}
Bool.type = 'bool';
return Bool;
})();
let Nil = /** @class */ (() => {
class Nil {
/**
* A class to represent an explicit Nil
*/
constructor() {
this.type = Nil.type;
this.value = null;
}
toString() {
return 'null';
}
toString() {
return this.value.toString();
}
Nil.type = 'nil';
return Nil;
})();
let Str = /** @class */ (() => {
class Str {
/**
* A class to represent an explicit String
*/
constructor(value) {
this.type = Str.type;
switch (typeof value) {
case 'string':
this.value = value;
break;
case 'bigint':
this.value = value.toString();
break;
case 'undefined':
this.value = '';
break;
default:
this.value = JSON.stringify(value);
}
if (isJsbi(value)) {
}
Int.type = 'int';
class Bool {
/**
* A class to represent an explicit boolean
*/
constructor(value) {
this.type = Bool.type;
this.value = !!value;
}
toString() {
return this.value ? 'true' : 'false';
}
}
Bool.type = 'bool';
class Nil {
/**
* A class to represent an explicit Nil
*/
constructor() {
this.type = Nil.type;
this.value = null;
}
toString() {
return 'null';
}
}
Nil.type = 'nil';
class Str {
/**
* A class to represent an explicit String
*/
constructor(value) {
this.type = Str.type;
switch (typeof value) {
case 'string':
this.value = value;
break;
case 'bigint':
this.value = value.toString();
}
break;
case 'undefined':
this.value = '';
break;
default:
this.value = JSON.stringify(value);
}
toString() {
return this.value;
if (isJsbi(value)) {
this.value = value.toString();
}
}
Str.type = 'str';
return Str;
})();
let Pointer = /** @class */ (() => {
class Pointer {
/**
* A class to represent a Pointer type.
* A Pointer is a pointer from one set of path elements to another.
*/
constructor(value = []) {
this.delimiter = '/';
this.type = Pointer.type;
let strValue;
if (!Array.isArray(value)) {
if (typeof value !== 'string') {
strValue = JSON.stringify(value);
}
else {
strValue = value;
}
const ptrArray = strValue.split(this.delimiter);
while (ptrArray[0] === '') {
ptrArray.shift();
}
this.value = ptrArray.map((pathEl) => {
try {
return JSON.parse(pathEl);
}
catch (e) {
// ignore errors, these are just regular strings
}
return pathEl;
});
toString() {
return this.value;
}
}
Str.type = 'str';
class Pointer {
/**
* A class to represent a Pointer type.
* A Pointer is a pointer from one set of path elements to another.
*/
constructor(value = []) {
this.delimiter = '/';
this.type = Pointer.type;
let strValue;
if (!Array.isArray(value)) {
if (typeof value !== 'string') {
strValue = JSON.stringify(value);
}
else {
this.value = value;
strValue = value;
}
}
toString() {
return this.value
.map((pathEl) => {
if (typeof pathEl === 'string') {
return pathEl;
const ptrArray = strValue.split(this.delimiter);
while (ptrArray[0] === '') {
ptrArray.shift();
}
this.value = ptrArray.map((pathEl) => {
try {
return JSON.parse(pathEl);
}
return JSON.stringify(pathEl);
})
.join(this.delimiter);
catch (e) {
// ignore errors, these are just regular strings
}
return pathEl;
});
}
else {
this.value = value;
}
}
Pointer.type = 'ptr';
return Pointer;
})();
toString() {
return this.value
.map((pathEl) => {
if (typeof pathEl === 'string') {
return pathEl;
}
return JSON.stringify(pathEl);
})
.join(this.delimiter);
}
}
Pointer.type = 'ptr';
/* eslint-disable @typescript-eslint/naming-convention */
function isNeatType(value) {

@@ -282,26 +259,23 @@ if (typeof value === 'object' && value !== null) {

}
let NeatTypeSerializer = /** @class */ (() => {
class NeatTypeSerializer {
static serialize(neatTypeInstance) {
return {
__neatTypeClass: neatTypeInstance.type,
value: neatTypeInstance.value,
};
}
static deserialize(serializedNeatType) {
// eslint-disable-next-line no-underscore-dangle
return new NeatTypeSerializer.NEAT_TYPE_MAP[serializedNeatType.__neatTypeClass](serializedNeatType.value);
}
class NeatTypeSerializer {
static serialize(neatTypeInstance) {
return {
__neatTypeClass: neatTypeInstance.type,
value: neatTypeInstance.value,
};
}
NeatTypeSerializer.NEAT_TYPE_MAP = {
float32: Float32,
float64: Float64,
int: Int,
ptr: Pointer,
str: Str,
nil: Nil,
bool: Bool,
};
return NeatTypeSerializer;
})();
static deserialize(serializedNeatType) {
// eslint-disable-next-line no-underscore-dangle
return new NeatTypeSerializer.NEAT_TYPE_MAP[serializedNeatType.__neatTypeClass](serializedNeatType.value);
}
}
NeatTypeSerializer.NEAT_TYPE_MAP = {
float32: Float32,
float64: Float64,
int: Int,
ptr: Pointer,
str: Str,
nil: Nil,
bool: Bool,
};

@@ -1528,3 +1502,3 @@ // DataView extension to handle int64 / uint64,

if (Object.getPrototypeOf(value) === proto) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
// eslint-disable-next-line no-use-before-define
return createTypedMap(value);

@@ -1531,0 +1505,0 @@ }

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jsbi"),require("base64-js")):"function"==typeof define&&define.amd?define(["exports","jsbi","base64-js"],e):e((t=t||self)["a-msgpack"]={},t.jsbi,t.base64Js)}(this,(function(t,e,i){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;class s{constructor(t,e){this.type=t,this.data=e,this.type=t,this.data=e}}let n=(()=>{class t{constructor(){this.encoders=[],this.decoders=[]}register({type:t,encode:e,decode:i}){this.encoders[t]=e,this.decoders[t]=i}tryToEncode(t){for(let e=0;e<this.encoders.length;e++){const i=(0,this.encoders[e])(t);if(null!=i){return new s(e,i)}}return null}decode(t,e){return(0,this.decoders[e])(t,e)}}return t.defaultCodec=new t,t})();function r(t){return Array.isArray(t)&&"__clzmsd"in t}let o=(()=>{class t{constructor(e){this.type=t.type,this.value=e?parseFloat(String(e)):0}toString(){const t=this.value.toString();return t.includes(".")?t:this.value.toFixed(1)}}return t.type="float32",t})(),h=(()=>{class t{constructor(e){this.type=t.type,this.value=e?parseFloat(String(e)):0}toString(){const t=this.value.toString();return t.includes(".")?t:this.value.toFixed(1)}}return t.type="float64",t})(),a=(()=>{class t{constructor(i,s=!1){if(this.type=t.type,"string"==typeof i){let t;t="undefined"==typeof BigInt||s?e.BigInt:BigInt,this.value=parseInt(i,10)>Number.MAX_SAFE_INTEGER||parseInt(i,10)<-1*Number.MAX_SAFE_INTEGER?t(i):parseInt(i,10)}else"bigint"==typeof i||r(i)?this.value=i:this.value=parseInt(String(i),10)}toString(){return this.value.toString()}}return t.type="int",t})(),c=(()=>{class t{constructor(e){this.type=t.type,this.value=!!e}toString(){return this.value?"true":"false"}}return t.type="bool",t})(),u=(()=>{class t{constructor(){this.type=t.type,this.value=null}toString(){return"null"}}return t.type="nil",t})(),f=(()=>{class t{constructor(e){switch(this.type=t.type,typeof e){case"string":this.value=e;break;case"bigint":this.value=e.toString();break;case"undefined":this.value="";break;default:this.value=JSON.stringify(e)}r(e)&&(this.value=e.toString())}toString(){return this.value}}return t.type="str",t})(),l=(()=>{class t{constructor(e=[]){let i;if(this.delimiter="/",this.type=t.type,Array.isArray(e))this.value=e;else{i="string"!=typeof e?JSON.stringify(e):e;const t=i.split(this.delimiter);for(;""===t[0];)t.shift();this.value=t.map(t=>{try{return JSON.parse(t)}catch(t){}return t})}}toString(){return this.value.map(t=>"string"==typeof t?t:JSON.stringify(t)).join(this.delimiter)}}return t.type="ptr",t})();function d(t){if("object"==typeof t&&null!==t){if(2===Object.keys(t).length&&"type"in t&&"value"in t){const e=t;return[c.type,o.type,h.type,a.type,u.type,f.type].includes(e.type)}if(3===Object.keys(t).length&&"type"in t&&"value"in t&&"delimiter"in t){return t.type===l.type}}return!1}function p(t,e){return function(t,e){const i=Math.min(t.length,e.length);if(t===e)return 0;for(let s=0;s<i;s+=1)if(t[s]!==e[s])return t[s]-e[s];return t.length-e.length}(t[0],e[0])}let y=(()=>{class t{static serialize(t){return{__neatTypeClass:t.type,value:t.value}}static deserialize(e){return new t.NEAT_TYPE_MAP[e.__neatTypeClass](e.value)}}return t.NEAT_TYPE_MAP={float32:o,float64:h,int:a,ptr:l,str:f,nil:u,bool:c},t})();function g(t,e,i){let s=t,n=e;const r=!i&&2147483648&t;r&&(s=~t,n=4294967296-e);let o="";for(;;){const t=s%10*4294967296+n;if(s=Math.floor(s/10),n=Math.floor(t/10),o=(t%10).toString(10)+o,!s&&!n)break}return r&&(o="-"+o),o}function w(t,e,i){let s=0;const n=i.length;let r=0,o=0;"-"===i[0]&&s++;const h=s;for(;s<n;){const t=parseInt(i[s++],10);if(Number.isNaN(t)||t<0)break;o=10*o+t,r=10*r+Math.floor(o/4294967296),o%=4294967296}h&&(r=~r,o?o=4294967296-o:r++),t.setUint32(e,r),t.setUint32(e+4,o)}function U(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer?new Uint8Array(t):Uint8Array.from(t)}const b="never"!==process.env.TEXT_ENCODING&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function S(t){const e=t.length;let i=0,s=0;for(;s<e;){let n=t.charCodeAt(s++);if(0!=(4294967168&n))if(0==(4294965248&n))i+=2;else{if(n>=55296&&n<=56319&&s<e){const e=t.charCodeAt(s);56320==(64512&e)&&(++s,n=((1023&n)<<10)+(1023&e)+65536)}i+=0==(4294901760&n)?3:4}else i++}return i}const x=b?new TextEncoder:void 0,v="force"!==process.env.TEXT_ENCODING?200:0;const B=(null==x?void 0:x.encodeInto)?function(t,e,i){x.encodeInto(t,e.subarray(i))}:function(t,e,i){e.set(x.encode(t),i)};function m(t,e,i){let s=e;const n=s+i,r=[];let o="";for(;s<n;){const e=t[s++];if(0==(128&e))r.push(e);else if(192==(224&e)){const i=63&t[s++];r.push((31&e)<<6|i)}else if(224==(240&e)){const i=63&t[s++],n=63&t[s++];r.push((31&e)<<12|i<<6|n)}else if(240==(248&e)){let i=(7&e)<<18|(63&t[s++])<<12|(63&t[s++])<<6|63&t[s++];i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i)}else r.push(e);r.length>=4096&&(o+=String.fromCharCode(...r),r.length=0)}return r.length>0&&(o+=String.fromCharCode(...r)),o}const I=b?new TextDecoder:null,E="force"!==process.env.TEXT_DECODER?200:0;class A{constructor(t=n.defaultCodec,e=100,i=2048){this.pos=0,this.extensionCodec=t,this.maxDepth=e,this.initialBufferSize=i,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}keyEncoder(t,e){const i=new A(this.extensionCodec,this.maxDepth,this.initialBufferSize);return i.encode(t,e),i.getUint8Array()}encode(t,e){if(e>this.maxDepth)throw new Error("Too deep objects in depth "+e);null==t?this.encodeNil():"boolean"==typeof t?this.encodeBoolean(t):"number"==typeof t?this.encodeNumber(t):"string"==typeof t?this.encodeString(t):this.encodeObject(t,e)}getUint8Array(){return this.bytes.subarray(0,this.pos)}ensureBufferSizeToWrite(t){const e=this.pos+t;this.view.byteLength<e&&this.resizeBuffer(2*e)}resizeBuffer(t){const e=new ArrayBuffer(t),i=new Uint8Array(e),s=new DataView(e);i.set(this.bytes),this.view=s,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(t){!1===t?this.writeU8(194):this.writeU8(195)}encodeNumber(t){Number.isSafeInteger(t)?t>=0?t<128?this.writeU8(t):t<256?(this.writeU8(204),this.writeU8(t)):t<65536?(this.writeU8(205),this.writeU16(t)):t<4294967296?(this.writeU8(206),this.writeU32(t)):(this.writeU8(207),this.writeU64(t)):t>=-32?this.writeU8(224|t+32):t>=-128?(this.writeU8(208),this.writeI8(t)):t>=-32768?(this.writeU8(209),this.writeI16(t)):t>=-2147483648?(this.writeU8(210),this.writeI32(t)):(this.writeU8(211),this.writeI64(t)):(this.writeU8(203),this.writeF64(t))}writeStringHeader(t){t<256?(this.writeU8(196),this.writeU8(t)):t<65536?(this.writeU8(197),this.writeU16(t)):(this.writeU8(198),this.writeU32(t))}encodeString(t){const e=t.length;if(b&&e>v){const e=S(t);this.ensureBufferSizeToWrite(5+e),this.writeStringHeader(e),B(t,this.bytes,this.pos),this.pos+=e}else{const e=S(t);this.ensureBufferSizeToWrite(5+e),this.writeStringHeader(e),function(t,e,i){const s=t.length;let n=i,r=0;for(;r<s;){let i=t.charCodeAt(r++);if(0!=(4294967168&i)){if(0==(4294965248&i))e[n++]=i>>6&31|192;else{if(i>=55296&&i<=56319&&r<s){const e=t.charCodeAt(r);56320==(64512&e)&&(++r,i=((1023&i)<<10)+(1023&e)+65536)}0==(4294901760&i)?(e[n++]=i>>12&15|224,e[n++]=i>>6&63|128):(e[n++]=i>>18&7|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128)}e[n++]=63&i|128}else e[n++]=i}}(t,this.bytes,this.pos),this.pos+=e}}encodeObject(t,e){const i=this.extensionCodec.tryToEncode(t);if(null!=i)this.encodeExtension(i);else if(Array.isArray(t))r(t)?this.encodeJSBI(t):this.encodeArray(t,e);else if(ArrayBuffer.isView(t))this.encodeBinary(t);else if("bigint"==typeof t)this.encodeBigInt(t);else if(t instanceof Map)this.encodeMap(t,e);else if("object"==typeof t)d(t)?this.encodeNeatClass(t):this.encodePlainObject(t,e);else{if("function"!=typeof t)throw new Error("Unrecognized object: "+Object.prototype.toString.apply(t));this.encodeNil()}}encodeNeatClass(t){t instanceof o?(this.writeU8(202),this.writeF32(t.value)):t instanceof h?(this.writeU8(203),this.writeF64(t.value)):t instanceof a?"bigint"==typeof t.value?this.encodeBigInt(t.value):r(t.value)?this.encodeJSBI(t.value):this.encodeNumber(t.value):t instanceof f?this.encodeString(t.value):t instanceof c?this.encodeBoolean(t.value):this.encodeNil()}encodeBigInt(t){t===BigInt(0)||BigInt.asIntN(32,t)>0||t<0&&BigInt.asUintN(32,t)===t*BigInt(-1)?this.encodeNumber(Number(t)):t<0?(this.writeU8(211),this.writeI64(t)):(this.writeU8(207),this.writeU64(t))}encodeJSBI(t){const i=t.toString();"0"===i||e.LE(t,2147483647)&&e.GE(t,-4294967295)||i<"0"&&e.GE(t,-4294967295)?this.encodeNumber(Number(t)):i<"0"?(this.writeU8(211),this.writeI64(i)):(this.writeU8(207),this.writeU64(i))}encodeBinary(t){const e=t.byteLength;e<256?(this.writeU8(196),this.writeU8(e)):e<65536?(this.writeU8(197),this.writeU16(e)):(this.writeU8(198),this.writeU32(e));const i=U(t);this.writeU8a(i)}encodeArray(t,e){const i=t.length;i<16?this.writeU8(144+i):i<65536?(this.writeU8(220),this.writeU16(i)):(this.writeU8(221),this.writeU32(i));for(const i of t)this.encode(i,e+1)}encodeMap(t,e){const i=t.size,s=[];i<16?this.writeU8(128+i):i<65536?(this.writeU8(222),this.writeU16(i)):(this.writeU8(223),this.writeU32(i)),t.forEach((t,i)=>{const n=this.keyEncoder(i,e+1);s.push([n,t])}),s.sort(p),s.forEach(t=>{this.writeU8a(t[0]),this.encode(t[1],e+1)})}encodePlainObject(t,e){this.encodeMap(new Map(Object.entries(t)),e)}encodeExtension(t){const e=t.data.length;1===e?this.writeU8(212):2===e?this.writeU8(213):4===e?this.writeU8(214):8===e?this.writeU8(215):16===e?this.writeU8(216):e<256?(this.writeU8(199),this.writeU8(e)):e<65536?(this.writeU8(200),this.writeU16(e)):(this.writeU8(201),this.writeU32(e)),this.writeI8(t.type),this.writeU8a(t.data)}writeU8(t){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,t),this.pos++}writeU8a(t){const e=t.length;this.ensureBufferSizeToWrite(e),this.bytes.set(t,this.pos),this.pos+=e}writeI8(t){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,t),this.pos++}writeU16(t){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,t),this.pos+=2}writeI16(t){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,t),this.pos+=2}writeU32(t){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,t),this.pos+=4}writeI32(t){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,t),this.pos+=4}writeF32(t){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,t),this.pos+=4}writeF64(t){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,t),this.pos+=8}writeU64(t){this.ensureBufferSizeToWrite(8),function(t,e,i){if("number"==typeof i){const s=i/4294967296,n=i;t.setUint32(e,s),t.setUint32(e+4,n)}else"bigint"==typeof i?t.setBigUint64(e,i):"string"==typeof i&&w(t,e,i)}(this.view,this.pos,t),this.pos+=8}writeI64(t){this.ensureBufferSizeToWrite(8),function(t,e,i){if("number"==typeof i){const s=Math.floor(i/4294967296),n=i;t.setUint32(e,s),t.setUint32(e+4,n)}else"bigint"==typeof i?t.setBigInt64(e,i):"string"==typeof i&&w(t,e,i)}(this.view,this.pos,t),this.pos+=8}}const N={};function T(t,e=N){const i=new A(e.extensionCodec,e.maxDepth,e.initialBufferSize);return i.encode(t,1),i.getUint8Array()}const L=t=>"string"===typeof t,k=new DataView(new ArrayBuffer(0)),z=new Uint8Array(k.buffer),C=new class{constructor(t=16,e=16){this.maxKeyLength=t,this.maxLengthPerKey=e,this.caches=[];for(let t=0;t<this.maxKeyLength;t++)this.caches.push([])}canBeCached(t){return t>0&&t<=this.maxKeyLength}get(t,e,i){const s=this.caches[i-1],n=s.length;t:for(let r=0;r<n;r++){const n=s[r],o=n.bytes;for(let s=0;s<i;s++)if(o[s]!==t[e+s])continue t;return n.value}return null}store(t,e){const i=this.caches[t.length-1],s={bytes:t,value:e};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=s:i.push(s)}decode(t,e,i){const s=this.get(t,e,i);if(s)return s;const n=m(t,e,i),r=Uint8Array.prototype.slice.call(t,e,e+i);return this.store(r,n),n}};class M{constructor(t=n.defaultCodec,e=!1,i=4294967295,s=4294967295,r=4294967295,o=4294967295,h=4294967295,a=C){this.totalPos=0,this.pos=0,this.view=k,this.bytes=z,this.stack=[],this.extensionCodec=t,this.cachedKeyDecoder=a,this.useJSBI=e,this.maxStrLength=i,this.maxBinLength=s,this.maxArrayLength=r,this.maxMapLength=o,this.maxExtLength=h}setBuffer(t){this.bytes=U(t),this.view=function(t){if(t instanceof ArrayBuffer)return new DataView(t);const e=U(t);return new DataView(e.buffer,e.byteOffset,e.byteLength)}(this.bytes),this.pos=0}hasRemaining(t=1){return this.view.byteLength-this.pos>=t}createNoExtraBytesError(t){const{view:e,pos:i}=this;return new RangeError(`Extra ${e.byteLength-i} byte(s) found at buffer[${t}]`)}decodeSingleSync(){const t=this.decodeSync();if(this.hasRemaining())throw this.createNoExtraBytesError(this.pos);return t}decodeSync(){t:for(;;){const e=this.readU8();let s;if(e>=224)s=e-256;else if(e<192)if(e<128)s=e;else if(e<144){const t=e-128;if(0!==t){this.pushMapState(t);continue t}s={}}else{const t=e-144;if(0!==t){this.pushArrayState(t);continue t}s=[]}else if(192===e)s=null;else if(194===e)s=!1;else if(195===e)s=!0;else if(202===e)s=this.readF32();else if(203===e)s=this.readF64();else if(204===e)s=this.readU8();else if(205===e)s=this.readU16();else if(206===e)s=this.readU32();else if(207===e)s=this.readU64();else if(208===e)s=this.readI8();else if(209===e)s=this.readI16();else if(210===e)s=this.readI32();else if(211===e)s=this.readI64();else{if(220===e){const t=this.readU16();this.pushArrayState(t);continue t}if(221===e){const t=this.readU32();this.pushArrayState(t);continue t}if(222===e){const t=this.readU16();this.pushMapState(t);continue t}if(223===e){const t=this.readU32();this.pushMapState(t);continue t}if(196===e){const t=this.lookU8();s=this.decodeUtf8String(t,1)}else if(197===e){const t=this.lookU16();s=this.decodeUtf8String(t,2)}else if(198===e){const t=this.lookU32();s=this.decodeUtf8String(t,4)}else if(212===e)s=this.decodeExtension(1,0);else if(213===e)s=this.decodeExtension(2,0);else if(214===e)s=this.decodeExtension(4,0);else if(215===e)s=this.decodeExtension(8,0);else if(216===e)s=this.decodeExtension(16,0);else if(199===e){const t=this.lookU8();s=this.decodeExtension(t,1)}else if(200===e){const t=this.lookU16();s=this.decodeExtension(t,2)}else{if(201!==e)throw new Error("Unrecognized type byte: "+`${(t=e)<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`);{const t=this.lookU32();s=this.decodeExtension(t,4)}}}const n=this.stack;for(;n.length>0;){const t=n[n.length-1];if(0===t.type){if(t.array[t.position]=s,t.position++,t.position!==t.size)continue t;n.pop(),s=t.array}else{if(1===t.type){L(s)||(t.serializedKey=i.fromByteArray(this.bytes.slice(t.keyStart,this.pos))),t.key=s,t.type=2;continue t}if(L(t.key)?t.map[t.key]=s:t.map[t.serializedKey]={_key:t.key,_value:s},t.readCount++,t.readCount!==t.size){t.key=null,t.type=1,n[n.length-1].keyStart=this.pos;continue t}n.pop(),s=t.map}}return s}var t}pushMapState(t){if(t>this.maxMapLength)throw new Error(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.push({type:1,size:t,keyStart:1,key:null,serializedKey:null,readCount:0,map:{}})}pushArrayState(t){if(t>this.maxArrayLength)throw new Error(`Max length exceeded: array length (${t}) > maxArrayLength (${this.maxArrayLength})`);this.stack.push({type:0,size:t,keyStart:1,array:new Array(t),position:0})}decodeUtf8String(t,e){var i;if(t>this.maxStrLength)throw new Error(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+e+t)throw new RangeError("Insufficient data");const s=this.pos+e;let n;return n=this.stateIsMapKey()&&(null===(i=this.cachedKeyDecoder)||void 0===i?void 0:i.canBeCached(t))?this.cachedKeyDecoder.decode(this.bytes,s,t):b&&t>E?function(t,e,i){const s=t.subarray(e,e+i);return I.decode(s)}(this.bytes,s,t):m(this.bytes,s,t),this.pos+=e+t,n}stateIsMapKey(){if(this.stack.length>0){return 1===this.stack[this.stack.length-1].type}return!1}decodeBinary(t,e){if(t>this.maxBinLength)throw new Error(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+e))throw new RangeError("Insufficient data");const i=this.pos+e,s=this.bytes.subarray(i,i+t);return this.pos+=e+t,s}decodeExtension(t,e){if(t>this.maxExtLength)throw new Error(`Max length exceeded: ext length (${t}) > maxExtLength (${this.maxExtLength})`);const i=this.view.getInt8(this.pos+e),s=this.decodeBinary(t,e+1);return this.extensionCodec.decode(s,i)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const t=this.view.getUint8(this.pos);return this.pos++,t}readI8(){const t=this.view.getInt8(this.pos);return this.pos++,t}readU16(){const t=this.view.getUint16(this.pos);return this.pos+=2,t}readI16(){const t=this.view.getInt16(this.pos);return this.pos+=2,t}readU32(){const t=this.view.getUint32(this.pos);return this.pos+=4,t}readI32(){const t=this.view.getInt32(this.pos);return this.pos+=4,t}readU64(){const t=function(t,i,s){if(!t.getBigUint64||s){const s=t.getUint32(i),n=t.getUint32(i+4);return e.BigInt(g(s,n,!0))}return t.getBigUint64(i)}(this.view,this.pos,this.useJSBI);return this.pos+=8,t}readI64(){const t=function(t,i,s){if(!t.getBigInt64||s){const s=t.getInt32(i),n=t.getUint32(i+4);return e.BigInt(g(s,n,!1))}return t.getBigInt64(i)}(this.view,this.pos,this.useJSBI);return this.pos+=8,t}readF32(){const t=this.view.getFloat32(this.pos);return this.pos+=4,t}readF64(){const t=this.view.getFloat64(this.pos);return this.pos+=8,t}}const O={};function j(t,e=O){const i=new M(e.extensionCodec,e.useJSBI,e.maxStrLength,e.maxBinLength,e.maxArrayLength,e.maxMapLength,e.maxExtLength,e.cachedKeyDecoder);return i.setBuffer(t),i.decodeSingleSync()}function F(t){const e=typeof t;if("number"===e){return String(t).split(".").length>1?new h(t):new a(t)}if("boolean"===e)return new c(t);if("string"===e)return new f(t);if(null!==t&&"object"===e){let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);if(Object.getPrototypeOf(t)===e)return function(t){const e=new Map,i=Object.keys(t);for(let s=0;s<i.length;s+=1){const n=i[s],r=t[n],o=F(n),h=F(r);e.set(o,h)}return e}(t)}return new u}const _={Bool:c,Float32:o,Float64:h,Int:a,Nil:u,Pointer:l,Str:f},D=new n;var P;D.register({type:0,encode:(P=D,t=>t instanceof l?T(t.value,{extensionCodec:P}):null),decode:function(t){return e=>{const i=j(e,{extensionCodec:t});return Array.isArray(i)?new l(i):new l}}(D)}),t.Bool=c,t.Codec=D,t.ExtData=s,t.ExtensionCodec=n,t.Float32=o,t.Float64=h,t.Int=a,t.NeatTypeSerializer=y,t.NeatTypes=_,t.Nil=u,t.Pointer=l,t.Str=f,t.createBaseType=F,t.decode=j,t.encode=T,t.isJsbi=r,t.isNeatType=d,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jsbi"),require("base64-js")):"function"==typeof define&&define.amd?define(["exports","jsbi","base64-js"],e):e((t=t||self)["a-msgpack"]={},t.jsbi,t.base64Js)}(this,(function(t,e,i){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;class s{constructor(t,e){this.type=t,this.data=e,this.type=t,this.data=e}}class n{constructor(){this.encoders=[],this.decoders=[]}register({type:t,encode:e,decode:i}){this.encoders[t]=e,this.decoders[t]=i}tryToEncode(t){for(let e=0;e<this.encoders.length;e++){const i=(0,this.encoders[e])(t);if(null!=i){return new s(e,i)}}return null}decode(t,e){return(0,this.decoders[e])(t,e)}}function r(t){return Array.isArray(t)&&"__clzmsd"in t}n.defaultCodec=new n;class o{constructor(t){this.type=o.type,this.value=t?parseFloat(String(t)):0}toString(){const t=this.value.toString();return t.includes(".")?t:this.value.toFixed(1)}}o.type="float32";class h{constructor(t){this.type=h.type,this.value=t?parseFloat(String(t)):0}toString(){const t=this.value.toString();return t.includes(".")?t:this.value.toFixed(1)}}h.type="float64";class a{constructor(t,i=!1){if(this.type=a.type,"string"==typeof t){let s;s="undefined"==typeof BigInt||i?e.BigInt:BigInt,this.value=parseInt(t,10)>Number.MAX_SAFE_INTEGER||parseInt(t,10)<-1*Number.MAX_SAFE_INTEGER?s(t):parseInt(t,10)}else"bigint"==typeof t||r(t)?this.value=t:this.value=parseInt(String(t),10)}toString(){return this.value.toString()}}a.type="int";class c{constructor(t){this.type=c.type,this.value=!!t}toString(){return this.value?"true":"false"}}c.type="bool";class u{constructor(){this.type=u.type,this.value=null}toString(){return"null"}}u.type="nil";class f{constructor(t){switch(this.type=f.type,typeof t){case"string":this.value=t;break;case"bigint":this.value=t.toString();break;case"undefined":this.value="";break;default:this.value=JSON.stringify(t)}r(t)&&(this.value=t.toString())}toString(){return this.value}}f.type="str";class l{constructor(t=[]){let e;if(this.delimiter="/",this.type=l.type,Array.isArray(t))this.value=t;else{e="string"!=typeof t?JSON.stringify(t):t;const i=e.split(this.delimiter);for(;""===i[0];)i.shift();this.value=i.map(t=>{try{return JSON.parse(t)}catch(t){}return t})}}toString(){return this.value.map(t=>"string"==typeof t?t:JSON.stringify(t)).join(this.delimiter)}}function d(t){if("object"==typeof t&&null!==t){if(2===Object.keys(t).length&&"type"in t&&"value"in t){const e=t;return[c.type,o.type,h.type,a.type,u.type,f.type].includes(e.type)}if(3===Object.keys(t).length&&"type"in t&&"value"in t&&"delimiter"in t){return t.type===l.type}}return!1}function p(t,e){return function(t,e){const i=Math.min(t.length,e.length);if(t===e)return 0;for(let s=0;s<i;s+=1)if(t[s]!==e[s])return t[s]-e[s];return t.length-e.length}(t[0],e[0])}l.type="ptr";class y{static serialize(t){return{__neatTypeClass:t.type,value:t.value}}static deserialize(t){return new y.NEAT_TYPE_MAP[t.__neatTypeClass](t.value)}}function g(t,e,i){let s=t,n=e;const r=!i&&2147483648&t;r&&(s=~t,n=4294967296-e);let o="";for(;;){const t=s%10*4294967296+n;if(s=Math.floor(s/10),n=Math.floor(t/10),o=(t%10).toString(10)+o,!s&&!n)break}return r&&(o="-"+o),o}function w(t,e,i){let s=0;const n=i.length;let r=0,o=0;"-"===i[0]&&s++;const h=s;for(;s<n;){const t=parseInt(i[s++],10);if(Number.isNaN(t)||t<0)break;o=10*o+t,r=10*r+Math.floor(o/4294967296),o%=4294967296}h&&(r=~r,o?o=4294967296-o:r++),t.setUint32(e,r),t.setUint32(e+4,o)}function U(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer?new Uint8Array(t):Uint8Array.from(t)}y.NEAT_TYPE_MAP={float32:o,float64:h,int:a,ptr:l,str:f,nil:u,bool:c};const b="never"!==process.env.TEXT_ENCODING&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder;function S(t){const e=t.length;let i=0,s=0;for(;s<e;){let n=t.charCodeAt(s++);if(0!=(4294967168&n))if(0==(4294965248&n))i+=2;else{if(n>=55296&&n<=56319&&s<e){const e=t.charCodeAt(s);56320==(64512&e)&&(++s,n=((1023&n)<<10)+(1023&e)+65536)}i+=0==(4294901760&n)?3:4}else i++}return i}const x=b?new TextEncoder:void 0,v="force"!==process.env.TEXT_ENCODING?200:0;const B=(null==x?void 0:x.encodeInto)?function(t,e,i){x.encodeInto(t,e.subarray(i))}:function(t,e,i){e.set(x.encode(t),i)};function m(t,e,i){let s=e;const n=s+i,r=[];let o="";for(;s<n;){const e=t[s++];if(0==(128&e))r.push(e);else if(192==(224&e)){const i=63&t[s++];r.push((31&e)<<6|i)}else if(224==(240&e)){const i=63&t[s++],n=63&t[s++];r.push((31&e)<<12|i<<6|n)}else if(240==(248&e)){let i=(7&e)<<18|(63&t[s++])<<12|(63&t[s++])<<6|63&t[s++];i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i)}else r.push(e);r.length>=4096&&(o+=String.fromCharCode(...r),r.length=0)}return r.length>0&&(o+=String.fromCharCode(...r)),o}const I=b?new TextDecoder:null,E="force"!==process.env.TEXT_DECODER?200:0;class A{constructor(t=n.defaultCodec,e=100,i=2048){this.pos=0,this.extensionCodec=t,this.maxDepth=e,this.initialBufferSize=i,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}keyEncoder(t,e){const i=new A(this.extensionCodec,this.maxDepth,this.initialBufferSize);return i.encode(t,e),i.getUint8Array()}encode(t,e){if(e>this.maxDepth)throw new Error("Too deep objects in depth "+e);null==t?this.encodeNil():"boolean"==typeof t?this.encodeBoolean(t):"number"==typeof t?this.encodeNumber(t):"string"==typeof t?this.encodeString(t):this.encodeObject(t,e)}getUint8Array(){return this.bytes.subarray(0,this.pos)}ensureBufferSizeToWrite(t){const e=this.pos+t;this.view.byteLength<e&&this.resizeBuffer(2*e)}resizeBuffer(t){const e=new ArrayBuffer(t),i=new Uint8Array(e),s=new DataView(e);i.set(this.bytes),this.view=s,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(t){!1===t?this.writeU8(194):this.writeU8(195)}encodeNumber(t){Number.isSafeInteger(t)?t>=0?t<128?this.writeU8(t):t<256?(this.writeU8(204),this.writeU8(t)):t<65536?(this.writeU8(205),this.writeU16(t)):t<4294967296?(this.writeU8(206),this.writeU32(t)):(this.writeU8(207),this.writeU64(t)):t>=-32?this.writeU8(224|t+32):t>=-128?(this.writeU8(208),this.writeI8(t)):t>=-32768?(this.writeU8(209),this.writeI16(t)):t>=-2147483648?(this.writeU8(210),this.writeI32(t)):(this.writeU8(211),this.writeI64(t)):(this.writeU8(203),this.writeF64(t))}writeStringHeader(t){t<256?(this.writeU8(196),this.writeU8(t)):t<65536?(this.writeU8(197),this.writeU16(t)):(this.writeU8(198),this.writeU32(t))}encodeString(t){const e=t.length;if(b&&e>v){const e=S(t);this.ensureBufferSizeToWrite(5+e),this.writeStringHeader(e),B(t,this.bytes,this.pos),this.pos+=e}else{const e=S(t);this.ensureBufferSizeToWrite(5+e),this.writeStringHeader(e),function(t,e,i){const s=t.length;let n=i,r=0;for(;r<s;){let i=t.charCodeAt(r++);if(0!=(4294967168&i)){if(0==(4294965248&i))e[n++]=i>>6&31|192;else{if(i>=55296&&i<=56319&&r<s){const e=t.charCodeAt(r);56320==(64512&e)&&(++r,i=((1023&i)<<10)+(1023&e)+65536)}0==(4294901760&i)?(e[n++]=i>>12&15|224,e[n++]=i>>6&63|128):(e[n++]=i>>18&7|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128)}e[n++]=63&i|128}else e[n++]=i}}(t,this.bytes,this.pos),this.pos+=e}}encodeObject(t,e){const i=this.extensionCodec.tryToEncode(t);if(null!=i)this.encodeExtension(i);else if(Array.isArray(t))r(t)?this.encodeJSBI(t):this.encodeArray(t,e);else if(ArrayBuffer.isView(t))this.encodeBinary(t);else if("bigint"==typeof t)this.encodeBigInt(t);else if(t instanceof Map)this.encodeMap(t,e);else if("object"==typeof t)d(t)?this.encodeNeatClass(t):this.encodePlainObject(t,e);else{if("function"!=typeof t)throw new Error("Unrecognized object: "+Object.prototype.toString.apply(t));this.encodeNil()}}encodeNeatClass(t){t instanceof o?(this.writeU8(202),this.writeF32(t.value)):t instanceof h?(this.writeU8(203),this.writeF64(t.value)):t instanceof a?"bigint"==typeof t.value?this.encodeBigInt(t.value):r(t.value)?this.encodeJSBI(t.value):this.encodeNumber(t.value):t instanceof f?this.encodeString(t.value):t instanceof c?this.encodeBoolean(t.value):this.encodeNil()}encodeBigInt(t){t===BigInt(0)||BigInt.asIntN(32,t)>0||t<0&&BigInt.asUintN(32,t)===t*BigInt(-1)?this.encodeNumber(Number(t)):t<0?(this.writeU8(211),this.writeI64(t)):(this.writeU8(207),this.writeU64(t))}encodeJSBI(t){const i=t.toString();"0"===i||e.LE(t,2147483647)&&e.GE(t,-4294967295)||i<"0"&&e.GE(t,-4294967295)?this.encodeNumber(Number(t)):i<"0"?(this.writeU8(211),this.writeI64(i)):(this.writeU8(207),this.writeU64(i))}encodeBinary(t){const e=t.byteLength;e<256?(this.writeU8(196),this.writeU8(e)):e<65536?(this.writeU8(197),this.writeU16(e)):(this.writeU8(198),this.writeU32(e));const i=U(t);this.writeU8a(i)}encodeArray(t,e){const i=t.length;i<16?this.writeU8(144+i):i<65536?(this.writeU8(220),this.writeU16(i)):(this.writeU8(221),this.writeU32(i));for(const i of t)this.encode(i,e+1)}encodeMap(t,e){const i=t.size,s=[];i<16?this.writeU8(128+i):i<65536?(this.writeU8(222),this.writeU16(i)):(this.writeU8(223),this.writeU32(i)),t.forEach((t,i)=>{const n=this.keyEncoder(i,e+1);s.push([n,t])}),s.sort(p),s.forEach(t=>{this.writeU8a(t[0]),this.encode(t[1],e+1)})}encodePlainObject(t,e){this.encodeMap(new Map(Object.entries(t)),e)}encodeExtension(t){const e=t.data.length;1===e?this.writeU8(212):2===e?this.writeU8(213):4===e?this.writeU8(214):8===e?this.writeU8(215):16===e?this.writeU8(216):e<256?(this.writeU8(199),this.writeU8(e)):e<65536?(this.writeU8(200),this.writeU16(e)):(this.writeU8(201),this.writeU32(e)),this.writeI8(t.type),this.writeU8a(t.data)}writeU8(t){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,t),this.pos++}writeU8a(t){const e=t.length;this.ensureBufferSizeToWrite(e),this.bytes.set(t,this.pos),this.pos+=e}writeI8(t){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,t),this.pos++}writeU16(t){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,t),this.pos+=2}writeI16(t){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,t),this.pos+=2}writeU32(t){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,t),this.pos+=4}writeI32(t){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,t),this.pos+=4}writeF32(t){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,t),this.pos+=4}writeF64(t){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,t),this.pos+=8}writeU64(t){this.ensureBufferSizeToWrite(8),function(t,e,i){if("number"==typeof i){const s=i/4294967296,n=i;t.setUint32(e,s),t.setUint32(e+4,n)}else"bigint"==typeof i?t.setBigUint64(e,i):"string"==typeof i&&w(t,e,i)}(this.view,this.pos,t),this.pos+=8}writeI64(t){this.ensureBufferSizeToWrite(8),function(t,e,i){if("number"==typeof i){const s=Math.floor(i/4294967296),n=i;t.setUint32(e,s),t.setUint32(e+4,n)}else"bigint"==typeof i?t.setBigInt64(e,i):"string"==typeof i&&w(t,e,i)}(this.view,this.pos,t),this.pos+=8}}const N={};function T(t,e=N){const i=new A(e.extensionCodec,e.maxDepth,e.initialBufferSize);return i.encode(t,1),i.getUint8Array()}const L=t=>"string"===typeof t,k=new DataView(new ArrayBuffer(0)),z=new Uint8Array(k.buffer),C=new class{constructor(t=16,e=16){this.maxKeyLength=t,this.maxLengthPerKey=e,this.caches=[];for(let t=0;t<this.maxKeyLength;t++)this.caches.push([])}canBeCached(t){return t>0&&t<=this.maxKeyLength}get(t,e,i){const s=this.caches[i-1],n=s.length;t:for(let r=0;r<n;r++){const n=s[r],o=n.bytes;for(let s=0;s<i;s++)if(o[s]!==t[e+s])continue t;return n.value}return null}store(t,e){const i=this.caches[t.length-1],s={bytes:t,value:e};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=s:i.push(s)}decode(t,e,i){const s=this.get(t,e,i);if(s)return s;const n=m(t,e,i),r=Uint8Array.prototype.slice.call(t,e,e+i);return this.store(r,n),n}};class M{constructor(t=n.defaultCodec,e=!1,i=4294967295,s=4294967295,r=4294967295,o=4294967295,h=4294967295,a=C){this.totalPos=0,this.pos=0,this.view=k,this.bytes=z,this.stack=[],this.extensionCodec=t,this.cachedKeyDecoder=a,this.useJSBI=e,this.maxStrLength=i,this.maxBinLength=s,this.maxArrayLength=r,this.maxMapLength=o,this.maxExtLength=h}setBuffer(t){this.bytes=U(t),this.view=function(t){if(t instanceof ArrayBuffer)return new DataView(t);const e=U(t);return new DataView(e.buffer,e.byteOffset,e.byteLength)}(this.bytes),this.pos=0}hasRemaining(t=1){return this.view.byteLength-this.pos>=t}createNoExtraBytesError(t){const{view:e,pos:i}=this;return new RangeError(`Extra ${e.byteLength-i} byte(s) found at buffer[${t}]`)}decodeSingleSync(){const t=this.decodeSync();if(this.hasRemaining())throw this.createNoExtraBytesError(this.pos);return t}decodeSync(){t:for(;;){const e=this.readU8();let s;if(e>=224)s=e-256;else if(e<192)if(e<128)s=e;else if(e<144){const t=e-128;if(0!==t){this.pushMapState(t);continue t}s={}}else{const t=e-144;if(0!==t){this.pushArrayState(t);continue t}s=[]}else if(192===e)s=null;else if(194===e)s=!1;else if(195===e)s=!0;else if(202===e)s=this.readF32();else if(203===e)s=this.readF64();else if(204===e)s=this.readU8();else if(205===e)s=this.readU16();else if(206===e)s=this.readU32();else if(207===e)s=this.readU64();else if(208===e)s=this.readI8();else if(209===e)s=this.readI16();else if(210===e)s=this.readI32();else if(211===e)s=this.readI64();else{if(220===e){const t=this.readU16();this.pushArrayState(t);continue t}if(221===e){const t=this.readU32();this.pushArrayState(t);continue t}if(222===e){const t=this.readU16();this.pushMapState(t);continue t}if(223===e){const t=this.readU32();this.pushMapState(t);continue t}if(196===e){const t=this.lookU8();s=this.decodeUtf8String(t,1)}else if(197===e){const t=this.lookU16();s=this.decodeUtf8String(t,2)}else if(198===e){const t=this.lookU32();s=this.decodeUtf8String(t,4)}else if(212===e)s=this.decodeExtension(1,0);else if(213===e)s=this.decodeExtension(2,0);else if(214===e)s=this.decodeExtension(4,0);else if(215===e)s=this.decodeExtension(8,0);else if(216===e)s=this.decodeExtension(16,0);else if(199===e){const t=this.lookU8();s=this.decodeExtension(t,1)}else if(200===e){const t=this.lookU16();s=this.decodeExtension(t,2)}else{if(201!==e)throw new Error("Unrecognized type byte: "+`${(t=e)<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`);{const t=this.lookU32();s=this.decodeExtension(t,4)}}}const n=this.stack;for(;n.length>0;){const t=n[n.length-1];if(0===t.type){if(t.array[t.position]=s,t.position++,t.position!==t.size)continue t;n.pop(),s=t.array}else{if(1===t.type){L(s)||(t.serializedKey=i.fromByteArray(this.bytes.slice(t.keyStart,this.pos))),t.key=s,t.type=2;continue t}if(L(t.key)?t.map[t.key]=s:t.map[t.serializedKey]={_key:t.key,_value:s},t.readCount++,t.readCount!==t.size){t.key=null,t.type=1,n[n.length-1].keyStart=this.pos;continue t}n.pop(),s=t.map}}return s}var t}pushMapState(t){if(t>this.maxMapLength)throw new Error(`Max length exceeded: map length (${t}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.push({type:1,size:t,keyStart:1,key:null,serializedKey:null,readCount:0,map:{}})}pushArrayState(t){if(t>this.maxArrayLength)throw new Error(`Max length exceeded: array length (${t}) > maxArrayLength (${this.maxArrayLength})`);this.stack.push({type:0,size:t,keyStart:1,array:new Array(t),position:0})}decodeUtf8String(t,e){var i;if(t>this.maxStrLength)throw new Error(`Max length exceeded: UTF-8 byte length (${t}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+e+t)throw new RangeError("Insufficient data");const s=this.pos+e;let n;return n=this.stateIsMapKey()&&(null===(i=this.cachedKeyDecoder)||void 0===i?void 0:i.canBeCached(t))?this.cachedKeyDecoder.decode(this.bytes,s,t):b&&t>E?function(t,e,i){const s=t.subarray(e,e+i);return I.decode(s)}(this.bytes,s,t):m(this.bytes,s,t),this.pos+=e+t,n}stateIsMapKey(){if(this.stack.length>0){return 1===this.stack[this.stack.length-1].type}return!1}decodeBinary(t,e){if(t>this.maxBinLength)throw new Error(`Max length exceeded: bin length (${t}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(t+e))throw new RangeError("Insufficient data");const i=this.pos+e,s=this.bytes.subarray(i,i+t);return this.pos+=e+t,s}decodeExtension(t,e){if(t>this.maxExtLength)throw new Error(`Max length exceeded: ext length (${t}) > maxExtLength (${this.maxExtLength})`);const i=this.view.getInt8(this.pos+e),s=this.decodeBinary(t,e+1);return this.extensionCodec.decode(s,i)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const t=this.view.getUint8(this.pos);return this.pos++,t}readI8(){const t=this.view.getInt8(this.pos);return this.pos++,t}readU16(){const t=this.view.getUint16(this.pos);return this.pos+=2,t}readI16(){const t=this.view.getInt16(this.pos);return this.pos+=2,t}readU32(){const t=this.view.getUint32(this.pos);return this.pos+=4,t}readI32(){const t=this.view.getInt32(this.pos);return this.pos+=4,t}readU64(){const t=function(t,i,s){if(!t.getBigUint64||s){const s=t.getUint32(i),n=t.getUint32(i+4);return e.BigInt(g(s,n,!0))}return t.getBigUint64(i)}(this.view,this.pos,this.useJSBI);return this.pos+=8,t}readI64(){const t=function(t,i,s){if(!t.getBigInt64||s){const s=t.getInt32(i),n=t.getUint32(i+4);return e.BigInt(g(s,n,!1))}return t.getBigInt64(i)}(this.view,this.pos,this.useJSBI);return this.pos+=8,t}readF32(){const t=this.view.getFloat32(this.pos);return this.pos+=4,t}readF64(){const t=this.view.getFloat64(this.pos);return this.pos+=8,t}}const O={};function j(t,e=O){const i=new M(e.extensionCodec,e.useJSBI,e.maxStrLength,e.maxBinLength,e.maxArrayLength,e.maxMapLength,e.maxExtLength,e.cachedKeyDecoder);return i.setBuffer(t),i.decodeSingleSync()}function F(t){const e=typeof t;if("number"===e){return String(t).split(".").length>1?new h(t):new a(t)}if("boolean"===e)return new c(t);if("string"===e)return new f(t);if(null!==t&&"object"===e){let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);if(Object.getPrototypeOf(t)===e)return function(t){const e=new Map,i=Object.keys(t);for(let s=0;s<i.length;s+=1){const n=i[s],r=t[n],o=F(n),h=F(r);e.set(o,h)}return e}(t)}return new u}const _={Bool:c,Float32:o,Float64:h,Int:a,Nil:u,Pointer:l,Str:f},D=new n;var P;D.register({type:0,encode:(P=D,t=>t instanceof l?T(t.value,{extensionCodec:P}):null),decode:function(t){return e=>{const i=j(e,{extensionCodec:t});return Array.isArray(i)?new l(i):new l}}(D)}),t.Bool=c,t.Codec=D,t.ExtData=s,t.ExtensionCodec=n,t.Float32=o,t.Float64=h,t.Int=a,t.NeatTypeSerializer=y,t.NeatTypes=_,t.Nil=u,t.Pointer=l,t.Str=f,t.createBaseType=F,t.decode=j,t.encode=T,t.isJsbi=r,t.isNeatType=d,Object.defineProperty(t,"__esModule",{value:!0})}));

@@ -17,33 +17,30 @@ import JSBI from 'jsbi';

// ExtensionCodec to handle MessagePack extensions
let ExtensionCodec = /** @class */ (() => {
class ExtensionCodec {
constructor() {
// custom extensions
this.encoders = [];
this.decoders = [];
}
register({ type, encode, decode, }) {
this.encoders[type] = encode;
this.decoders[type] = decode;
}
tryToEncode(object) {
// custom extensions
for (let i = 0; i < this.encoders.length; i++) {
const encoder = this.encoders[i];
const data = encoder(object);
if (data != null) {
const type = i;
return new ExtData(type, data);
}
class ExtensionCodec {
constructor() {
// custom extensions
this.encoders = [];
this.decoders = [];
}
register({ type, encode, decode, }) {
this.encoders[type] = encode;
this.decoders[type] = decode;
}
tryToEncode(object) {
// custom extensions
for (let i = 0; i < this.encoders.length; i++) {
const encoder = this.encoders[i];
const data = encoder(object);
if (data != null) {
const type = i;
return new ExtData(type, data);
}
return null;
}
decode(data, type) {
const decoder = this.decoders[type];
return decoder(data, type);
}
return null;
}
ExtensionCodec.defaultCodec = new ExtensionCodec();
return ExtensionCodec;
})();
decode(data, type) {
const decoder = this.decoders[type];
return decoder(data, type);
}
}
ExtensionCodec.defaultCodec = new ExtensionCodec();

@@ -59,186 +56,166 @@ /**

// Copyright (c) 2018, Arista Networks, Inc.
let Float32 = /** @class */ (() => {
class Float32 {
/**
* A class to represent an explicit float32
*/
constructor(value) {
this.type = Float32.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
class Float32 {
/**
* A class to represent an explicit float32
*/
constructor(value) {
this.type = Float32.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
Float32.type = 'float32';
return Float32;
})();
let Float64 = /** @class */ (() => {
class Float64 {
/**
* A class to represent an explicit float64
*/
constructor(value) {
this.type = Float64.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
Float64.type = 'float64';
return Float64;
})();
let Int = /** @class */ (() => {
class Int {
/**
* A class to represent an explicit int
*/
constructor(value, forceJSBI = false) {
this.type = Int.type;
if (typeof value === 'string') {
let BI;
if (typeof BigInt === 'undefined' || forceJSBI) {
BI = JSBI.BigInt;
}
else {
BI = BigInt;
}
this.value =
parseInt(value, 10) > Number.MAX_SAFE_INTEGER ||
parseInt(value, 10) < Number.MAX_SAFE_INTEGER * -1
? BI(value)
: parseInt(value, 10);
}
Float32.type = 'float32';
class Float64 {
/**
* A class to represent an explicit float64
*/
constructor(value) {
this.type = Float64.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
}
Float64.type = 'float64';
class Int {
/**
* A class to represent an explicit int
*/
constructor(value, forceJSBI = false) {
this.type = Int.type;
if (typeof value === 'string') {
let BI;
if (typeof BigInt === 'undefined' || forceJSBI) {
BI = JSBI.BigInt;
}
else if (typeof value === 'bigint' || isJsbi(value)) {
this.value = value;
}
else {
this.value = parseInt(String(value), 10);
BI = BigInt;
}
this.value =
parseInt(value, 10) > Number.MAX_SAFE_INTEGER ||
parseInt(value, 10) < Number.MAX_SAFE_INTEGER * -1
? BI(value)
: parseInt(value, 10);
}
toString() {
return this.value.toString();
else if (typeof value === 'bigint' || isJsbi(value)) {
this.value = value;
}
}
Int.type = 'int';
return Int;
})();
let Bool = /** @class */ (() => {
class Bool {
/**
* A class to represent an explicit boolean
*/
constructor(value) {
this.type = Bool.type;
this.value = !!value;
else {
this.value = parseInt(String(value), 10);
}
toString() {
return this.value ? 'true' : 'false';
}
}
Bool.type = 'bool';
return Bool;
})();
let Nil = /** @class */ (() => {
class Nil {
/**
* A class to represent an explicit Nil
*/
constructor() {
this.type = Nil.type;
this.value = null;
}
toString() {
return 'null';
}
toString() {
return this.value.toString();
}
Nil.type = 'nil';
return Nil;
})();
let Str = /** @class */ (() => {
class Str {
/**
* A class to represent an explicit String
*/
constructor(value) {
this.type = Str.type;
switch (typeof value) {
case 'string':
this.value = value;
break;
case 'bigint':
this.value = value.toString();
break;
case 'undefined':
this.value = '';
break;
default:
this.value = JSON.stringify(value);
}
if (isJsbi(value)) {
}
Int.type = 'int';
class Bool {
/**
* A class to represent an explicit boolean
*/
constructor(value) {
this.type = Bool.type;
this.value = !!value;
}
toString() {
return this.value ? 'true' : 'false';
}
}
Bool.type = 'bool';
class Nil {
/**
* A class to represent an explicit Nil
*/
constructor() {
this.type = Nil.type;
this.value = null;
}
toString() {
return 'null';
}
}
Nil.type = 'nil';
class Str {
/**
* A class to represent an explicit String
*/
constructor(value) {
this.type = Str.type;
switch (typeof value) {
case 'string':
this.value = value;
break;
case 'bigint':
this.value = value.toString();
}
break;
case 'undefined':
this.value = '';
break;
default:
this.value = JSON.stringify(value);
}
toString() {
return this.value;
if (isJsbi(value)) {
this.value = value.toString();
}
}
Str.type = 'str';
return Str;
})();
let Pointer = /** @class */ (() => {
class Pointer {
/**
* A class to represent a Pointer type.
* A Pointer is a pointer from one set of path elements to another.
*/
constructor(value = []) {
this.delimiter = '/';
this.type = Pointer.type;
let strValue;
if (!Array.isArray(value)) {
if (typeof value !== 'string') {
strValue = JSON.stringify(value);
}
else {
strValue = value;
}
const ptrArray = strValue.split(this.delimiter);
while (ptrArray[0] === '') {
ptrArray.shift();
}
this.value = ptrArray.map((pathEl) => {
try {
return JSON.parse(pathEl);
}
catch (e) {
// ignore errors, these are just regular strings
}
return pathEl;
});
toString() {
return this.value;
}
}
Str.type = 'str';
class Pointer {
/**
* A class to represent a Pointer type.
* A Pointer is a pointer from one set of path elements to another.
*/
constructor(value = []) {
this.delimiter = '/';
this.type = Pointer.type;
let strValue;
if (!Array.isArray(value)) {
if (typeof value !== 'string') {
strValue = JSON.stringify(value);
}
else {
this.value = value;
strValue = value;
}
}
toString() {
return this.value
.map((pathEl) => {
if (typeof pathEl === 'string') {
return pathEl;
const ptrArray = strValue.split(this.delimiter);
while (ptrArray[0] === '') {
ptrArray.shift();
}
this.value = ptrArray.map((pathEl) => {
try {
return JSON.parse(pathEl);
}
return JSON.stringify(pathEl);
})
.join(this.delimiter);
catch (e) {
// ignore errors, these are just regular strings
}
return pathEl;
});
}
else {
this.value = value;
}
}
Pointer.type = 'ptr';
return Pointer;
})();
toString() {
return this.value
.map((pathEl) => {
if (typeof pathEl === 'string') {
return pathEl;
}
return JSON.stringify(pathEl);
})
.join(this.delimiter);
}
}
Pointer.type = 'ptr';
/* eslint-disable @typescript-eslint/naming-convention */
function isNeatType(value) {

@@ -277,26 +254,23 @@ if (typeof value === 'object' && value !== null) {

}
let NeatTypeSerializer = /** @class */ (() => {
class NeatTypeSerializer {
static serialize(neatTypeInstance) {
return {
__neatTypeClass: neatTypeInstance.type,
value: neatTypeInstance.value,
};
}
static deserialize(serializedNeatType) {
// eslint-disable-next-line no-underscore-dangle
return new NeatTypeSerializer.NEAT_TYPE_MAP[serializedNeatType.__neatTypeClass](serializedNeatType.value);
}
class NeatTypeSerializer {
static serialize(neatTypeInstance) {
return {
__neatTypeClass: neatTypeInstance.type,
value: neatTypeInstance.value,
};
}
NeatTypeSerializer.NEAT_TYPE_MAP = {
float32: Float32,
float64: Float64,
int: Int,
ptr: Pointer,
str: Str,
nil: Nil,
bool: Bool,
};
return NeatTypeSerializer;
})();
static deserialize(serializedNeatType) {
// eslint-disable-next-line no-underscore-dangle
return new NeatTypeSerializer.NEAT_TYPE_MAP[serializedNeatType.__neatTypeClass](serializedNeatType.value);
}
}
NeatTypeSerializer.NEAT_TYPE_MAP = {
float32: Float32,
float64: Float64,
int: Int,
ptr: Pointer,
str: Str,
nil: Nil,
bool: Bool,
};

@@ -1523,3 +1497,3 @@ // DataView extension to handle int64 / uint64,

if (Object.getPrototypeOf(value) === proto) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
// eslint-disable-next-line no-use-before-define
return createTypedMap(value);

@@ -1526,0 +1500,0 @@ }

@@ -23,33 +23,30 @@ 'use strict';

// ExtensionCodec to handle MessagePack extensions
let ExtensionCodec = /** @class */ (() => {
class ExtensionCodec {
constructor() {
// custom extensions
this.encoders = [];
this.decoders = [];
}
register({ type, encode, decode, }) {
this.encoders[type] = encode;
this.decoders[type] = decode;
}
tryToEncode(object) {
// custom extensions
for (let i = 0; i < this.encoders.length; i++) {
const encoder = this.encoders[i];
const data = encoder(object);
if (data != null) {
const type = i;
return new ExtData(type, data);
}
class ExtensionCodec {
constructor() {
// custom extensions
this.encoders = [];
this.decoders = [];
}
register({ type, encode, decode, }) {
this.encoders[type] = encode;
this.decoders[type] = decode;
}
tryToEncode(object) {
// custom extensions
for (let i = 0; i < this.encoders.length; i++) {
const encoder = this.encoders[i];
const data = encoder(object);
if (data != null) {
const type = i;
return new ExtData(type, data);
}
return null;
}
decode(data, type) {
const decoder = this.decoders[type];
return decoder(data, type);
}
return null;
}
ExtensionCodec.defaultCodec = new ExtensionCodec();
return ExtensionCodec;
})();
decode(data, type) {
const decoder = this.decoders[type];
return decoder(data, type);
}
}
ExtensionCodec.defaultCodec = new ExtensionCodec();

@@ -65,186 +62,166 @@ /**

// Copyright (c) 2018, Arista Networks, Inc.
let Float32 = /** @class */ (() => {
class Float32 {
/**
* A class to represent an explicit float32
*/
constructor(value) {
this.type = Float32.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
class Float32 {
/**
* A class to represent an explicit float32
*/
constructor(value) {
this.type = Float32.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
Float32.type = 'float32';
return Float32;
})();
let Float64 = /** @class */ (() => {
class Float64 {
/**
* A class to represent an explicit float64
*/
constructor(value) {
this.type = Float64.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
Float64.type = 'float64';
return Float64;
})();
let Int = /** @class */ (() => {
class Int {
/**
* A class to represent an explicit int
*/
constructor(value, forceJSBI = false) {
this.type = Int.type;
if (typeof value === 'string') {
let BI;
if (typeof BigInt === 'undefined' || forceJSBI) {
BI = JSBI.BigInt;
}
else {
BI = BigInt;
}
this.value =
parseInt(value, 10) > Number.MAX_SAFE_INTEGER ||
parseInt(value, 10) < Number.MAX_SAFE_INTEGER * -1
? BI(value)
: parseInt(value, 10);
}
Float32.type = 'float32';
class Float64 {
/**
* A class to represent an explicit float64
*/
constructor(value) {
this.type = Float64.type;
this.value = value ? parseFloat(String(value)) : 0.0; // undefined defaults to 0.0
}
toString() {
const strValue = this.value.toString();
const hasDecimal = strValue.includes('.');
return hasDecimal ? strValue : this.value.toFixed(1);
}
}
Float64.type = 'float64';
class Int {
/**
* A class to represent an explicit int
*/
constructor(value, forceJSBI = false) {
this.type = Int.type;
if (typeof value === 'string') {
let BI;
if (typeof BigInt === 'undefined' || forceJSBI) {
BI = JSBI.BigInt;
}
else if (typeof value === 'bigint' || isJsbi(value)) {
this.value = value;
}
else {
this.value = parseInt(String(value), 10);
BI = BigInt;
}
this.value =
parseInt(value, 10) > Number.MAX_SAFE_INTEGER ||
parseInt(value, 10) < Number.MAX_SAFE_INTEGER * -1
? BI(value)
: parseInt(value, 10);
}
toString() {
return this.value.toString();
else if (typeof value === 'bigint' || isJsbi(value)) {
this.value = value;
}
}
Int.type = 'int';
return Int;
})();
let Bool = /** @class */ (() => {
class Bool {
/**
* A class to represent an explicit boolean
*/
constructor(value) {
this.type = Bool.type;
this.value = !!value;
else {
this.value = parseInt(String(value), 10);
}
toString() {
return this.value ? 'true' : 'false';
}
}
Bool.type = 'bool';
return Bool;
})();
let Nil = /** @class */ (() => {
class Nil {
/**
* A class to represent an explicit Nil
*/
constructor() {
this.type = Nil.type;
this.value = null;
}
toString() {
return 'null';
}
toString() {
return this.value.toString();
}
Nil.type = 'nil';
return Nil;
})();
let Str = /** @class */ (() => {
class Str {
/**
* A class to represent an explicit String
*/
constructor(value) {
this.type = Str.type;
switch (typeof value) {
case 'string':
this.value = value;
break;
case 'bigint':
this.value = value.toString();
break;
case 'undefined':
this.value = '';
break;
default:
this.value = JSON.stringify(value);
}
if (isJsbi(value)) {
}
Int.type = 'int';
class Bool {
/**
* A class to represent an explicit boolean
*/
constructor(value) {
this.type = Bool.type;
this.value = !!value;
}
toString() {
return this.value ? 'true' : 'false';
}
}
Bool.type = 'bool';
class Nil {
/**
* A class to represent an explicit Nil
*/
constructor() {
this.type = Nil.type;
this.value = null;
}
toString() {
return 'null';
}
}
Nil.type = 'nil';
class Str {
/**
* A class to represent an explicit String
*/
constructor(value) {
this.type = Str.type;
switch (typeof value) {
case 'string':
this.value = value;
break;
case 'bigint':
this.value = value.toString();
}
break;
case 'undefined':
this.value = '';
break;
default:
this.value = JSON.stringify(value);
}
toString() {
return this.value;
if (isJsbi(value)) {
this.value = value.toString();
}
}
Str.type = 'str';
return Str;
})();
let Pointer = /** @class */ (() => {
class Pointer {
/**
* A class to represent a Pointer type.
* A Pointer is a pointer from one set of path elements to another.
*/
constructor(value = []) {
this.delimiter = '/';
this.type = Pointer.type;
let strValue;
if (!Array.isArray(value)) {
if (typeof value !== 'string') {
strValue = JSON.stringify(value);
}
else {
strValue = value;
}
const ptrArray = strValue.split(this.delimiter);
while (ptrArray[0] === '') {
ptrArray.shift();
}
this.value = ptrArray.map((pathEl) => {
try {
return JSON.parse(pathEl);
}
catch (e) {
// ignore errors, these are just regular strings
}
return pathEl;
});
toString() {
return this.value;
}
}
Str.type = 'str';
class Pointer {
/**
* A class to represent a Pointer type.
* A Pointer is a pointer from one set of path elements to another.
*/
constructor(value = []) {
this.delimiter = '/';
this.type = Pointer.type;
let strValue;
if (!Array.isArray(value)) {
if (typeof value !== 'string') {
strValue = JSON.stringify(value);
}
else {
this.value = value;
strValue = value;
}
}
toString() {
return this.value
.map((pathEl) => {
if (typeof pathEl === 'string') {
return pathEl;
const ptrArray = strValue.split(this.delimiter);
while (ptrArray[0] === '') {
ptrArray.shift();
}
this.value = ptrArray.map((pathEl) => {
try {
return JSON.parse(pathEl);
}
return JSON.stringify(pathEl);
})
.join(this.delimiter);
catch (e) {
// ignore errors, these are just regular strings
}
return pathEl;
});
}
else {
this.value = value;
}
}
Pointer.type = 'ptr';
return Pointer;
})();
toString() {
return this.value
.map((pathEl) => {
if (typeof pathEl === 'string') {
return pathEl;
}
return JSON.stringify(pathEl);
})
.join(this.delimiter);
}
}
Pointer.type = 'ptr';
/* eslint-disable @typescript-eslint/naming-convention */
function isNeatType(value) {

@@ -283,26 +260,23 @@ if (typeof value === 'object' && value !== null) {

}
let NeatTypeSerializer = /** @class */ (() => {
class NeatTypeSerializer {
static serialize(neatTypeInstance) {
return {
__neatTypeClass: neatTypeInstance.type,
value: neatTypeInstance.value,
};
}
static deserialize(serializedNeatType) {
// eslint-disable-next-line no-underscore-dangle
return new NeatTypeSerializer.NEAT_TYPE_MAP[serializedNeatType.__neatTypeClass](serializedNeatType.value);
}
class NeatTypeSerializer {
static serialize(neatTypeInstance) {
return {
__neatTypeClass: neatTypeInstance.type,
value: neatTypeInstance.value,
};
}
NeatTypeSerializer.NEAT_TYPE_MAP = {
float32: Float32,
float64: Float64,
int: Int,
ptr: Pointer,
str: Str,
nil: Nil,
bool: Bool,
};
return NeatTypeSerializer;
})();
static deserialize(serializedNeatType) {
// eslint-disable-next-line no-underscore-dangle
return new NeatTypeSerializer.NEAT_TYPE_MAP[serializedNeatType.__neatTypeClass](serializedNeatType.value);
}
}
NeatTypeSerializer.NEAT_TYPE_MAP = {
float32: Float32,
float64: Float64,
int: Int,
ptr: Pointer,
str: Str,
nil: Nil,
bool: Bool,
};

@@ -1529,3 +1503,3 @@ // DataView extension to handle int64 / uint64,

if (Object.getPrototypeOf(value) === proto) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
// eslint-disable-next-line no-use-before-define
return createTypedMap(value);

@@ -1532,0 +1506,0 @@ }

{
"name": "a-msgpack",
"version": "4.3.0",
"version": "4.3.1",
"description": "A minimalistic NEAT (MessagePack based) encoder and decoder for JavaScript.",

@@ -68,6 +68,6 @@ "author": "Stephane Rufer <stephane@arista.com>",

"eslint-config-airbnb-base": "14.1.0",
"eslint-config-arista-js": "1.1.23",
"eslint-config-arista-ts": "1.1.8",
"eslint-config-arista-js": "1.1.26",
"eslint-config-arista-ts": "1.1.21",
"eslint-plugin-arista": "0.1.32",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-import": "2.22.0",
"jest": "26.0.1",

@@ -77,12 +77,12 @@ "js-yaml": "3.14.0",

"rimraf": "3.0.2",
"rollup": "2.11.2",
"rollup": "2.20.0",
"rollup-plugin-terser": "5.3.0",
"ts-jest": "26.0.0",
"tslib": "2.0.0",
"typedoc": "0.17.7",
"typedoc": "0.17.8",
"typedoc-neo-theme": "1.0.8",
"typedoc-plugin-markdown": "2.2.17",
"typescript": "3.9.3"
"typescript": "3.9.6"
},
"gitHead": "3c634d604e2259c921828d77c9f96f1a1f75176e"
"gitHead": "d90c25f7f7ba17f90f6f1e846435fcb956db35de"
}
# a-msgpack
MessagePack, but for Arista. This is based on the official msgpack library for JS (@msgpack/msgpack), but implements our specific NEAT protocol.
MessagePack, but for Arista. This is based on the official msgpack library for JS
(@msgpack/msgpack), but implements our specific NEAT protocol.

@@ -28,10 +29,15 @@ ## Installation

In the browser, `a-msgpack` requires the [Encoding API](https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API) to work a peak performance. If the Encoding API is unavailable, there is a fallback JS implementation.
In the browser, `a-msgpack` requires the
[Encoding API](https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API) to work a peak
performance. If the Encoding API is unavailable, there is a fallback JS implementation.
## Benchmarks
The lastest code benchmarks and profiling is stored in `last-benchmark-results.txt`. This also compares this implementation to other msgpack libraries. Note, that the decoding results should be comparable to @msgpack/msgpack, but encoding will be slower because NEAT requires that map keys be sorted by binary value.
The lastest code benchmarks and profiling is stored in `last-benchmark-results.txt`. This also
compares this implementation to other msgpack libraries. Note, that the decoding results should be
comparable to @msgpack/msgpack, but encoding will be slower because NEAT requires that map keys be
sorted by binary value.
## License
[MIT](https://github.com/JoshuaWise/tiny-msgpack/blob/master/LICENSE)
[MIT](https://github.com/JoshuaWise/tiny-msgpack/blob/trunk/LICENSE)

@@ -48,3 +48,3 @@ // Copyright (c) 2018, Arista Networks, Inc.

if (Object.getPrototypeOf(value) === proto) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
// eslint-disable-next-line no-use-before-define
return createTypedMap(value as PlainObject<unknown>);

@@ -51,0 +51,0 @@ }

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

/* eslint-disable @typescript-eslint/naming-convention */
import { PathElements } from '../../types/neat';

@@ -2,0 +4,0 @@

import { Bool, Float32, Float64, Int, Nil, Pointer, Str } from '../src/neat/NeatTypes';
export declare type Element = string | number | object | unknown[] | boolean;
export declare type Element = string | number | Record<string, unknown> | {} | unknown[] | boolean;
export declare type PathElements = readonly Element[];

@@ -4,0 +4,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