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

js-big-counter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-big-counter - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

10

dist/es6/JSBigCounter.js

@@ -222,2 +222,12 @@ /*

/**
* Returns a copy of the internal big counter array used by this big counter.
*
* @return {number[]} A copy of the big counter array.
*/
getBigCounterArrayCopy() {
return [...this.bigCounterArray];
}
/**
* Static method to serialize a big counter to JSON.

@@ -224,0 +234,0 @@ *

2

dist/js-big-counter.min.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("JSBigCounter",[],t):"object"==typeof exports?exports.JSBigCounter=t():e.JSBigCounter=t()}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(){return(()=>{"use strict";var e={247:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(713)),l=r(217),o=n(r(489)),u=n(r(279)),i=n(r(626)),s=n(r(656)),f=n(r(997)),c=n(r(161)),g=n(r(436)),h=n(r(207)),d=n(r(373)),v=n(r(630));class m{constructor(e,t,r,n){this.length=e,this.scale=t,this.value=r,this.sign=n}add(e,t){return m.fromInfo(a.default(this,m.from(e),t))}subtract(e,t){return m.fromInfo(v.default(this,m.from(e),t))}multiply(e,t){return m.fromInfo(h.default(this,m.from(e),t))}divide(e,t){return m.fromInfo(u.default(this,m.from(e),t))}raise(e,t){return m.fromInfo(d.default(this,m.from(e),t))}modulo(e,t){return m.fromInfo(g.default(this,m.from(e),t))}divideModulo(e,t){const[r,n]=i.default(this,m.from(e),t);return[m.from(r),m.from(n)]}compareTo(e){return o.default(this,m.from(e))}isEqualTo(e){return 0===this.compareTo(e)}isGreaterThan(e){return 1===this.compareTo(e)}isGreaterThanOrEqualTo(e){return this.compareTo(e)>=0}isLowerThan(e){return-1===this.compareTo(e)}isLowerThanOrEqualTo(e){return this.compareTo(e)<=0}isZero(){return s.default(this)}isOne(){return this.isEqualTo(m.ONE)}isMinusOne(){return this.isEqualTo(m.MINUS_ONE)}negate(){return m.fromInfo(l.negate(this))}isNegative(){return this.sign===l.DecimalSign.MINUS}isPositive(){return this.sign===l.DecimalSign.PLUS}toString(){return l.createStringFromInfo(this)}toInt(){return parseInt(this.toString(),l.DECIMAL_RADIX)}toFloat(){return parseFloat(this.toString())}toFixed(e){return l.createStringFromInfo(this,e)}static max(...e){return m.from(f.default(...e.map(m.from)))}static min(...e){return m.from(c.default(...e.map(m.from)))}static fromString(e){return m.fromInfo(l.createInfoFromString(e))}static fromInfo(e){return new m(e.length,e.scale,e.value,e.sign)}static fromNumber(e){return m.fromInfo(l.createInfoFromString(e.toString(l.DECIMAL_RADIX)))}static from(e){if(e instanceof m)return e;if("string"==typeof e)return m.fromString(e);if("number"==typeof e)return m.fromNumber(e);if(l.isInfo(e))return m.fromInfo(e);throw Error(`Don't know how to parse value of type ${typeof e} to decimal`)}static isDecimal(e){return e instanceof m}static isDecimalLike(e){return e instanceof m||["string","number"].includes(typeof e)||l.isInfo(e)}}m.ZERO=m.fromInfo(l.INFO_ZERO),m.ONE=m.fromInfo(l.INFO_ONE),m.MINUS_ONE=m.fromInfo(l.INFO_MINUS_ONE),t.default=m},713:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(20)),l=r(217),o=n(r(489)),u=n(r(369)),{max:i}=Math;t.default=function(e,t,r=i(e.scale,t.scale)){let n;if(e.sign===t.sign)return n=a.default(e,t,r),n.sign=e.sign,n;switch(o.default(e,t,!1)){case-1:n=u.default(t,e,r),n.sign=t.sign;break;case 0:const a=i(r,i(e.scale,t.scale));n=l.createInfo(1,a);break;case 1:n=u.default(e,t,r),n.sign=e.sign;break;default:throw Error("Invalid decimal comparison result")}return n}},20:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),l=n(r(549)),{max:o}=Math;t.default=function(e,t,r=0){const n=o(e.scale,t.scale),u=o(e.length,t.length)+1,i=a.createInfo(u,o(n,r));let s=e.scale,f=t.scale,c=e.length+s-1,g=t.length+f-1,h=n+u-1;if(s!==f)if(s>f)for(;s>f;h-=1,c-=1,s-=1)i.value[h]=e.value[c];else for(;f>s;h-=1,g-=1,f-=1)i.value[h]=t.value[g];s+=e.length,f+=t.length;let d,v=0;for(;s>0&&f>0;c-=1,g-=1,h-=1,s-=1,f-=1)d=e.value[c]+t.value[g]+v,d>=a.DECIMAL_RADIX?(v=1,d-=a.DECIMAL_RADIX):v=0,i.value[h]=d;if(0===s)for(;f>0;f-=1,g-=1,h-=1)d=t.value[g]+v,d>=a.DECIMAL_RADIX?(v=1,d-=a.DECIMAL_RADIX):v=0,i.value[h]=d;else for(;s>0;s-=1,c-=1,h-=1)d=e.value[c]+v,d>=a.DECIMAL_RADIX?(v=1,d-=a.DECIMAL_RADIX):v=0,i.value[h]=d;return 1===v&&(i.value[h]+=1),l.default(i)}},217:(e,t)=>{var r;function n(e=1,t=0){return{length:e,scale:t,sign:r.PLUS,value:new Uint8Array(e+t)}}function a(e,t=e.length,r=e.length-t,a=0){const l=n(t,r);return l.value.set(e,a),l}function l(e){return Object.assign({},e,{sign:e.sign===r.PLUS?r.MINUS:r.PLUS})}Object.defineProperty(t,"__esModule",{value:!0}),t.DECIMAL_VALIDATION_REGEX=/^[+\-]?\d+(\.\d+)?$/,t.DECIMAL_RADIX=10,function(e){e.PLUS="+",e.MINUS="-"}(r=t.DecimalSign||(t.DecimalSign={})),t.INFO_ZERO=n(),t.INFO_ONE=a([1]),t.INFO_MINUS_ONE=l(a([1])),t.createInfo=n,t.createInfoFromArray=a,t.createInfoFromString=function(e){if("string"!=typeof e)throw new TypeError(`Invalid ${typeof e} argument passed, string expected`);if(!e.match(t.DECIMAL_VALIDATION_REGEX))throw Error(`Invalid decimal string ${e} provided`);let n=e,l=r.PLUS;const o=e.charAt(0);o!==r.PLUS&&o!==r.MINUS||(o===r.MINUS&&(l=r.MINUS),n=n.substr(1)),n=n.replace(/^0+([0-9])/,"$1");const u=n.indexOf(".");let i=n.length,s=0;return-1!==u&&(s=i-(u+1),i-=s+1,n=n.replace(".","")),Object.assign({},a(n.split("").map(e=>parseInt(e,t.DECIMAL_RADIX)),i,s),{sign:l})},t.createStringFromInfo=function(e,t=e.scale){let n=e.value.subarray(0,e.length).join("");return t>0&&(n+="."+e.value.subarray(e.length,e.length+t).join("")),(e.sign===r.MINUS?r.MINUS:"")+n},t.createSubInfo=function(e,t=e.length,r=e.scale,n=0,l=0){return a(e.value.subarray(n),t,r,l)},t.copyInfo=function(e){return{sign:e.sign,length:e.length,scale:e.scale,value:new Uint8Array(e.value)}},t.isInfo=function(e){return"object"==typeof e&&null!==e&&"number"==typeof e.length&&"number"==typeof e.scale&&"string"==typeof e.sign&&[r.PLUS,r.MINUS].includes(e.sign)&&"object"==typeof e.value&&e.value instanceof Uint8Array},t.negate=l},489:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(217),{min:a}=Math;t.default=function(e,t,r=!0,l=!1){if(r&&e.sign!==t.sign)return e.sign===n.DecimalSign.PLUS?1:-1;if(e.length!==t.length)return e.length>t.length?r&&e.sign!==n.DecimalSign.PLUS?-1:1:r&&e.sign!==n.DecimalSign.PLUS?1:-1;let o=e.length+a(e.scale,t.scale),u=0,i=0;for(;o>0&&e.value[u]===t.value[i];)u+=1,i+=1,o-=1;if(l&&1===o&&e.scale===t.scale)return 0;if(0!==o)return e.value[u]>t.value[i]?r&&e.sign!==n.DecimalSign.PLUS?-1:1:r&&e.sign!==n.DecimalSign.PLUS?1:-1;if(e.scale!==t.scale)if(e.scale>t.scale){for(o=e.scale-t.scale;o>0;o-=1,u+=1)if(0!==e.value[u])return r&&e.sign!==n.DecimalSign.PLUS?-1:1}else for(o=t.scale-e.scale;o>0;o-=1,i+=1)if(0!==t.value[i])return r&&e.sign!==n.DecimalSign.PLUS?1:-1;return 0}},279:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),l=n(r(489)),o=n(r(656)),u=n(r(549)),{min:i,max:s,floor:f}=Math;function c(e,t,r,n,l,o){if(0===n)return void l.fill(0,0,r);if(1===n)return void l.set(e.subarray(t,t+r),o);let u,i,s=t+r-1,c=o+r-1;u=0;let g=r;for(;g>0;g-=1,s-=1,c-=1)i=e[s]*n+u,l[c]=i%a.DECIMAL_RADIX,u=f(i/a.DECIMAL_RADIX);0!==u&&(l[c]=u)}t.default=function(e,t,r=s(e.scale,t.scale)){if(o.default(t))throw Error("Division by zero");if(o.default(e))return a.createInfo(1,r);if(0===l.default(e,t))return a.createInfoFromArray([1],1,r);let n;if(0===t.scale&&1===t.length&&1===t.value[0])return n=a.createInfo(e.length,r),n.sign=e.sign===t.sign?a.DecimalSign.PLUS:a.DecimalSign.MINUS,n.value.fill(0,e.length,e.length+r),n.value.set(e.value.subarray(e.length+i(e.scale,r))),n;let g=t.scale,h=t.length+g-1;for(;g>0&&0===t.value[h];h-=1)g-=1;const d=e.length+g,v=e.scale-g,m=v<r?r-v:0,I=new Uint8Array(e.length+e.scale+m+2).fill(0);I.set(e.value,1);let _=t.length+g;const y=new Uint8Array(_+1);for(y.set(t.value),h=0;0===y[h];)h+=1,_-=1;let p,b;_>d+r?(b=r+1,p=!0):(p=!1,b=_>d?r+1:d-_+r+1),n=a.createInfo(b-r,r);const A=new Uint8Array(_+1),S=a.copyInfo(t);if(!p){const e=f(10/(t.value[h]+1));1!==e&&(c(I,0,d+v+m+1,e,I,0),c(t.value,h,_,e,t.value,h));let a=0,l=_>d?_-d:0;for(;a<=d+r-_;){let e;e=t.value[h]===I[a]?9:f((10*I[a]+I[a+1])/t.value[h]),t.value[h+1]*e>10*(10*I[a]+I[a+1]-t.value[h]*e)+I[a+2]&&(e-=1,t.value[h+1]*e>10*(10*I[a]+I[a+1]-t.value[h]*e)+I[a+2]&&(e-=1));let r=0;if(0!==e){A[0]=0,c(t.value,h,_,e,A,1);let n=a+_,l=_;for(let e=0;e<_+1;e+=1,n-=1){let e;l<0?e=I[n]-r:(e=I[n]-A[l]-r,l-=1),e<0?(e+=10,r=1):r=0,I[n]=e}}if(1===r){e-=1;let r=a+_,n=_-1,l=0;for(let e=0;e<_;e+=1,r-=1){let e;n<0?e=I[r]+l:(e=I[r]+t.value[n]+l,n-=1),e>9?(e-=10,l=1):l=0,I[r]=e}1===l&&(I[r]=(I[r]+1)%10)}n.value[l]=e,l+=1,a+=1}}return n.sign=e.sign===t.sign?a.DecimalSign.PLUS:a.DecimalSign.MINUS,o.default(n)&&(n.sign=a.DecimalSign.PLUS),Object.assign(t,S),u.default(n)}},626:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),l=n(r(279)),o=n(r(656)),u=n(r(997)),i=n(r(207)),s=n(r(630));t.default=function(e,t,r=Math.max(e.scale,t.scale)){if(o.default(t))throw Error("Division by zero");const n=Math.max(e.scale,t.scale+r),f=l.default(e,t,0),c=i.default(f,t,n),g=s.default(e,c,n);return[f,u.default(g,a.INFO_ZERO)]}},350:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(713));t.add=a.default;const l=n(r(20));t.addUnsigned=l.default;const o=r(217);t.copyInfo=o.copyInfo,t.createInfo=o.createInfo,t.createInfoFromArray=o.createInfoFromArray,t.createInfoFromString=o.createInfoFromString,t.createStringFromInfo=o.createStringFromInfo,t.createSubInfo=o.createSubInfo;const u=n(r(489));t.compare=u.default;const i=n(r(247)),s=n(r(279));t.divide=s.default;const f=n(r(656));t.isZero=f.default;const c=n(r(207));t.multiply=c.default;const g=n(r(549));t.removeLeadingZeroes=g.default;const h=n(r(630));t.subtract=h.default;const d=n(r(369));t.subtractUnsigned=d.default,t.default=i.default},656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=e.length+e.scale;for(let r=0;r<t;r+=1)if(0!==e.value[r])return!1;return!0}},997:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(489));t.default=function(...e){if(e.length<2)throw Error("At least two values must be given");return 2===e.length?1===a.default(e[0],e[1])?e[0]:e[1]:(e.sort(a.default),e[e.length-1])}},161:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(489));t.default=function(...e){if(e.length<2)throw Error("At least two values must be given");return 2===e.length?1===a.default(e[0],e[1])?e[1]:e[0]:(e.sort(a.default),e[0])}},436:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(626)),{max:l}=Math;t.default=function(e,t,r=l(e.scale,t.scale)){return a.default(e,t,r)[1]}},207:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),l=n(r(656)),o=n(r(549)),u=n(r(630)),{min:i,max:s,floor:f}=Math;function c(e,t,r,n,l=0){const o=t+n+1,u=a.createInfo(o),c=t-1,g=n-1;let h,d,v=o-1,m=0;for(let t=0;t<o-1;t+=1,v-=1){for(h=c-s(0,t-n+1),d=g-i(t,n-1);h>=0&&d<=g;h-=1,d+=1)m+=e.value[h]*r.value[d];u.value[v]=f(m%a.DECIMAL_RADIX),m=f(m/a.DECIMAL_RADIX)}return u.value[v]=m,u}function g(e,t,r,n,i=0){if(t+n<80||t<20||n<20)return c(e,t,r,n,i);const d=f((s(t,n)+1)/2);let v,m,I,_;t<d?(m=a.createInfo(),v=a.createSubInfo(e,t,0)):(m=a.createSubInfo(e,t-d,0),v=a.createSubInfo(e,d,0,t-d)),n<d?(_=a.createInfo(),I=a.createSubInfo(r,n,0)):(_=a.createSubInfo(r,n-d,0),I=a.createSubInfo(r,d,0,n-d)),m=o.default(m),v=o.default(v),_=o.default(_),I=o.default(I);const y=l.default(m)||l.default(_),p=u.default(m,v),b=p.length,A=u.default(I,_),S=A.length;let D,M,E;D=y?a.createInfo():g(m,m.length,_,_.length),M=l.default(p)||l.default(A)?a.createInfo():g(p,b,A,S),E=l.default(v)||l.default(I)?a.createInfo():g(v,v.length,I,I.length);const C=t+n+1;let O=a.createInfo(C);return y||(O=h(O,D,2*d),O=h(O,D,d)),O=h(O,E,d),O=h(O,E,0),O=h(O,M,d,p.sign!==A.sign),O}function h(e,t,r,n=!1){const l=a.copyInfo(e);let o=t.length;if(0===t.value[0]&&(o-=1),l.length+l.scale<r+o)throw Error("len + scale < shift + count");let u=l.length+l.scale-r-1,i=t.length-1,s=0;if(n){for(;o>=0;o-=1,i-=1,u-=1)l.value[u]-=t.value[i]+s,l.value[u]<0?(s=1,l.value[u]+=a.DECIMAL_RADIX):s=0;for(;s;u-=1)l.value[u]-=s,l.value[u]<0?l.value[u]+=a.DECIMAL_RADIX:s=0}else{for(;o>=0;o-=1,i-=1,u-=1)l.value[u]+=t.value[i]+s,l.value[u]>a.DECIMAL_RADIX-1?(s=1,l.value[u]-=a.DECIMAL_RADIX):s=0;for(;s;u-=1)l.value[u]+=s,l.value[u]>a.DECIMAL_RADIX-1?l.value[u]-=a.DECIMAL_RADIX:s=0}return l}t.default=function(e,t,r=s(e.scale,t.scale)){const n=e.length+e.scale,u=t.length+t.scale,f=e.scale+t.scale,c=i(r,f);let h=g(e,n,t,u,f);return h.sign=e.sign===t.sign?a.DecimalSign.PLUS:a.DecimalSign.MINUS,h.length=u+n+1-f,h.scale=c,h.scale<h.value.length&&(h.value=h.value.subarray(0,h.length+h.scale)),h=o.default(h),l.default(h)&&(h.sign=a.DecimalSign.PLUS),h},t.multiplySimple=c,t.multiplyRecursive=g,t.shiftAddSubtract=h},373:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),l=n(r(279)),o=n(r(207)),{min:u,max:i}=Math;t.default=function(e,t,r=i(e.scale,t.scale)){if(t.scale>0)throw Error("Trying to build power with non-integral exponent");let n,s,f=parseInt(a.createStringFromInfo(t),a.DECIMAL_RADIX);if(isNaN(f)||0===f&&(t.length>1||0!==t.value[0]))throw Error("Exponent too large in raise");if(0===f)return a.createInfoFromArray([1],r);f<0?(n=!0,f=-f,s=r):(n=!1,s=u(e.scale*f,i(r,e.scale)));let c=a.copyInfo(e),g=e.scale;for(;0==(1&f);)g*=2,c=o.default(c,c,g),f>>=1;let h,d=a.copyInfo(c),v=g;for(f>>=1;f>0;)g*=2,c=o.default(c,c,g),1==(1&f)&&(v=g+v,d=o.default(d,c,v)),f>>=1;return n?h=l.default(a.INFO_ONE,d,s):(h=d,h.scale>s&&(h.scale=s,h.value.length>h.length+h.scale&&(h.value=h.value.subarray(0,h.length+h.scale)))),h}},549:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){let t=0;for(;0===e.value[t]&&e.length-t>1;)t+=1;return t>0?{length:e.length-t,scale:e.scale,sign:e.sign,value:e.value.subarray(t)}:e}},630:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(20)),l=r(217),o=n(r(489)),u=n(r(369)),{max:i}=Math;t.default=function(e,t,r=i(e.scale,t.scale)){let n;if(e.sign!==t.sign)return n=a.default(e,t,r),n.sign=e.sign,n;switch(o.default(e,t,!1)){case-1:n=u.default(t,e,r),n.sign=t.sign===l.DecimalSign.PLUS?l.DecimalSign.MINUS:l.DecimalSign.PLUS;break;case 0:const a=i(r,i(e.scale,t.scale));n=l.createInfo(1,a);break;case 1:n=u.default(e,t,r),n.sign=e.sign;break;default:throw Error("Invalid decimal comparison result")}return n}},369:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),l=n(r(549)),{max:o,min:u}=Math;t.default=function(e,t,r=0){const n=o(e.length,t.length),i=o(e.scale,t.scale),s=u(e.length,t.length),f=u(e.scale,t.scale),c=a.createInfo(n,o(i,r));let g,h,d=e.length+e.scale-1,v=t.length+t.scale-1,m=n+i-1,I=0;if(e.scale!==f)for(g=e.scale-f;g>0;g-=1)c.value[m]=e.value[d],m-=1,d-=1;else for(g=t.scale-f;g>0;g-=1,v-=1,m-=1)h=0-t.value[v]-I,v-=1,h<0?(h+=a.DECIMAL_RADIX,I=1):I=0,c.value[m]=h;for(g=0;g<s+f;g+=1,d-=1,v-=1,m-=1)h=e.value[d]-t.value[v]-I,h<0?(h+=a.DECIMAL_RADIX,I=1):I=0,c.value[m]=h;if(n!==s)for(g=n-s;g>0;g-=1,d-=1,m-=1)h=e.value[d]-I,h<0?(h+=a.DECIMAL_RADIX,I=1):I=0,c.value[m]=h;return l.default(c)}}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var l=t[n]={exports:{}};return e[n].call(l.exports,l,l.exports,r),l.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n={};return(()=>{r.d(n,{default:()=>u});var e=r(350),t=r.n(e),a=Number.MAX_SAFE_INTEGER;function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}const u=function(){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;l(this,e),t=Object.prototype.hasOwnProperty.call(r,"length")?r.map((function(e){return e>=0?e:0})):[r>=0?r:0],this.bigCounterArray=t,this.bigCounterArray.length||(this.bigCounterArray=[0]),this.bigCounterArray.length>1&&!this.bigCounterArray[this.bigCounterArray.length-1]&&(this.bigCounterArray[this.bigCounterArray.length-1]=1)}var r,n,u;return r=e,u=[{key:"toJSON",value:function(e){return JSON.stringify({bigCounterArray:e.bigCounterArray})}},{key:"fromJSON",value:function(t){var r=JSON.parse(t),n=new e;return n.bigCounterArray=r.bigCounterArray,n}}],(n=[{key:"increment",value:function(){for(var e=0;this.bigCounterArray[e]===a;)this.bigCounterArray[e]=0,e++;this.bigCounterArray[e]||(this.bigCounterArray[e]=0),this.bigCounterArray[e]++}},{key:"decrement",value:function(){if(this.bigCounterArray[0]>0)this.bigCounterArray[0]--;else{if(1===this.bigCounterArray.length)return;this.bigCounterArray[0]=a;for(var e=1;0===this.bigCounterArray[e];)this.bigCounterArray[e]=a,e++;this.bigCounterArray[e]--,e===this.bigCounterArray.length-1&&0===this.bigCounterArray[e]&&this.bigCounterArray.pop()}}},{key:"toString",value:function(){for(var e=t().from(a).add(1),r=t().from(e),n=t().from(this.bigCounterArray[0]),l=1;l<this.bigCounterArray.length;l++){var o=this.bigCounterArray[l];r=1===l?r:r.multiply(e),n=n.add(t().from(o).multiply(r))}return n.toString()}},{key:"compareTo",value:function(e){if(this===e)return 0;var t=this.bigCounterArray.length,r=e.bigCounterArray.length;if(t>r)return 1;if(r>t)return-1;for(var n=t;n>=0;n--){var a=this.bigCounterArray[n],l=e.bigCounterArray[n];if(a>l)return 1;if(l>a)return-1}return 0}},{key:"isEqualTo",value:function(e){return 0===this.compareTo(e)}},{key:"isGreaterThan",value:function(e){return this.compareTo(e)>0}},{key:"isLessThan",value:function(e){return this.compareTo(e)<0}},{key:"isGreaterThanOrEqualTo",value:function(e){return this.isGreaterThan(e)||this.isEqualTo(e)}},{key:"isLessThanOrEqualTo",value:function(e){return this.isLessThan(e)||this.isEqualTo(e)}}])&&o(r.prototype,n),u&&o(r,u),e}()})(),n=n.default})()}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("JSBigCounter",[],t):"object"==typeof exports?exports.JSBigCounter=t():e.JSBigCounter=t()}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(){return(()=>{"use strict";var e={247:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(713)),o=r(217),l=n(r(489)),u=n(r(279)),i=n(r(626)),s=n(r(656)),f=n(r(997)),c=n(r(161)),g=n(r(436)),h=n(r(207)),d=n(r(373)),v=n(r(630));class m{constructor(e,t,r,n){this.length=e,this.scale=t,this.value=r,this.sign=n}add(e,t){return m.fromInfo(a.default(this,m.from(e),t))}subtract(e,t){return m.fromInfo(v.default(this,m.from(e),t))}multiply(e,t){return m.fromInfo(h.default(this,m.from(e),t))}divide(e,t){return m.fromInfo(u.default(this,m.from(e),t))}raise(e,t){return m.fromInfo(d.default(this,m.from(e),t))}modulo(e,t){return m.fromInfo(g.default(this,m.from(e),t))}divideModulo(e,t){const[r,n]=i.default(this,m.from(e),t);return[m.from(r),m.from(n)]}compareTo(e){return l.default(this,m.from(e))}isEqualTo(e){return 0===this.compareTo(e)}isGreaterThan(e){return 1===this.compareTo(e)}isGreaterThanOrEqualTo(e){return this.compareTo(e)>=0}isLowerThan(e){return-1===this.compareTo(e)}isLowerThanOrEqualTo(e){return this.compareTo(e)<=0}isZero(){return s.default(this)}isOne(){return this.isEqualTo(m.ONE)}isMinusOne(){return this.isEqualTo(m.MINUS_ONE)}negate(){return m.fromInfo(o.negate(this))}isNegative(){return this.sign===o.DecimalSign.MINUS}isPositive(){return this.sign===o.DecimalSign.PLUS}toString(){return o.createStringFromInfo(this)}toInt(){return parseInt(this.toString(),o.DECIMAL_RADIX)}toFloat(){return parseFloat(this.toString())}toFixed(e){return o.createStringFromInfo(this,e)}static max(...e){return m.from(f.default(...e.map(m.from)))}static min(...e){return m.from(c.default(...e.map(m.from)))}static fromString(e){return m.fromInfo(o.createInfoFromString(e))}static fromInfo(e){return new m(e.length,e.scale,e.value,e.sign)}static fromNumber(e){return m.fromInfo(o.createInfoFromString(e.toString(o.DECIMAL_RADIX)))}static from(e){if(e instanceof m)return e;if("string"==typeof e)return m.fromString(e);if("number"==typeof e)return m.fromNumber(e);if(o.isInfo(e))return m.fromInfo(e);throw Error(`Don't know how to parse value of type ${typeof e} to decimal`)}static isDecimal(e){return e instanceof m}static isDecimalLike(e){return e instanceof m||["string","number"].includes(typeof e)||o.isInfo(e)}}m.ZERO=m.fromInfo(o.INFO_ZERO),m.ONE=m.fromInfo(o.INFO_ONE),m.MINUS_ONE=m.fromInfo(o.INFO_MINUS_ONE),t.default=m},713:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(20)),o=r(217),l=n(r(489)),u=n(r(369)),{max:i}=Math;t.default=function(e,t,r=i(e.scale,t.scale)){let n;if(e.sign===t.sign)return n=a.default(e,t,r),n.sign=e.sign,n;switch(l.default(e,t,!1)){case-1:n=u.default(t,e,r),n.sign=t.sign;break;case 0:const a=i(r,i(e.scale,t.scale));n=o.createInfo(1,a);break;case 1:n=u.default(e,t,r),n.sign=e.sign;break;default:throw Error("Invalid decimal comparison result")}return n}},20:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),o=n(r(549)),{max:l}=Math;t.default=function(e,t,r=0){const n=l(e.scale,t.scale),u=l(e.length,t.length)+1,i=a.createInfo(u,l(n,r));let s=e.scale,f=t.scale,c=e.length+s-1,g=t.length+f-1,h=n+u-1;if(s!==f)if(s>f)for(;s>f;h-=1,c-=1,s-=1)i.value[h]=e.value[c];else for(;f>s;h-=1,g-=1,f-=1)i.value[h]=t.value[g];s+=e.length,f+=t.length;let d,v=0;for(;s>0&&f>0;c-=1,g-=1,h-=1,s-=1,f-=1)d=e.value[c]+t.value[g]+v,d>=a.DECIMAL_RADIX?(v=1,d-=a.DECIMAL_RADIX):v=0,i.value[h]=d;if(0===s)for(;f>0;f-=1,g-=1,h-=1)d=t.value[g]+v,d>=a.DECIMAL_RADIX?(v=1,d-=a.DECIMAL_RADIX):v=0,i.value[h]=d;else for(;s>0;s-=1,c-=1,h-=1)d=e.value[c]+v,d>=a.DECIMAL_RADIX?(v=1,d-=a.DECIMAL_RADIX):v=0,i.value[h]=d;return 1===v&&(i.value[h]+=1),o.default(i)}},217:(e,t)=>{var r;function n(e=1,t=0){return{length:e,scale:t,sign:r.PLUS,value:new Uint8Array(e+t)}}function a(e,t=e.length,r=e.length-t,a=0){const o=n(t,r);return o.value.set(e,a),o}function o(e){return Object.assign({},e,{sign:e.sign===r.PLUS?r.MINUS:r.PLUS})}Object.defineProperty(t,"__esModule",{value:!0}),t.DECIMAL_VALIDATION_REGEX=/^[+\-]?\d+(\.\d+)?$/,t.DECIMAL_RADIX=10,function(e){e.PLUS="+",e.MINUS="-"}(r=t.DecimalSign||(t.DecimalSign={})),t.INFO_ZERO=n(),t.INFO_ONE=a([1]),t.INFO_MINUS_ONE=o(a([1])),t.createInfo=n,t.createInfoFromArray=a,t.createInfoFromString=function(e){if("string"!=typeof e)throw new TypeError(`Invalid ${typeof e} argument passed, string expected`);if(!e.match(t.DECIMAL_VALIDATION_REGEX))throw Error(`Invalid decimal string ${e} provided`);let n=e,o=r.PLUS;const l=e.charAt(0);l!==r.PLUS&&l!==r.MINUS||(l===r.MINUS&&(o=r.MINUS),n=n.substr(1)),n=n.replace(/^0+([0-9])/,"$1");const u=n.indexOf(".");let i=n.length,s=0;return-1!==u&&(s=i-(u+1),i-=s+1,n=n.replace(".","")),Object.assign({},a(n.split("").map(e=>parseInt(e,t.DECIMAL_RADIX)),i,s),{sign:o})},t.createStringFromInfo=function(e,t=e.scale){let n=e.value.subarray(0,e.length).join("");return t>0&&(n+="."+e.value.subarray(e.length,e.length+t).join("")),(e.sign===r.MINUS?r.MINUS:"")+n},t.createSubInfo=function(e,t=e.length,r=e.scale,n=0,o=0){return a(e.value.subarray(n),t,r,o)},t.copyInfo=function(e){return{sign:e.sign,length:e.length,scale:e.scale,value:new Uint8Array(e.value)}},t.isInfo=function(e){return"object"==typeof e&&null!==e&&"number"==typeof e.length&&"number"==typeof e.scale&&"string"==typeof e.sign&&[r.PLUS,r.MINUS].includes(e.sign)&&"object"==typeof e.value&&e.value instanceof Uint8Array},t.negate=o},489:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(217),{min:a}=Math;t.default=function(e,t,r=!0,o=!1){if(r&&e.sign!==t.sign)return e.sign===n.DecimalSign.PLUS?1:-1;if(e.length!==t.length)return e.length>t.length?r&&e.sign!==n.DecimalSign.PLUS?-1:1:r&&e.sign!==n.DecimalSign.PLUS?1:-1;let l=e.length+a(e.scale,t.scale),u=0,i=0;for(;l>0&&e.value[u]===t.value[i];)u+=1,i+=1,l-=1;if(o&&1===l&&e.scale===t.scale)return 0;if(0!==l)return e.value[u]>t.value[i]?r&&e.sign!==n.DecimalSign.PLUS?-1:1:r&&e.sign!==n.DecimalSign.PLUS?1:-1;if(e.scale!==t.scale)if(e.scale>t.scale){for(l=e.scale-t.scale;l>0;l-=1,u+=1)if(0!==e.value[u])return r&&e.sign!==n.DecimalSign.PLUS?-1:1}else for(l=t.scale-e.scale;l>0;l-=1,i+=1)if(0!==t.value[i])return r&&e.sign!==n.DecimalSign.PLUS?1:-1;return 0}},279:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),o=n(r(489)),l=n(r(656)),u=n(r(549)),{min:i,max:s,floor:f}=Math;function c(e,t,r,n,o,l){if(0===n)return void o.fill(0,0,r);if(1===n)return void o.set(e.subarray(t,t+r),l);let u,i,s=t+r-1,c=l+r-1;u=0;let g=r;for(;g>0;g-=1,s-=1,c-=1)i=e[s]*n+u,o[c]=i%a.DECIMAL_RADIX,u=f(i/a.DECIMAL_RADIX);0!==u&&(o[c]=u)}t.default=function(e,t,r=s(e.scale,t.scale)){if(l.default(t))throw Error("Division by zero");if(l.default(e))return a.createInfo(1,r);if(0===o.default(e,t))return a.createInfoFromArray([1],1,r);let n;if(0===t.scale&&1===t.length&&1===t.value[0])return n=a.createInfo(e.length,r),n.sign=e.sign===t.sign?a.DecimalSign.PLUS:a.DecimalSign.MINUS,n.value.fill(0,e.length,e.length+r),n.value.set(e.value.subarray(e.length+i(e.scale,r))),n;let g=t.scale,h=t.length+g-1;for(;g>0&&0===t.value[h];h-=1)g-=1;const d=e.length+g,v=e.scale-g,m=v<r?r-v:0,I=new Uint8Array(e.length+e.scale+m+2).fill(0);I.set(e.value,1);let y=t.length+g;const _=new Uint8Array(y+1);for(_.set(t.value),h=0;0===_[h];)h+=1,y-=1;let p,b;y>d+r?(b=r+1,p=!0):(p=!1,b=y>d?r+1:d-y+r+1),n=a.createInfo(b-r,r);const A=new Uint8Array(y+1),S=a.copyInfo(t);if(!p){const e=f(10/(t.value[h]+1));1!==e&&(c(I,0,d+v+m+1,e,I,0),c(t.value,h,y,e,t.value,h));let a=0,o=y>d?y-d:0;for(;a<=d+r-y;){let e;e=t.value[h]===I[a]?9:f((10*I[a]+I[a+1])/t.value[h]),t.value[h+1]*e>10*(10*I[a]+I[a+1]-t.value[h]*e)+I[a+2]&&(e-=1,t.value[h+1]*e>10*(10*I[a]+I[a+1]-t.value[h]*e)+I[a+2]&&(e-=1));let r=0;if(0!==e){A[0]=0,c(t.value,h,y,e,A,1);let n=a+y,o=y;for(let e=0;e<y+1;e+=1,n-=1){let e;o<0?e=I[n]-r:(e=I[n]-A[o]-r,o-=1),e<0?(e+=10,r=1):r=0,I[n]=e}}if(1===r){e-=1;let r=a+y,n=y-1,o=0;for(let e=0;e<y;e+=1,r-=1){let e;n<0?e=I[r]+o:(e=I[r]+t.value[n]+o,n-=1),e>9?(e-=10,o=1):o=0,I[r]=e}1===o&&(I[r]=(I[r]+1)%10)}n.value[o]=e,o+=1,a+=1}}return n.sign=e.sign===t.sign?a.DecimalSign.PLUS:a.DecimalSign.MINUS,l.default(n)&&(n.sign=a.DecimalSign.PLUS),Object.assign(t,S),u.default(n)}},626:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),o=n(r(279)),l=n(r(656)),u=n(r(997)),i=n(r(207)),s=n(r(630));t.default=function(e,t,r=Math.max(e.scale,t.scale)){if(l.default(t))throw Error("Division by zero");const n=Math.max(e.scale,t.scale+r),f=o.default(e,t,0),c=i.default(f,t,n),g=s.default(e,c,n);return[f,u.default(g,a.INFO_ZERO)]}},350:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(713));t.add=a.default;const o=n(r(20));t.addUnsigned=o.default;const l=r(217);t.copyInfo=l.copyInfo,t.createInfo=l.createInfo,t.createInfoFromArray=l.createInfoFromArray,t.createInfoFromString=l.createInfoFromString,t.createStringFromInfo=l.createStringFromInfo,t.createSubInfo=l.createSubInfo;const u=n(r(489));t.compare=u.default;const i=n(r(247)),s=n(r(279));t.divide=s.default;const f=n(r(656));t.isZero=f.default;const c=n(r(207));t.multiply=c.default;const g=n(r(549));t.removeLeadingZeroes=g.default;const h=n(r(630));t.subtract=h.default;const d=n(r(369));t.subtractUnsigned=d.default,t.default=i.default},656:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=e.length+e.scale;for(let r=0;r<t;r+=1)if(0!==e.value[r])return!1;return!0}},997:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(489));t.default=function(...e){if(e.length<2)throw Error("At least two values must be given");return 2===e.length?1===a.default(e[0],e[1])?e[0]:e[1]:(e.sort(a.default),e[e.length-1])}},161:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(489));t.default=function(...e){if(e.length<2)throw Error("At least two values must be given");return 2===e.length?1===a.default(e[0],e[1])?e[1]:e[0]:(e.sort(a.default),e[0])}},436:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(626)),{max:o}=Math;t.default=function(e,t,r=o(e.scale,t.scale)){return a.default(e,t,r)[1]}},207:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),o=n(r(656)),l=n(r(549)),u=n(r(630)),{min:i,max:s,floor:f}=Math;function c(e,t,r,n,o=0){const l=t+n+1,u=a.createInfo(l),c=t-1,g=n-1;let h,d,v=l-1,m=0;for(let t=0;t<l-1;t+=1,v-=1){for(h=c-s(0,t-n+1),d=g-i(t,n-1);h>=0&&d<=g;h-=1,d+=1)m+=e.value[h]*r.value[d];u.value[v]=f(m%a.DECIMAL_RADIX),m=f(m/a.DECIMAL_RADIX)}return u.value[v]=m,u}function g(e,t,r,n,i=0){if(t+n<80||t<20||n<20)return c(e,t,r,n,i);const d=f((s(t,n)+1)/2);let v,m,I,y;t<d?(m=a.createInfo(),v=a.createSubInfo(e,t,0)):(m=a.createSubInfo(e,t-d,0),v=a.createSubInfo(e,d,0,t-d)),n<d?(y=a.createInfo(),I=a.createSubInfo(r,n,0)):(y=a.createSubInfo(r,n-d,0),I=a.createSubInfo(r,d,0,n-d)),m=l.default(m),v=l.default(v),y=l.default(y),I=l.default(I);const _=o.default(m)||o.default(y),p=u.default(m,v),b=p.length,A=u.default(I,y),S=A.length;let D,M,E;D=_?a.createInfo():g(m,m.length,y,y.length),M=o.default(p)||o.default(A)?a.createInfo():g(p,b,A,S),E=o.default(v)||o.default(I)?a.createInfo():g(v,v.length,I,I.length);const C=t+n+1;let O=a.createInfo(C);return _||(O=h(O,D,2*d),O=h(O,D,d)),O=h(O,E,d),O=h(O,E,0),O=h(O,M,d,p.sign!==A.sign),O}function h(e,t,r,n=!1){const o=a.copyInfo(e);let l=t.length;if(0===t.value[0]&&(l-=1),o.length+o.scale<r+l)throw Error("len + scale < shift + count");let u=o.length+o.scale-r-1,i=t.length-1,s=0;if(n){for(;l>=0;l-=1,i-=1,u-=1)o.value[u]-=t.value[i]+s,o.value[u]<0?(s=1,o.value[u]+=a.DECIMAL_RADIX):s=0;for(;s;u-=1)o.value[u]-=s,o.value[u]<0?o.value[u]+=a.DECIMAL_RADIX:s=0}else{for(;l>=0;l-=1,i-=1,u-=1)o.value[u]+=t.value[i]+s,o.value[u]>a.DECIMAL_RADIX-1?(s=1,o.value[u]-=a.DECIMAL_RADIX):s=0;for(;s;u-=1)o.value[u]+=s,o.value[u]>a.DECIMAL_RADIX-1?o.value[u]-=a.DECIMAL_RADIX:s=0}return o}t.default=function(e,t,r=s(e.scale,t.scale)){const n=e.length+e.scale,u=t.length+t.scale,f=e.scale+t.scale,c=i(r,f);let h=g(e,n,t,u,f);return h.sign=e.sign===t.sign?a.DecimalSign.PLUS:a.DecimalSign.MINUS,h.length=u+n+1-f,h.scale=c,h.scale<h.value.length&&(h.value=h.value.subarray(0,h.length+h.scale)),h=l.default(h),o.default(h)&&(h.sign=a.DecimalSign.PLUS),h},t.multiplySimple=c,t.multiplyRecursive=g,t.shiftAddSubtract=h},373:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),o=n(r(279)),l=n(r(207)),{min:u,max:i}=Math;t.default=function(e,t,r=i(e.scale,t.scale)){if(t.scale>0)throw Error("Trying to build power with non-integral exponent");let n,s,f=parseInt(a.createStringFromInfo(t),a.DECIMAL_RADIX);if(isNaN(f)||0===f&&(t.length>1||0!==t.value[0]))throw Error("Exponent too large in raise");if(0===f)return a.createInfoFromArray([1],r);f<0?(n=!0,f=-f,s=r):(n=!1,s=u(e.scale*f,i(r,e.scale)));let c=a.copyInfo(e),g=e.scale;for(;0==(1&f);)g*=2,c=l.default(c,c,g),f>>=1;let h,d=a.copyInfo(c),v=g;for(f>>=1;f>0;)g*=2,c=l.default(c,c,g),1==(1&f)&&(v=g+v,d=l.default(d,c,v)),f>>=1;return n?h=o.default(a.INFO_ONE,d,s):(h=d,h.scale>s&&(h.scale=s,h.value.length>h.length+h.scale&&(h.value=h.value.subarray(0,h.length+h.scale)))),h}},549:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){let t=0;for(;0===e.value[t]&&e.length-t>1;)t+=1;return t>0?{length:e.length-t,scale:e.scale,sign:e.sign,value:e.value.subarray(t)}:e}},630:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(20)),o=r(217),l=n(r(489)),u=n(r(369)),{max:i}=Math;t.default=function(e,t,r=i(e.scale,t.scale)){let n;if(e.sign!==t.sign)return n=a.default(e,t,r),n.sign=e.sign,n;switch(l.default(e,t,!1)){case-1:n=u.default(t,e,r),n.sign=t.sign===o.DecimalSign.PLUS?o.DecimalSign.MINUS:o.DecimalSign.PLUS;break;case 0:const a=i(r,i(e.scale,t.scale));n=o.createInfo(1,a);break;case 1:n=u.default(e,t,r),n.sign=e.sign;break;default:throw Error("Invalid decimal comparison result")}return n}},369:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=r(217),o=n(r(549)),{max:l,min:u}=Math;t.default=function(e,t,r=0){const n=l(e.length,t.length),i=l(e.scale,t.scale),s=u(e.length,t.length),f=u(e.scale,t.scale),c=a.createInfo(n,l(i,r));let g,h,d=e.length+e.scale-1,v=t.length+t.scale-1,m=n+i-1,I=0;if(e.scale!==f)for(g=e.scale-f;g>0;g-=1)c.value[m]=e.value[d],m-=1,d-=1;else for(g=t.scale-f;g>0;g-=1,v-=1,m-=1)h=0-t.value[v]-I,v-=1,h<0?(h+=a.DECIMAL_RADIX,I=1):I=0,c.value[m]=h;for(g=0;g<s+f;g+=1,d-=1,v-=1,m-=1)h=e.value[d]-t.value[v]-I,h<0?(h+=a.DECIMAL_RADIX,I=1):I=0,c.value[m]=h;if(n!==s)for(g=n-s;g>0;g-=1,d-=1,m-=1)h=e.value[d]-I,h<0?(h+=a.DECIMAL_RADIX,I=1):I=0,c.value[m]=h;return o.default(c)}}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n={};return(()=>{r.d(n,{default:()=>s});var e=r(350),t=r.n(e),a=Number.MAX_SAFE_INTEGER;function o(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return l(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}const s=function(){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;u(this,e),t=Object.prototype.hasOwnProperty.call(r,"length")?r.map((function(e){return e>=0?e:0})):[r>=0?r:0],this.bigCounterArray=t,this.bigCounterArray.length||(this.bigCounterArray=[0]),this.bigCounterArray.length>1&&!this.bigCounterArray[this.bigCounterArray.length-1]&&(this.bigCounterArray[this.bigCounterArray.length-1]=1)}var r,n,l;return r=e,l=[{key:"toJSON",value:function(e){return JSON.stringify({bigCounterArray:e.bigCounterArray})}},{key:"fromJSON",value:function(t){var r=JSON.parse(t),n=new e;return n.bigCounterArray=r.bigCounterArray,n}}],(n=[{key:"increment",value:function(){for(var e=0;this.bigCounterArray[e]===a;)this.bigCounterArray[e]=0,e++;this.bigCounterArray[e]||(this.bigCounterArray[e]=0),this.bigCounterArray[e]++}},{key:"decrement",value:function(){if(this.bigCounterArray[0]>0)this.bigCounterArray[0]--;else{if(1===this.bigCounterArray.length)return;this.bigCounterArray[0]=a;for(var e=1;0===this.bigCounterArray[e];)this.bigCounterArray[e]=a,e++;this.bigCounterArray[e]--,e===this.bigCounterArray.length-1&&0===this.bigCounterArray[e]&&this.bigCounterArray.pop()}}},{key:"toString",value:function(){for(var e=t().from(a).add(1),r=t().from(e),n=t().from(this.bigCounterArray[0]),o=1;o<this.bigCounterArray.length;o++){var l=this.bigCounterArray[o];r=1===o?r:r.multiply(e),n=n.add(t().from(l).multiply(r))}return n.toString()}},{key:"compareTo",value:function(e){if(this===e)return 0;var t=this.bigCounterArray.length,r=e.bigCounterArray.length;if(t>r)return 1;if(r>t)return-1;for(var n=t;n>=0;n--){var a=this.bigCounterArray[n],o=e.bigCounterArray[n];if(a>o)return 1;if(o>a)return-1}return 0}},{key:"isEqualTo",value:function(e){return 0===this.compareTo(e)}},{key:"isGreaterThan",value:function(e){return this.compareTo(e)>0}},{key:"isLessThan",value:function(e){return this.compareTo(e)<0}},{key:"isGreaterThanOrEqualTo",value:function(e){return this.isGreaterThan(e)||this.isEqualTo(e)}},{key:"isLessThanOrEqualTo",value:function(e){return this.isLessThan(e)||this.isEqualTo(e)}},{key:"getBigCounterArrayCopy",value:function(){return o(this.bigCounterArray)}}])&&i(r.prototype,n),l&&i(r,l),e}()})(),n=n.default})()}));
{
"name": "js-big-counter",
"version": "1.4.0",
"version": "1.5.0",
"description": "Big integer/arbitrary-length counter for JavaScript.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -216,2 +216,11 @@ /*

/**
* Returns a copy of the internal big counter array used by this big counter.
*
* @return {number[]} A copy of the big counter array.
*/
getBigCounterArrayCopy() {
return [...this.bigCounterArray];
}
/**
* Static method to serialize a big counter to JSON.

@@ -218,0 +227,0 @@ *

@@ -389,1 +389,12 @@ /*

});
test("getBigCounterArrayCopy works", () => {
const bigCounter = new JSBigCounter([5, 89, 78, Number.MAX_SAFE_INTEGER, 2]);
expect(bigCounter.getBigCounterArrayCopy()).toEqual([
5,
89,
78,
Number.MAX_SAFE_INTEGER,
2,
]);
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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