a-calc 0.0.5 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -7
- package/browser/index.core.js +1 -0
- package/browser/index.html +29 -0
- package/browser/index.js +1 -0
- package/calc.d.ts +5 -5
- package/cjs/index.js +1 -0
- package/cjs/package.json +3 -0
- package/es/index.js +1 -0
- package/es/package.json +3 -0
- package/example/index.html +2 -53
- package/example/index.js +8 -0
- package/package.json +46 -12
- package/LICENSE +0 -373
- package/dist/calc.js +0 -2
- package/dist/calc.js.map +0 -1
- package/example/index.cjs +0 -14
- package/example/index.mjs +0 -22
- package/example/numbro.min.js +0 -2
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@ A string of four operations of the library, can solve the js digital calculation
|
|
|
3
3
|
|
|
4
4
|
(一个字符串四则运算的库, 可以解决js数字计算精度 科学记数法和格式化的问题, 支持千分位小数点格式化输出等操作)
|
|
5
5
|
|
|
6
|
-
>
|
|
6
|
+
> Supported operators (支持的运算符) : + - * / %
|
|
7
|
+
>
|
|
7
8
|
|
|
8
9
|
## Install(安装)
|
|
9
10
|
|
|
@@ -22,16 +23,13 @@ const {calc, fmt} = require("a-calc")
|
|
|
22
23
|
**es module**
|
|
23
24
|
|
|
24
25
|
```js
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
const {calc, fmt} = a_calc
|
|
26
|
+
import {calc, fmt} from "a-calc"
|
|
28
27
|
```
|
|
29
28
|
|
|
30
29
|
**browser**
|
|
31
30
|
|
|
32
31
|
```html
|
|
33
|
-
<script src="node_modules/
|
|
34
|
-
<script src="node_modules/a-calc/dist/calc.js"></script>
|
|
32
|
+
<script src="node_modules/a-calc/browser/index.js"></script>
|
|
35
33
|
<script>
|
|
36
34
|
const {calc, fmt} = a_calc
|
|
37
35
|
</script>
|
|
@@ -44,10 +42,17 @@ calc("0.1 + 0.2") // 0.3
|
|
|
44
42
|
calc`0.1 + 0.2` // 0.3
|
|
45
43
|
// 以上方式等价
|
|
46
44
|
|
|
45
|
+
// 复杂一点的计算
|
|
47
46
|
calc("0.1 + 0.2 * 0.3 / 0.4 * (0.5 + 0.6)") // 0.265
|
|
48
47
|
```
|
|
49
48
|
|
|
49
|
+
**Fill and calculate(填充变量并计算)**
|
|
50
50
|
|
|
51
|
+
```js
|
|
52
|
+
let a = 0.000001
|
|
53
|
+
let b = 888.789
|
|
54
|
+
calc("a + b", {a,b}) // 0.000001 + 888.789 = 888.789001
|
|
55
|
+
```
|
|
51
56
|
|
|
52
57
|
## Calculate & Format (计算并格式化)
|
|
53
58
|
|
|
@@ -86,5 +91,13 @@ fmt("1000000 | ,") // 1,000,000
|
|
|
86
91
|
|
|
87
92
|
## Video Tutorial(视频教程)
|
|
88
93
|
|
|
89
|
-
|
|
94
|
+
待定
|
|
95
|
+
|
|
96
|
+
## Issue To(问题提交)
|
|
97
|
+
|
|
98
|
+
If you have any questions, pstlease send email to 718879459@qq.com as soon as possible to give me feedback
|
|
99
|
+
|
|
100
|
+
(如果遇到了什么问题, 请第一时间向我发送反馈邮件, 718879459@qq.com 对于bug我会第一时间修复他)
|
|
101
|
+
|
|
102
|
+
|
|
90
103
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a_calc=function(r){"use strict";function t(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var u=t(Decimal);function o(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function n(r,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function i(r,t,e){return t&&n(r.prototype,t),e&&n(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function a(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),t&&f(r,t)}function l(r){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function f(r,t){return(f=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(r){return!1}}function s(r,t,e){return(s=c()?Reflect.construct:function(r,t,e){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(r,n));return e&&f(t,e.prototype),t}).apply(null,arguments)}function p(r){var e="function"==typeof Map?new Map:void 0;return(p=function(r){if(null===r||-1===Function.toString.call(r).indexOf("[native code]"))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(r))return e.get(r);e.set(r,t)}function t(){return s(r,arguments,l(this).constructor)}return t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),f(t,r)})(r)}function h(r,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");t=r;if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function d(e){var n=c();return function(){var r,t=l(e);return h(this,n?(r=l(this).constructor,Reflect.construct(t,arguments,r)):t.apply(this,arguments))}}function y(r){return function(r){if(Array.isArray(r))return v(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,t){if(r){if("string"==typeof r)return v(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(e="Object"===e&&r.constructor?r.constructor.name:e)||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?v(r,t):void 0}}(r)||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 v(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function g(r){return-1<"+-*/%()".indexOf(r)}function b(r){switch(r){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function m(r){var t={expr:"",fmt:null,data:null},e="",n=r[0];if(1===r.length)"string"==typeof n?e=n:"number"==typeof n?e=n.toString():Array.isArray(n)&&(e=n[0]);else if(1<r.length){n=r[r.length-1];if(l=n,"[object Object]"!==Object.prototype.toString.call(l)||Array.isArray(l))for(var o=y(r.shift());o.length||r.length;)var i=0===o.length?"":o.shift(),a=0===r.length?"":r.shift(),e=e+i+(a="number"==typeof a?a.toString():a);else e=r[0],t.data=n}var l=e.split("|");return 1===l.length?t.expr=l[0]:(t.expr=l[0],""!==(n=l[1]).trim()&&(t.fmt=n)),t}function w(r,t){var e="",n=(e=u.default.isDecimal(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,i=t.match(/(<=|>=|=)\s*(\d+)/);if(i&&(r=i[1],n=Number(i[2])),t.includes(",")&&(o=!0),null!==n){var i=e.split("."),t=i[0],a=1===i.length?"":i[1],l=a.length;switch(r){case"<=":a=l<=n?a:a.slice(0,n);break;case"=":l<n?a+="0".repeat(n-l):n<l&&(a=a.slice(0,n));break;case">=":a=n<=l?a:a+"0".repeat(n-l)}e=""===a?t:"".concat(t,".").concat(a)}return e=null!==o?1<(i=e.split(".")).length?((r=i[0]).includes("-")?i[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(t=i[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,","):e}function O(r){for(var t=[],e=0,n=null,o=r.length;e<o;)if(n=r[e],/\s/.test(n))e++;else if("+-".includes(n)){var i=t[t.length-1];if(0===t.length||"+-".includes(i)||"("===i){for(var a=n,n=r[++e];/[a-zA-Z\d._]/.test(n);)a+=n,n=r[++e];t.push(a)}else t.push(n),e++}else if("*/%()".includes(n))t.push(n),e++;else if(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++e>=o));)n=r[e];t.push(l)}else if(/\d/.test(n)){for(var u="";/[\d.]/.test(n)&&(u+=n,!(++e>=o));)n=r[e];t.push(u)}return t}var j=function(){a(n,p(Error));var e=d(n);function n(r){var t;return o(this,n),(t=e.call(this,r)).name="CalculatorError",t.message=r,t}return i(n)}(),E=function(){a(n,p(Error));var e=d(n);function n(r){var t;return o(this,n),(t=e.call(this,r)).name="TokensFillError",t.message=r,t}return i(n)}();function _(r,t){var e=t._fillData;return void 0===t._fillData&&(e=t),r.map(function(r){if(/^[a-zA-z_][\w_]*$/.test(r)){var t=e[r];if(void 0!==t)return"number"==typeof t?t.toString():t;throw new E("错误的参数:".concat(r," 请确认他存在"))}return r})}function A(r){for(var t,e=[],n=[],o=r;0<o.length;){var i=o.shift();if(g(i))if("("===i)e.push(i);else if(")"===i){for(var a=e.pop();"("!==a&&0<e.length;)n.push(a),a=e.pop();if("("!==a)throw"error: unmatched ()"}else{for(;t=e[e.length-1],b(i)<=b(t)&&0<e.length;)n.push(e.pop());e.push(i)}else n.push(i)}if(0<e.length){if(")"===e[e.length-1]||"("===e[e.length-1])throw"error: unmatched ()";for(;0<e.length;)n.push(e.pop())}return n}function x(r){for(var t=[];0<r.length;){var e=r.shift();if(g(e)){if(t.length<2)throw new j("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),o=t.pop();switch("string"==typeof n&&(n=new u.default(n)),"string"==typeof o&&(o=new u.default(o)),e){case"+":t.push(o.add(n));break;case"-":t.push(o.sub(n));break;case"*":t.push(o.mul(n));break;case"/":t.push(o.div(n));break;case"%":t.push(o.mod(n))}}else t.push(e)}if(1!==t.length)throw"unvalid expression";return t[0]}return r.calc=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=m(t),o=O(n.expr),i=null;if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=_(o,n.data);else try{o=_(o,n.data)}catch(r){if(r instanceof E)return i.fillError||i.error;throw r}var o=A(o),a=null;if(null!==i){if(void 0!==i.calcError||void 0!==i.error)try{a=x(o)}catch(r){if(r instanceof j)return void 0!==i.calcError?i.calcError:i.error;throw r}}else a=x(o);return a=null!==n.fmt?w(a,n.fmt):null!==a?a.toFixed():null},r.fmt=function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=m(t),o=O(n.expr),i=null;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=_(o,n.data);else try{o=_(o,n.data)}catch(r){if(r instanceof TokensFillError)return i.fillError||i.error;throw r}if(null===n.fmt)throw"表达式没有格式化部分";return w(o[0],n.fmt)},r.version="0.0.30",Object.defineProperty(r,"__esModule",{value:!0}),r}({});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Title</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<script src="./index.js"></script>
|
|
9
|
+
<script>
|
|
10
|
+
const {calc, fmt} = a_calc
|
|
11
|
+
|
|
12
|
+
console.log(calc("a + b",{a: 1, b: 3}))
|
|
13
|
+
console.log(fmt("100|=5"))
|
|
14
|
+
let a = 0.000001
|
|
15
|
+
let b = 888.789
|
|
16
|
+
console.log(calc("a + b", {a,b}))
|
|
17
|
+
|
|
18
|
+
console.log(calc("0.1 + 0.2 * 0.3 / 0.4 * (0.5 + 0.6)"))
|
|
19
|
+
console.log(calc("0.11111 + 0.11111 | <=4"))
|
|
20
|
+
|
|
21
|
+
// console.log(fmt("123"))
|
|
22
|
+
|
|
23
|
+
a = 0.1
|
|
24
|
+
b = 0.2
|
|
25
|
+
let c = calc("a + b + 1 |= 2",{a,b})
|
|
26
|
+
console.log(c)
|
|
27
|
+
</script>
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
package/browser/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a_calc=function(n){"use strict";function s(n){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function k(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function U(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function I(n,e,t){return e&&U(n.prototype,e),t&&U(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function L(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&o(n,e)}function i(n){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)})(n)}function o(n,e){return(o=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n})(n,e)}function C(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(n){return!1}}function $(n,e,t){return($=C()?Reflect.construct:function(n,e,t){var r=[null];r.push.apply(r,e);e=new(Function.bind.apply(n,r));return t&&o(e,t.prototype),e}).apply(null,arguments)}function e(n){var t="function"==typeof Map?new Map:void 0;return(e=function(n){if(null===n||-1===Function.toString.call(n).indexOf("[native code]"))return n;if("function"!=typeof n)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(n))return t.get(n);t.set(n,e)}function e(){return $(n,arguments,i(this).constructor)}return e.prototype=Object.create(n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,n)})(n)}function H(n,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");e=n;if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(t){var r=C();return function(){var n,e=i(t);return H(this,r?(n=i(this).constructor,Reflect.construct(e,arguments,n)):e.apply(this,arguments))}}function V(n){return function(n){if(Array.isArray(n))return r(n)}(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||function(n,e){if(n){if("string"==typeof n)return r(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return"Map"===(t="Object"===t&&n.constructor?n.constructor.name:t)||"Set"===t?Array.from(n):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?r(n,e):void 0}}(n)||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 r(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function z(n){return-1<"+-*/%()".indexOf(n)}function W(n){switch(n){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function J(n){var e={expr:"",fmt:null,data:null},t="",r=n[0];if(1===n.length)"string"==typeof r?t=r:"number"==typeof r?t=r.toString():Array.isArray(r)&&(t=r[0]);else if(1<n.length){r=n[n.length-1];if(u=r,"[object Object]"!==Object.prototype.toString.call(u)||Array.isArray(u))for(var i=V(n.shift());i.length||n.length;)var o=0===i.length?"":i.shift(),s=0===n.length?"":n.shift(),t=t+o+(s="number"==typeof s?s.toString():s);else t=n[0],e.data=r}var u=t.split("|");return 1===u.length?e.expr=u[0]:(e.expr=u[0],""!==(r=u[1]).trim()&&(e.fmt=r)),e}var G,u,c=9e15,p=1e9,g="0123456789abcdef",f="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",a="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",K={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-c,maxE:c,crypto:!1},y=!0,l="[DecimalError] ",m=l+"Invalid argument: ",Q=l+"Precision limit exceeded",X=l+"crypto unavailable",t="[object Decimal]",q=Math.floor,w=Math.pow,Y=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,nn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,en=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,tn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,F=1e7,D=7,rn=f.length-1,on=a.length-1,h={toStringTag:t};function b(n){var e,t,r,i=n.length-1,o="",s=n[0];if(0<i){for(o+=s,e=1;e<i;e++)r=n[e]+"",(t=D-r.length)&&(o+=S(t)),o+=r;s=n[e],(t=D-(r=s+"").length)&&(o+=S(t))}else if(0===s)return"0";for(;s%10==0;)s/=10;return o+s}function v(n,e,t){if(n!==~~n||n<e||t<n)throw Error(m+n)}function N(n,e,t,r){for(var i,o,s=n[0];10<=s;s/=10)--e;return--e<0?(e+=D,i=0):(i=Math.ceil((e+1)/D),e%=D),s=w(10,D-e),o=n[i]%s|0,null==r?e<3?(0==e?o=o/100|0:1==e&&(o=o/10|0),t<4&&99999==o||3<t&&49999==o||5e4==o||0==o):(t<4&&o+1==s||3<t&&o+1==s/2)&&(n[i+1]/s/100|0)==w(10,e-2)-1||(o==s/2||0==o)&&0==(n[i+1]/s/100|0):e<4?(0==e?o=o/1e3|0:1==e?o=o/100|0:2==e&&(o=o/10|0),(r||t<4)&&9999==o||!r&&3<t&&4999==o):((r||t<4)&&o+1==s||!r&&3<t&&o+1==s/2)&&(n[i+1]/s/1e3|0)==w(10,e-3)-1}function E(n,e,t){for(var r,i,o=[0],s=0,u=n.length;s<u;){for(i=o.length;i--;)o[i]*=e;for(o[0]+=g.indexOf(n.charAt(s++)),r=0;r<o.length;r++)o[r]>t-1&&(void 0===o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/t|0,o[r]%=t)}return o.reverse()}h.absoluteValue=h.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),P(n)},h.ceil=function(){return P(new this.constructor(this),this.e+1,2)},h.clampedTo=h.clamp=function(n,e){var t=this.constructor;if(n=new t(n),e=new t(e),!n.s||!e.s)return new t(NaN);if(n.gt(e))throw Error(m+e);return this.cmp(n)<0?n:0<this.cmp(e)?e:new t(this)},h.comparedTo=h.cmp=function(n){var e,t,r=this,i=r.d,o=(n=new r.constructor(n)).d,s=r.s,u=n.s;if(!i||!o)return s&&u?s!==u?s:i===o?0:!i^s<0?1:-1:NaN;if(!i[0]||!o[0])return i[0]?s:o[0]?-u:0;if(s!==u)return s;if(r.e!==n.e)return r.e>n.e^s<0?1:-1;for(e=0,t=(u=i.length)<(r=o.length)?u:r;e<t;++e)if(i[e]!==o[e])return i[e]>o[e]^s<0?1:-1;return u===r?0:r<u^s<0?1:-1},h.cosine=h.cos=function(){var n,e,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+D,r.rounding=1,t=function(n,e){var t,r;if(e.isZero())return e;r=(r=e.d.length)<32?(t=Math.ceil(r/3),(1/T(4,t)).toString()):(t=16,"2.3283064365386962890625e-10");n.precision+=t,e=R(n,1,e.times(r),new n(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=t,e}(r,mn(r,t)),r.precision=n,r.rounding=e,P(2==u||3==u?t.neg():t,n,e,!0)):new r(1):new r(NaN)},h.cubeRoot=h.cbrt=function(){var n,e,t,r,i,o,s,u,c,f,a=this,l=a.constructor;if(!a.isFinite()||a.isZero())return new l(a);for(y=!1,(o=a.s*w(a.s*a,1/3))&&Math.abs(o)!=1/0?r=new l(o.toString()):(t=b(a.d),(o=((n=a.e)-t.length+1)%3)&&(t+=1==o||-2==o?"0":"00"),o=w(t,1/3),n=q((n+1)/3)-(n%3==(n<0?-1:2)),(r=new l(t=o==1/0?"5e"+n:(t=o.toExponential()).slice(0,t.indexOf("e")+1)+n)).s=a.s),s=(n=l.precision)+3;;)if(f=(c=(u=r).times(u).times(u)).plus(a),r=x(f.plus(a).times(u),f.plus(c),s+2,1),b(u.d).slice(0,s)===(t=b(r.d)).slice(0,s)){if("9999"!=(t=t.slice(s-3,s+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(P(r,n+1,1),e=!r.times(r).times(r).eq(a));break}if(!i&&(P(u,n+1,0),u.times(u).times(u).eq(a))){r=u;break}s+=4,i=1}return y=!0,P(r,n,l.rounding,e)},h.decimalPlaces=h.dp=function(){var n,e=this.d,t=NaN;if(e){if(t=((n=e.length-1)-q(this.e/D))*D,n=e[n])for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t},h.dividedBy=h.div=function(n){return x(this,new this.constructor(n))},h.dividedToIntegerBy=h.divToInt=function(n){var e=this.constructor;return P(x(this,new e(n),0,1,1),e.precision,e.rounding)},h.equals=h.eq=function(n){return 0===this.cmp(n)},h.floor=function(){return P(new this.constructor(this),this.e+1,3)},h.greaterThan=h.gt=function(n){return 0<this.cmp(n)},h.greaterThanOrEqualTo=h.gte=function(n){n=this.cmp(n);return 1==n||0===n},h.hyperbolicCosine=h.cosh=function(){var n,e,t,r=(u=this).constructor,i=new r(1);if(!u.isFinite())return new r(u.s?1/0:NaN);if(u.isZero())return i;e=r.precision,t=r.rounding,r.precision=e+Math.max(u.e,u.sd())+4,r.rounding=1;for(var o,s=(s=u.d.length)<32?(1/T(4,n=Math.ceil(s/3))).toString():(n=16,"2.3283064365386962890625e-10"),u=R(r,1,u.times(s),new r(1),!0),c=n,f=new r(8);c--;)o=u.times(u),u=i.minus(o.times(f.minus(o.times(f))));return P(u,r.precision=e,r.rounding=t,!0)},h.hyperbolicSine=h.sinh=function(){var n,e,t,r=(s=this).constructor;if(!s.isFinite()||s.isZero())return new r(s);if(n=r.precision,e=r.rounding,r.precision=n+Math.max(s.e,s.sd())+4,r.rounding=1,(t=s.d.length)<3)s=R(r,2,s,s,!0);else for(var i,o=1.4*Math.sqrt(t),s=R(r,2,s=s.times(1/T(5,o=16<o?16:0|o)),s,!0),u=new r(5),c=new r(16),f=new r(20);o--;)i=s.times(s),s=s.times(u.plus(i.times(c.times(i).plus(f))));return P(s,r.precision=n,r.rounding=e,!0)},h.hyperbolicTangent=h.tanh=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,x(t.sinh(),t.cosh(),r.precision=n,r.rounding=e)):new r(t.s)},h.inverseCosine=h.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),r=e.precision,i=e.rounding;return-1!==t?0===t?n.isNeg()?d(e,r,i):new e(0):new e(NaN):n.isZero()?d(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,n=n.asin(),t=d(e,r+4,i).times(.5),e.precision=r,e.rounding=i,t.minus(n))},h.inverseHyperbolicCosine=h.acosh=function(){var n,e,t=this,r=t.constructor;return t.lte(1)?new r(t.eq(1)?0:NaN):t.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(t.e),t.sd())+4,r.rounding=1,y=!1,t=t.times(t).minus(1).sqrt().plus(t),y=!0,r.precision=n,r.rounding=e,t.ln()):new r(t)},h.inverseHyperbolicSine=h.asinh=function(){var n,e,t=this,r=t.constructor;return!t.isFinite()||t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,r.rounding=1,y=!1,t=t.times(t).plus(1).sqrt().plus(t),y=!0,r.precision=n,r.rounding=e,t.ln())},h.inverseHyperbolicTangent=h.atanh=function(){var n,e,t,r=this,i=r.constructor;return r.isFinite()?0<=r.e?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=i.precision,e=i.rounding,t=r.sd(),Math.max(t,n)<2*-r.e-1?P(new i(r),n,e,!0):(i.precision=t=t-r.e,r=x(r.plus(1),new i(1).minus(r),t+n,1),i.precision=n+4,i.rounding=1,r=r.ln(),i.precision=n,i.rounding=e,r.times(.5))):new i(NaN)},h.inverseSine=h.asin=function(){var n,e,t,r=this,i=r.constructor;return r.isZero()?new i(r):(n=r.abs().cmp(1),e=i.precision,t=i.rounding,-1!==n?0===n?((n=d(i,e+4,t).times(.5)).s=r.s,n):new i(NaN):(i.precision=e+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=e,i.rounding=t,r.times(2)))},h.inverseTangent=h.atan=function(){var n,e,t,r,i,o,s,u,c,f=this,a=f.constructor,l=a.precision,h=a.rounding;if(f.isFinite()){if(f.isZero())return new a(f);if(f.abs().eq(1)&&l+4<=on)return(s=d(a,l+4,h).times(.25)).s=f.s,s}else{if(!f.s)return new a(NaN);if(l+4<=on)return(s=d(a,l+4,h).times(.5)).s=f.s,s}for(a.precision=u=l+10,a.rounding=1,n=t=Math.min(28,u/D+2|0);n;--n)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(y=!1,e=Math.ceil(u/D),r=1,c=f.times(f),s=new a(f),i=f;-1!==n;)if(i=i.times(c),o=s.minus(i.div(r+=2)),i=i.times(c),void 0!==(s=o.plus(i.div(r+=2))).d[e])for(n=e;s.d[n]===o.d[n]&&n--;);return t&&(s=s.times(2<<t-1)),y=!0,P(s,a.precision=l,a.rounding=h,!0)},h.isFinite=function(){return!!this.d},h.isInteger=h.isInt=function(){return!!this.d&&q(this.e/D)>this.d.length-2},h.isNaN=function(){return!this.s},h.isNegative=h.isNeg=function(){return this.s<0},h.isPositive=h.isPos=function(){return 0<this.s},h.isZero=function(){return!!this.d&&0===this.d[0]},h.lessThan=h.lt=function(n){return this.cmp(n)<0},h.lessThanOrEqualTo=h.lte=function(n){return this.cmp(n)<1},h.logarithm=h.log=function(n){var e,t,r,i,o,s,u,c,f=this,a=f.constructor,l=a.precision,h=a.rounding;if(null==n)n=new a(10),e=!0;else{if(t=(n=new a(n)).d,n.s<0||!t||!t[0]||n.eq(1))return new a(NaN);e=n.eq(10)}if(t=f.d,f.s<0||!t||!t[0]||f.eq(1))return new a(t&&!t[0]?-1/0:1!=f.s?NaN:t?0:1/0);if(e)if(1<t.length)o=!0;else{for(i=t[0];i%10==0;)i/=10;o=1!==i}if(y=!1,s=_(f,u=l+5),r=e?A(a,u+10):_(n,u),N((c=x(s,r,u,1)).d,i=l,h))do{if(s=_(f,u+=10),r=e?A(a,u+10):_(n,u),c=x(s,r,u,1),!o){+b(c.d).slice(i+1,i+15)+1==1e14&&(c=P(c,l+1,0));break}}while(N(c.d,i+=10,h));return y=!0,P(c,l,h)},h.minus=h.sub=function(n){var e,t,r,i,o,s,u,c,f,a,l,h=this,d=h.constructor;if(n=new d(n),!h.d||!n.d)return h.s&&n.s?h.d?n.s=-n.s:n=new d(n.d||h.s!==n.s?h:NaN):n=new d(NaN),n;if(h.s!=n.s)return n.s=-n.s,h.plus(n);if(f=h.d,l=n.d,u=d.precision,c=d.rounding,!f[0]||!l[0]){if(l[0])n.s=-n.s;else{if(!f[0])return new d(3===c?-0:0);n=new d(h)}return y?P(n,u,c):n}if(t=q(n.e/D),h=q(h.e/D),f=f.slice(),o=h-t){for(s=(a=o<0)?(e=f,o=-o,l.length):(e=l,t=h,f.length),(r=Math.max(Math.ceil(u/D),s)+2)<o&&(o=r,e.length=1),e.reverse(),r=o;r--;)e.push(0);e.reverse()}else{for((a=(r=f.length)<(s=l.length))&&(s=r),r=0;r<s;r++)if(f[r]!=l[r]){a=f[r]<l[r];break}o=0}for(a&&(e=f,f=l,l=e,n.s=-n.s),s=f.length,r=l.length-s;0<r;--r)f[s++]=0;for(r=l.length;o<r;){if(f[--r]<l[r]){for(i=r;i&&0===f[--i];)f[i]=F-1;--f[i],f[r]+=F}f[r]-=l[r]}for(;0===f[--s];)f.pop();for(;0===f[0];f.shift())--t;return f[0]?(n.d=f,n.e=M(f,t),y?P(n,u,c):n):new d(3===c?-0:0)},h.modulo=h.mod=function(n){var e,t=this,r=t.constructor;return n=new r(n),!t.d||!n.s||n.d&&!n.d[0]?new r(NaN):!n.d||t.d&&!t.d[0]?P(new r(t),r.precision,r.rounding):(y=!1,9==r.modulo?(e=x(t,n.abs(),0,3,1)).s*=n.s:e=x(t,n,0,r.modulo,1),e=e.times(n),y=!0,t.minus(e))},h.naturalExponential=h.exp=function(){return dn(this)},h.naturalLogarithm=h.ln=function(){return _(this)},h.negated=h.neg=function(){var n=new this.constructor(this);return n.s=-n.s,P(n)},h.plus=h.add=function(n){var e,t,r,i,o,s,u,c,f=this,a=f.constructor;if(n=new a(n),!f.d||!n.d)return f.s&&n.s?f.d||(n=new a(n.d||f.s===n.s?f:NaN)):n=new a(NaN),n;if(f.s!=n.s)return n.s=-n.s,f.minus(n);if(u=f.d,c=n.d,o=a.precision,s=a.rounding,!u[0]||!c[0])return c[0]||(n=new a(f)),y?P(n,o,s):n;if(a=q(f.e/D),f=q(n.e/D),u=u.slice(),r=a-f){for((i=(i=r<0?(t=u,r=-r,c.length):(t=c,f=a,u.length))<(a=Math.ceil(o/D))?a+1:i+1)<r&&(r=i,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for((i=u.length)-(r=c.length)<0&&(r=i,t=c,c=u,u=t),e=0;r;)e=(u[--r]=u[r]+c[r]+e)/F|0,u[r]%=F;for(e&&(u.unshift(e),++f),i=u.length;0==u[--i];)u.pop();return n.d=u,n.e=M(u,f),y?P(n,o,s):n},h.precision=h.sd=function(n){var e;if(void 0!==n&&n!==!!n&&1!==n&&0!==n)throw Error(m+n);return this.d?(e=fn(this.d),n&&this.e+1>e&&(e=this.e+1)):e=NaN,e},h.round=function(){var n=this.constructor;return P(new n(this),this.e+1,n.rounding)},h.sine=h.sin=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+D,r.rounding=1,t=function(n,e){var t,r=e.d.length;if(r<3)return e.isZero()?e:R(n,2,e,e);t=16<(t=1.4*Math.sqrt(r))?16:0|t,e=e.times(1/T(5,t)),e=R(n,2,e,e);for(var i,o=new n(5),s=new n(16),u=new n(20);t--;)i=e.times(e),e=e.times(o.plus(i.times(s.times(i).minus(u))));return e}(r,mn(r,t)),r.precision=n,r.rounding=e,P(2<u?t.neg():t,n,e,!0)):new r(NaN)},h.squareRoot=h.sqrt=function(){var n,e,t,r,i,o,s=this,u=s.d,c=s.e,f=s.s,a=s.constructor;if(1!==f||!u||!u[0])return new a(!f||f<0&&(!u||u[0])?NaN:u?s:1/0);for(y=!1,r=0==(f=Math.sqrt(+s))||f==1/0?(((e=b(u)).length+c)%2==0&&(e+="0"),f=Math.sqrt(e),c=q((c+1)/2)-(c<0||c%2),new a(e=f==1/0?"5e"+c:(e=f.toExponential()).slice(0,e.indexOf("e")+1)+c)):new a(f.toString()),t=(c=a.precision)+3;;)if(r=(o=r).plus(x(s,o,t+2,1)).times(.5),b(o.d).slice(0,t)===(e=b(r.d)).slice(0,t)){if("9999"!=(e=e.slice(t-3,t+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(P(r,c+1,1),n=!r.times(r).eq(s));break}if(!i&&(P(o,c+1,0),o.times(o).eq(s))){r=o;break}t+=4,i=1}return y=!0,P(r,c,a.rounding,n)},h.tangent=h.tan=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,(t=t.sin()).s=1,t=x(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,P(2==u||4==u?t.neg():t,n,e,!0)):new r(NaN)},h.times=h.mul=function(n){var e,t,r,i,o,s,u,c,f,a=this.constructor,l=this.d,h=(n=new a(n)).d;if(n.s*=this.s,!(l&&l[0]&&h&&h[0]))return new a(!n.s||l&&!l[0]&&!h||h&&!h[0]&&!l?NaN:l&&h?0*n.s:n.s/0);for(t=q(this.e/D)+q(n.e/D),(c=l.length)<(f=h.length)&&(o=l,l=h,h=o,s=c,c=f,f=s),o=[],r=s=c+f;r--;)o.push(0);for(r=f;0<=--r;){for(e=0,i=c+r;r<i;)u=o[i]+h[r]*l[i-r-1]+e,o[i--]=u%F|0,e=u/F|0;o[i]=(o[i]+e)%F|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),n.d=o,n.e=M(o,t),y?P(n,a.precision,a.rounding):n},h.toBinary=function(n,e){return wn(this,2,n,e)},h.toDecimalPlaces=h.toDP=function(n,e){var t=this.constructor,r=new t(this);return void 0===n?r:(v(n,0,p),void 0===e?e=t.rounding:v(e,0,8),P(r,n+r.e+1,e))},h.toExponential=function(n,e){var t=this,r=t.constructor,r=void 0===n?O(t,!0):(v(n,0,p),void 0===e?e=r.rounding:v(e,0,8),O(t=P(new r(t),n+1,e),!0,n+1));return t.isNeg()&&!t.isZero()?"-"+r:r},h.toFixed=function(n,e){var t=this,r=t.constructor,e=void 0===n?O(t):(v(n,0,p),void 0===e?e=r.rounding:v(e,0,8),O(r=P(new r(t),n+t.e+1,e),!1,n+r.e+1));return t.isNeg()&&!t.isZero()?"-"+e:e},h.toFraction=function(n){var e,t,r,i,o,s,u,c,f,a,l=this,h=l.d,d=l.constructor;if(!h)return new d(l);if(c=t=new d(1),r=u=new d(0),o=(e=new d(r)).e=fn(h)-l.e-1,e.d[0]=w(10,(f=o%D)<0?D+f:f),null==n)n=0<o?e:c;else{if(!(s=new d(n)).isInt()||s.lt(c))throw Error(m+s);n=s.gt(e)?0<o?e:c:s}for(y=!1,s=new d(b(h)),f=d.precision,d.precision=o=h.length*D*2;a=x(s,e,0,1,1),1!=(i=t.plus(a.times(r))).cmp(n);)t=r,r=i,i=c,c=u.plus(a.times(i)),u=i,i=e,e=s.minus(a.times(i)),s=i;return i=x(n.minus(t),r,0,1,1),u=u.plus(i.times(c)),t=t.plus(i.times(r)),u.s=c.s=l.s,h=x(c,r,o,1).minus(l).abs().cmp(x(u,t,o,1).minus(l).abs())<1?[c,r]:[u,t],d.precision=f,y=!0,h},h.toHexadecimal=h.toHex=function(n,e){return wn(this,16,n,e)},h.toNearest=function(n,e){var t=(r=this).constructor,r=new t(r);if(null==n){if(!r.d)return r;n=new t(1),e=t.rounding}else{if(n=new t(n),void 0===e?e=t.rounding:v(e,0,8),!r.d)return n.s?r:n;if(!n.d)return n.s&&(n.s=r.s),n}return n.d[0]?(y=!1,r=x(r,n,0,e,1).times(n),y=!0,P(r)):(n.s=r.s,r=n),r},h.toNumber=function(){return+this},h.toOctal=function(n,e){return wn(this,8,n,e)},h.toPower=h.pow=function(n){var e,t,r,i,o,s,u=this,c=u.constructor,f=+(n=new c(n));if(!(u.d&&n.d&&u.d[0]&&n.d[0]))return new c(w(+u,f));if((u=new c(u)).eq(1))return u;if(r=c.precision,o=c.rounding,n.eq(1))return P(u,r,o);if((e=q(n.e/D))>=n.d.length-1&&(t=f<0?-f:f)<=9007199254740991)return i=an(c,u,t,r),n.s<0?new c(1).div(i):P(i,r,o);if((s=u.s)<0){if(e<n.d.length-1)return new c(NaN);if(0==(1&n.d[e])&&(s=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=s,u}return(e=0!=(t=w(+u,f))&&isFinite(t)?new c(t+"").e:q(f*(Math.log("0."+b(u.d))/Math.LN10+u.e+1)))>c.maxE+1||e<c.minE-1?new c(0<e?s/0:0):(y=!1,c.rounding=u.s=1,t=Math.min(12,(e+"").length),(i=(i=dn(n.times(_(u,r+t)),r)).d&&N((i=P(i,r+5,1)).d,r,o)&&+b((i=P(dn(n.times(_(u,(e=r+10)+t)),e),e+5,1)).d).slice(r+1,r+15)+1==1e14?P(i,r+1,0):i).s=s,y=!0,P(i,r,c.rounding=o))},h.toPrecision=function(n,e){var t=this,r=t.constructor,e=void 0===n?O(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(v(n,1,p),void 0===e?e=r.rounding:v(e,0,8),O(t=P(new r(t),n,e),n<=t.e||t.e<=r.toExpNeg,n));return t.isNeg()&&!t.isZero()?"-"+e:e},h.toSignificantDigits=h.toSD=function(n,e){var t=this.constructor;return void 0===n?(n=t.precision,e=t.rounding):(v(n,1,p),void 0===e?e=t.rounding:v(e,0,8)),P(new t(this),n,e)},h.toString=function(){var n=this,e=n.constructor,e=O(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+e:e},h.truncated=h.trunc=function(){return P(new this.constructor(this),this.e+1,1)},h.valueOf=h.toJSON=function(){var n=this,e=n.constructor,e=O(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+e:e};var x=function(n,e,t,r,i,o){var s,u,c,f,a,l,h,d,p,g,m,w,v,y,b,N,E,x,O,M=n.constructor,A=n.s==e.s?1:-1,S=n.d,_=e.d;if(!(S&&S[0]&&_&&_[0]))return new M(n.s&&e.s&&(S?!_||S[0]!=_[0]:_)?S&&0==S[0]||!_?0*A:A/0:NaN);for(u=o?(a=1,n.e-e.e):(o=F,q(n.e/(a=D))-q(e.e/a)),x=_.length,N=S.length,p=(A=new M(A)).d=[],c=0;_[c]==(S[c]||0);c++);if(_[c]>(S[c]||0)&&u--,null==t?(v=t=M.precision,r=M.rounding):v=i?t+(n.e-e.e)+1:t,v<0)p.push(1),l=!0;else{if(v=v/a+2|0,c=0,1==x){for(_=_[f=0],v++;(c<N||f)&&v--;c++)y=f*o+(S[c]||0),p[c]=y/_|0,f=y%_|0;l=f||c<N}else{for(1<(f=o/(_[0]+1)|0)&&(_=sn(_,f,o),S=sn(S,f,o),x=_.length,N=S.length),b=x,m=(g=S.slice(0,x)).length;m<x;)g[m++]=0;for((O=_.slice()).unshift(0),E=_[0],_[1]>=o/2&&++E;f=0,(s=un(_,g,x,m))<0?(w=g[0],1<(f=(w=x!=m?w*o+(g[1]||0):w)/E|0)?1==(s=un(h=sn(_,f=o<=f?o-1:f,o),g,d=h.length,m=g.length))&&(f--,cn(h,x<d?O:_,d,o)):(0==f&&(s=f=1),h=_.slice()),(d=h.length)<m&&h.unshift(0),cn(g,h,m,o),-1==s&&(s=un(_,g,x,m=g.length))<1&&(f++,cn(g,x<m?O:_,m,o)),m=g.length):0===s&&(f++,g=[0]),p[c++]=f,s&&g[0]?g[m++]=S[b]||0:(g=[S[b]],m=1),(b++<N||void 0!==g[0])&&v--;);l=void 0!==g[0]}p[0]||p.shift()}if(1==a)A.e=u,G=l;else{for(c=1,f=p[0];10<=f;f/=10)c++;A.e=c+u*a-1,P(A,i?t+A.e+1:t,r,l)}return A};function sn(n,e,t){var r,i=0,o=n.length;for(n=n.slice();o--;)r=n[o]*e+i,n[o]=r%t|0,i=r/t|0;return i&&n.unshift(i),n}function un(n,e,t,r){var i,o;if(t!=r)o=r<t?1:-1;else for(i=o=0;i<t;i++)if(n[i]!=e[i]){o=n[i]>e[i]?1:-1;break}return o}function cn(n,e,t,r){for(var i=0;t--;)n[t]-=i,i=n[t]<e[t]?1:0,n[t]=i*r+n[t]-e[t];for(;!n[0]&&1<n.length;)n.shift()}function P(n,e,t,r){var i,o,s,u,c,f,a,l,h=n.constructor;n:if(null!=e){if(!(a=n.d))return n;for(i=1,u=a[0];10<=u;u/=10)i++;if((o=e-i)<0)o+=D,s=e,c=(f=a[l=0])/w(10,i-s-1)%10|0;else if(l=Math.ceil((o+1)/D),(u=a.length)<=l){if(!r)break n;for(;u++<=l;)a.push(0);f=c=0,s=(o%=D)-D+(i=1)}else{for(f=u=a[l],i=1;10<=u;u/=10)i++;c=(s=(o%=D)-D+i)<0?0:f/w(10,i-s-1)%10|0}if(r=r||e<0||void 0!==a[l+1]||(s<0?f:f%w(10,i-s-1)),c=t<4?(c||r)&&(0==t||t==(n.s<0?3:2)):5<c||5==c&&(4==t||r||6==t&&(0<o?0<s?f/w(10,i-s):0:a[l-1])%10&1||t==(n.s<0?8:7)),e<1||!a[0])return a.length=0,c?(e-=n.e+1,a[0]=w(10,(D-e%D)%D),n.e=-e||0):a[0]=n.e=0,n;if(0==o?(a.length=l,u=1,l--):(a.length=l+1,u=w(10,D-o),a[l]=0<s?(f/w(10,i-s)%w(10,s)|0)*u:0),c)for(;;){if(0==l){for(o=1,s=a[0];10<=s;s/=10)o++;for(s=a[0]+=u,u=1;10<=s;s/=10)u++;o!=u&&(n.e++,a[0]==F&&(a[0]=1));break}if(a[l]+=u,a[l]!=F)break;a[l--]=0,u=1}for(o=a.length;0===a[--o];)a.pop()}return y&&(n.e>h.maxE?(n.d=null,n.e=NaN):n.e<h.minE&&(n.e=0,n.d=[0])),n}function O(n,e,t){if(!n.isFinite())return pn(n);var r,i=n.e,o=b(n.d),s=o.length;return e?(t&&0<(r=t-s)?o=o.charAt(0)+"."+o.slice(1)+S(r):1<s&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(n.e<0?"e":"e+")+n.e):i<0?(o="0."+S(-i-1)+o,t&&0<(r=t-s)&&(o+=S(r))):s<=i?(o+=S(i+1-s),t&&0<(r=t-i-1)&&(o=o+"."+S(r))):((r=i+1)<s&&(o=o.slice(0,r)+"."+o.slice(r)),t&&0<(r=t-s)&&(i+1===s&&(o+="."),o+=S(r))),o}function M(n,e){var t=n[0];for(e*=D;10<=t;t/=10)e++;return e}function A(n,e,t){if(rn<e)throw y=!0,t&&(n.precision=t),Error(Q);return P(new n(f),e,1,!0)}function d(n,e,t){if(on<e)throw Error(Q);return P(new n(a),e,t,!0)}function fn(n){var e=n.length-1,t=e*D+1;if(e=n[e]){for(;e%10==0;e/=10)t--;for(e=n[0];10<=e;e/=10)t++}return t}function S(n){for(var e="";n--;)e+="0";return e}function an(n,e,t,r){var i,o=new n(1),s=Math.ceil(r/D+4);for(y=!1;;){if(t%2&&vn((o=o.times(e)).d,s)&&(i=!0),0===(t=q(t/2))){t=o.d.length-1,i&&0===o.d[t]&&++o.d[t];break}vn((e=e.times(e)).d,s)}return y=!0,o}function ln(n){return 1&n.d[n.d.length-1]}function hn(n,e,t){for(var r,i=new n(e[0]),o=0;++o<e.length;){if(!(r=new n(e[o])).s){i=r;break}i[t](r)&&(i=r)}return i}function dn(n,e){var t,r,i,o,s,u,c,f=0,a=0,l=0,h=n.constructor,d=h.rounding,p=h.precision;if(!n.d||!n.d[0]||17<n.e)return new h(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(c=null==e?(y=!1,p):e,u=new h(.03125);-2<n.e;)n=n.times(u),l+=5;for(c+=r=Math.log(w(2,l))/Math.LN10*2+5|0,t=o=s=new h(1),h.precision=c;;){if(o=P(o.times(n),c,1),t=t.times(++a),b((u=s.plus(x(o,t,c,1))).d).slice(0,c)===b(s.d).slice(0,c)){for(i=l;i--;)s=P(s.times(s),c,1);if(null!=e)return h.precision=p,s;if(!(f<3&&N(s.d,c-r,d,f)))return P(s,h.precision=p,d,y=!0);h.precision=c+=10,t=o=u=new h(1),a=0,f++}s=u}}function _(n,e){var t,r,i,o,s,u,c,f,a,l,h,d=1,p=n,g=p.d,m=p.constructor,w=m.rounding,v=m.precision;if(p.s<0||!g||!g[0]||!p.e&&1==g[0]&&1==g.length)return new m(g&&!g[0]?-1/0:1!=p.s?NaN:g?0:p);if(a=null==e?(y=!1,v):e,m.precision=a+=10,r=(t=b(g)).charAt(0),!(Math.abs(o=p.e)<15e14))return f=A(m,a+2,v).times(o+""),p=_(new m(r+"."+t.slice(1)),a-10).plus(f),m.precision=v,null==e?P(p,v,w,y=!0):p;for(;r<7&&1!=r||1==r&&3<t.charAt(1);)r=(t=b((p=p.times(n)).d)).charAt(0),d++;for(o=p.e,1<r?(p=new m("0."+t),o++):p=new m(r+"."+t.slice(1)),c=s=p=x((l=p).minus(1),p.plus(1),a,1),h=P(p.times(p),a,1),i=3;;){if(s=P(s.times(h),a,1),b((f=c.plus(x(s,new m(i),a,1))).d).slice(0,a)===b(c.d).slice(0,a)){if(c=c.times(2),0!==o&&(c=c.plus(A(m,a+2,v).times(o+""))),c=x(c,new m(d),a,1),null!=e)return m.precision=v,c;if(!N(c.d,a-10,w,u))return P(c,m.precision=v,w,y=!0);m.precision=a+=10,f=s=p=x(l.minus(1),l.plus(1),a,1),h=P(p.times(p),a,1),i=u=1}c=f,i+=2}}function pn(n){return String(n.s*n.s/0)}function gn(n,e){var t,r,i;for(0<(r=(e=-1<(t=e.indexOf("."))?e.replace(".",""):e).search(/e/i))?(t<0&&(t=r),t+=+e.slice(r+1),e=e.substring(0,r)):t<0&&(t=e.length),r=0;48===e.charCodeAt(r);r++);for(i=e.length;48===e.charCodeAt(i-1);--i);if(e=e.slice(r,i)){if(i-=r,n.e=t=t-r-1,n.d=[],r=(t+1)%D,t<0&&(r+=D),r<i){for(r&&n.d.push(+e.slice(0,r)),i-=D;r<i;)n.d.push(+e.slice(r,r+=D));e=e.slice(r),r=D-e.length}else r-=i;for(;r--;)e+="0";n.d.push(+e),y&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function R(n,e,t,r,i){var o,s,u,c,f=n.precision,a=Math.ceil(f/D);for(y=!1,c=t.times(t),u=new n(r);;){if(s=x(u.times(c),new n(e++*e++),f,1),u=i?r.plus(s):r.minus(s),r=x(s.times(c),new n(e++*e++),f,1),void 0!==(s=u.plus(r)).d[a]){for(o=a;s.d[o]===u.d[o]&&o--;);if(-1==o)break}o=u,u=r,r=s,s=o}return y=!0,s.d.length=a+1,s}function T(n,e){for(var t=n;--e;)t*=n;return t}function mn(n,e){var t,r=e.s<0,n=d(n,n.precision,1),i=n.times(.5);if((e=e.abs()).lte(i))return u=r?4:1,e;if((t=e.divToInt(n)).isZero())u=r?3:2;else{if((e=e.minus(t.times(n))).lte(i))return u=ln(t)?r?2:3:r?4:1,e;u=ln(t)?r?1:4:r?3:2}return e.minus(n).abs()}function wn(n,e,t,r){var i,o,s,u,c,f,a,l,h=n.constructor,d=void 0!==t;if(d?(v(t,1,p),void 0===r?r=h.rounding:v(r,0,8)):(t=h.precision,r=h.rounding),n.isFinite()){for(d?(i=2,16==e?t=4*t-3:8==e&&(t=3*t-2)):i=e,0<=(s=(f=O(n)).indexOf("."))&&(f=f.replace(".",""),(l=new h(1)).e=f.length-s,l.d=E(O(l),10,i),l.e=l.d.length),o=u=(a=E(f,10,i)).length;0==a[--u];)a.pop();if(a[0]){if(s<0?o--:((n=new h(n)).d=a,n.e=o,a=(n=x(n,l,t,r,0,i)).d,o=n.e,c=G),s=a[t],h=i/2,c=c||void 0!==a[t+1],c=r<4?(void 0!==s||c)&&(0===r||r===(n.s<0?3:2)):h<s||s===h&&(4===r||c||6===r&&1&a[t-1]||r===(n.s<0?8:7)),a.length=t,c)for(;++a[--t]>i-1;)a[t]=0,t||(++o,a.unshift(1));for(u=a.length;!a[u-1];--u);for(s=0,f="";s<u;s++)f+=g.charAt(a[s]);if(d){if(1<u)if(16==e||8==e){for(s=16==e?4:3,--u;u%s;u++)f+="0";for(u=(a=E(f,i,e)).length;!a[u-1];--u);for(s=1,f="1.";s<u;s++)f+=g.charAt(a[s])}else f=f.charAt(0)+"."+f.slice(1);f=f+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)f="0"+f;f="0."+f}else if(++o>u)for(o-=u;o--;)f+="0";else o<u&&(f=f.slice(0,o)+"."+f.slice(o))}else f=d?"0p+0":"0";f=(16==e?"0x":2==e?"0b":8==e?"0o":"")+f}else f=pn(n);return n.s<0?"-"+f:f}function vn(n,e){return n.length>e&&(n.length=e,1)}function yn(n){return new this(n).abs()}function bn(n){return new this(n).acos()}function Nn(n){return new this(n).acosh()}function En(n,e){return new this(n).plus(e)}function xn(n){return new this(n).asin()}function On(n){return new this(n).asinh()}function Mn(n){return new this(n).atan()}function An(n){return new this(n).atanh()}function Sn(n,e){n=new this(n),e=new this(e);var t,r=this.precision,i=this.rounding,o=r+4;return n.s&&e.s?n.d||e.d?!e.d||n.isZero()?(t=e.s<0?d(this,r,i):new this(0)).s=n.s:!n.d||e.isZero()?(t=d(this,o,1).times(.5)).s=n.s:t=e.s<0?(this.precision=o,this.rounding=1,t=this.atan(x(n,e,o,1)),e=d(this,o,1),this.precision=r,this.rounding=i,n.s<0?t.minus(e):t.plus(e)):this.atan(x(n,e,o,1)):(t=d(this,o,1).times(0<e.s?.25:.75)).s=n.s:t=new this(NaN),t}function _n(n){return new this(n).cbrt()}function qn(n){return P(n=new this(n),n.e+1,2)}function Fn(n,e,t){return new this(n).clamp(e,t)}function Dn(n){if(!n||"object"!==s(n))throw Error(l+"Object expected");for(var e,t,r=!0===n.defaults,i=["precision",1,p,"rounding",0,8,"toExpNeg",-c,0,"toExpPos",0,c,"maxE",0,c,"minE",-c,0,"modulo",0,9],o=0;o<i.length;o+=3)if(e=i[o],r&&(this[e]=K[e]),void 0!==(t=n[e])){if(!(q(t)===t&&i[o+1]<=t&&t<=i[o+2]))throw Error(m+e+": "+t);this[e]=t}if(e="crypto",r&&(this[e]=K[e]),void 0!==(t=n[e])){if(!0!==t&&!1!==t&&0!==t&&1!==t)throw Error(m+e+": "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(X);this[e]=!0}else this[e]=!1}return this}function Pn(n){return new this(n).cos()}function Rn(n){return new this(n).cosh()}function Tn(n,e){return new this(n).div(e)}function Zn(n){return new this(n).exp()}function jn(n){return P(n=new this(n),n.e+1,3)}function kn(){var n,e,t=new this(0);for(y=!1,n=0;n<arguments.length;)if((e=new this(arguments[n++])).d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return y=!0,new this(1/0);t=e}return y=!0,t.sqrt()}function Un(n){return n instanceof Z||n&&n.toStringTag===t||!1}function In(n){return new this(n).ln()}function Ln(n,e){return new this(n).log(e)}function Cn(n){return new this(n).log(2)}function $n(n){return new this(n).log(10)}function Hn(){return hn(this,arguments,"lt")}function Bn(){return hn(this,arguments,"gt")}function Vn(n,e){return new this(n).mod(e)}function zn(n,e){return new this(n).mul(e)}function Wn(n,e){return new this(n).pow(e)}function Jn(n){var e,t,r,i,o=0,s=new this(1),u=[];if(void 0===n?n=this.precision:v(n,1,p),r=Math.ceil(n/D),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(r));o<r;)429e7<=(i=e[o])?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:u[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(X);for(e=crypto.randomBytes(r*=4);o<r;)214e7<=(i=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((127&e[o+3])<<24))?crypto.randomBytes(4).copy(e,o):(u.push(i%1e7),o+=4);o=r/4}else for(;o<r;)u[o++]=1e7*Math.random()|0;for(r=u[--o],n%=D,r&&n&&(i=w(10,D-n),u[o]=(r/i|0)*i);0===u[o];o--)u.pop();if(o<0)u=[t=0];else{for(t=-1;0===u[0];t-=D)u.shift();for(r=1,i=u[0];10<=i;i/=10)r++;r<D&&(t-=D-r)}return s.e=t,s.d=u,s}function Gn(n){return P(n=new this(n),n.e+1,this.rounding)}function Kn(n){return(n=new this(n)).d?n.d[0]?n.s:0*n.s:n.s||NaN}function Qn(n){return new this(n).sin()}function Xn(n){return new this(n).sinh()}function Yn(n){return new this(n).sqrt()}function ne(n,e){return new this(n).sub(e)}function ee(){var n=0,e=arguments,t=new this(e[n]);for(y=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return y=!0,P(t,this.precision,this.rounding)}function te(n){return new this(n).tan()}function re(n){return new this(n).tanh()}function ie(n){return P(n=new this(n),n.e+1,1)}h[Symbol.for("nodejs.util.inspect.custom")]=h.toString,h[Symbol.toStringTag]="Decimal";var Z=h.constructor=function n(e){var t,r,i;function o(n){var e,t,r,i=this;if(!(i instanceof o))return new o(n);if(i.constructor=o,Un(n))return i.s=n.s,void(y?!n.d||n.e>o.maxE?(i.e=NaN,i.d=null):n.e<o.minE?(i.e=0,i.d=[0]):(i.e=n.e,i.d=n.d.slice()):(i.e=n.e,i.d=n.d&&n.d.slice()));if("number"===(r=s(n))){if(0===n)return i.s=1/n<0?-1:1,i.e=0,void(i.d=[0]);if(n<0?(n=-n,i.s=-1):i.s=1,n===~~n&&n<1e7){for(e=0,t=n;10<=t;t/=10)e++;return void(y?o.maxE<e?(i.e=NaN,i.d=null):e<o.minE?(i.e=0,i.d=[0]):(i.e=e,i.d=[n]):(i.e=e,i.d=[n]))}return 0*n!=0?(n||(i.s=NaN),i.e=NaN,void(i.d=null)):gn(i,n.toString())}if("string"!==r)throw Error(m+n);return 45===(t=n.charCodeAt(0))?(n=n.slice(1),i.s=-1):(43===t&&(n=n.slice(1)),i.s=1),(tn.test(n)?gn:function(n,e){var t,r,i,o,s,u,c,f;if(-1<e.indexOf("_")){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),tn.test(e))return gn(n,e)}else if("Infinity"===e||"NaN"===e)return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(nn.test(e))t=16,e=e.toLowerCase();else if(Y.test(e))t=2;else{if(!en.test(e))throw Error(m+e);t=8}for(o=(e=0<(o=e.search(/p/i))?(c=+e.slice(o+1),e.substring(2,o)):e.slice(2)).indexOf("."),r=n.constructor,(s=0<=o)&&(o=(u=(e=e.replace(".","")).length)-o,i=an(r,new r(t),o,2*o)),o=e=(f=E(e,t,F)).length-1;0===f[o];--o)f.pop();return o<0?new r(0*n.s):(n.e=M(f,e),n.d=f,y=!1,s&&(n=x(n,i,4*u)),c&&(n=n.times(Math.abs(c)<54?w(2,c):Z.pow(2,c))),y=!0,n)})(i,n)}if(o.prototype=h,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=Dn,o.clone=n,o.isDecimal=Un,o.abs=yn,o.acos=bn,o.acosh=Nn,o.add=En,o.asin=xn,o.asinh=On,o.atan=Mn,o.atanh=An,o.atan2=Sn,o.cbrt=_n,o.ceil=qn,o.clamp=Fn,o.cos=Pn,o.cosh=Rn,o.div=Tn,o.exp=Zn,o.floor=jn,o.hypot=kn,o.ln=In,o.log=Ln,o.log10=$n,o.log2=Cn,o.max=Hn,o.min=Bn,o.mod=Vn,o.mul=zn,o.pow=Wn,o.random=Jn,o.round=Gn,o.sign=Kn,o.sin=Qn,o.sinh=Xn,o.sqrt=Yn,o.sub=ne,o.sum=ee,o.tan=te,o.tanh=re,o.trunc=ie,(e=void 0===e?{}:e)&&!0!==e.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<i.length;)e.hasOwnProperty(r=i[t++])||(e[r]=this[r]);return o.config(e),o}(K);function oe(n,e){var t="",r=(t=Z.isDecimal(n)?n.toFixed():"string"!=typeof n?n.toString():n,null),n=null,i=null,o=e.match(/(<=|>=|=)\s*(\d+)/);if(o&&(n=o[1],r=Number(o[2])),e.includes(",")&&(i=!0),null!==r){var o=t.split("."),e=o[0],s=1===o.length?"":o[1],u=s.length;switch(n){case"<=":s=u<=r?s:s.slice(0,r);break;case"=":u<r?s+="0".repeat(r-u):r<u&&(s=s.slice(0,r));break;case">=":s=r<=u?s:s+"0".repeat(r-u)}t=""===s?e:"".concat(e,".").concat(s)}return t=null!==i?1<(o=t.split(".")).length?((n=o[0]).includes("-")?o[0]=n[0]+n.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):o[0]=n.replace(/(?=(?!^)(?:\d{3})+$)/g,","),o.join(".")):(e=o[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function se(n){for(var e=[],t=0,r=null,i=n.length;t<i;)if(r=n[t],/\s/.test(r))t++;else if("+-".includes(r)){var o=e[e.length-1];if(0===e.length||"+-".includes(o)||"("===o){for(var s=r,r=n[++t];/[a-zA-Z\d._]/.test(r);)s+=r,r=n[++t];e.push(s)}else e.push(r),t++}else if("*/%()".includes(r))e.push(r),t++;else if(/[a-zA-Z_]/.test(r)){for(var u="";/[a-zA-Z0-9_]/.test(r)&&(u+=r,!(++t>=i));)r=n[t];e.push(u)}else if(/\d/.test(r)){for(var c="";/[\d.]/.test(r)&&(c+=r,!(++t>=i));)r=n[t];e.push(c)}return e}var f=new Z(f),a=new Z(a),ue=function(){L(r,e(Error));var t=B(r);function r(n){var e;return k(this,r),(e=t.call(this,n)).name="CalculatorError",e.message=n,e}return I(r)}(),ce=function(){L(r,e(Error));var t=B(r);function r(n){var e;return k(this,r),(e=t.call(this,n)).name="TokensFillError",e.message=n,e}return I(r)}();function j(n,e){var t=e._fillData;return void 0===e._fillData&&(t=e),n.map(function(n){if(/^[a-zA-z_][\w_]*$/.test(n)){var e=t[n];if(void 0!==e)return"number"==typeof e?e.toString():e;throw new ce("错误的参数:".concat(n," 请确认他存在"))}return n})}function fe(n){for(var e,t=[],r=[],i=n;0<i.length;){var o=i.shift();if(z(o))if("("===o)t.push(o);else if(")"===o){for(var s=t.pop();"("!==s&&0<t.length;)r.push(s),s=t.pop();if("("!==s)throw"error: unmatched ()"}else{for(;e=t[t.length-1],W(o)<=W(e)&&0<t.length;)r.push(t.pop());t.push(o)}else r.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)r.push(t.pop())}return r}function ae(n){for(var e=[];0<n.length;){var t=n.shift();if(z(t)){if(e.length<2)throw new ue("错误的栈长度, 可能是无法计算的表达式");var r=e.pop(),i=e.pop();switch("string"==typeof r&&(r=new Z(r)),"string"==typeof i&&(i=new Z(i)),t){case"+":e.push(i.add(r));break;case"-":e.push(i.sub(r));break;case"*":e.push(i.mul(r));break;case"/":e.push(i.div(r));break;case"%":e.push(i.mod(r))}}else e.push(t)}if(1!==e.length)throw"unvalid expression";return e[0]}return n.calc=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];var r=J(e),i=se(r.expr),o=null;if(null!==r.data)if(null===(o=void 0!==r.data._fillData?r.data:o)||void 0===o.fillError&&void 0===o.error)i=j(i,r.data);else try{i=j(i,r.data)}catch(n){if(n instanceof ce)return o.fillError||o.error;throw n}var i=fe(i),s=null;if(null!==o){if(void 0!==o.calcError||void 0!==o.error)try{s=ae(i)}catch(n){if(n instanceof ue)return void 0!==o.calcError?o.calcError:o.error;throw n}}else s=ae(i);return s=null!==r.fmt?oe(s,r.fmt):null!==s?s.toFixed():null},n.fmt=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];var r=J(e),i=se(r.expr),o=null;if(2<i.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(r.expr));if(1!==i.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==r.data)if(null===(o=void 0!==r.data._fillData?r.data:o)||void 0===o.fillError&&void 0===o.error)i=j(i,r.data);else try{i=j(i,r.data)}catch(n){if(n instanceof TokensFillError)return o.fillError||o.error;throw n}if(null===r.fmt)throw"表达式没有格式化部分";return oe(i[0],r.fmt)},n.version="0.0.30",Object.defineProperty(n,"__esModule",{value:!0}),n}({});
|
package/calc.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export function calc (...args: any): string;
|
|
2
|
+
|
|
3
|
+
export function fmt (...args: any): string;
|
|
4
|
+
|
|
5
|
+
export const version: string;
|
|
3
6
|
|
|
4
|
-
export function fmt (...args: any): string;
|
|
5
|
-
}
|
|
6
7
|
|
|
7
|
-
export default a_calc;
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Decimal=require("decimal.js");function _interopDefaultLegacy(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var Decimal__default=_interopDefaultLegacy(Decimal);function _classCallCheck(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function _createClass(r,e,t){return e&&_defineProperties(r.prototype,e),t&&_defineProperties(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function _inherits(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&_setPrototypeOf(r,e)}function _getPrototypeOf(r){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function _setPrototypeOf(r,e){return(_setPrototypeOf=Object.setPrototypeOf||function(r,e){return r.__proto__=e,r})(r,e)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(r){return!1}}function _construct(r,e,t){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(r,e,t){var n=[null];n.push.apply(n,e);e=new(Function.bind.apply(r,n));return t&&_setPrototypeOf(e,t.prototype),e}).apply(null,arguments)}function _isNativeFunction(r){return-1!==Function.toString.call(r).indexOf("[native code]")}function _wrapNativeSuper(r){var t="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(r){if(null===r||!_isNativeFunction(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(r))return t.get(r);t.set(r,e)}function e(){return _construct(r,arguments,_getPrototypeOf(this).constructor)}return e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(e,r)})(r)}function _assertThisInitialized(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function _possibleConstructorReturn(r,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(r)}function _createSuper(t){var n=_isNativeReflectConstruct();return function(){var r,e=_getPrototypeOf(t);return _possibleConstructorReturn(this,n?(r=_getPrototypeOf(this).constructor,Reflect.construct(e,arguments,r)):e.apply(this,arguments))}}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _unsupportedIterableToArray(r,e){if(r){if("string"==typeof r)return _arrayLikeToArray(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(t="Object"===t&&r.constructor?r.constructor.name:t)||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,e):void 0}}function _arrayLikeToArray(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function _nonIterableSpread(){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 isOperator(r){return-1<"+-*/%()".indexOf(r)}function getPrioraty(r){switch(r){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(r,e){return getPrioraty(r)<=getPrioraty(e)}function isObj(r){return"[object Object]"===Object.prototype.toString.call(r)&&!Array.isArray(r)}function parseArgs(r){var e={expr:"",fmt:null,data:null},t="",n=r[0];if(1===r.length)"string"==typeof n?t=n:"number"==typeof n?t=n.toString():Array.isArray(n)&&(t=n[0]);else if(1<r.length){n=r[r.length-1];if(isObj(n))t=r[0],e.data=n;else for(var o=_toConsumableArray(r.shift());o.length||r.length;)var a=0===o.length?"":o.shift(),i=0===r.length?"":r.shift(),t=t+a+(i="number"==typeof i?i.toString():i)}var n=t.split("|");return 1===n.length?e.expr=n[0]:(e.expr=n[0],""!==(n=n[1]).trim()&&(e.fmt=n)),e}function format(r,e){var t="",n=(t=Decimal__default.default.isDecimal(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,a=e.match(/(<=|>=|=)\s*(\d+)/);if(a&&(r=a[1],n=Number(a[2])),e.includes(",")&&(o=!0),null!==n){var a=t.split("."),e=a[0],i=1===a.length?"":a[1],l=i.length;switch(r){case"<=":i=l<=n?i:i.slice(0,n);break;case"=":l<n?i+="0".repeat(n-l):n<l&&(i=i.slice(0,n));break;case">=":i=n<=l?i:i+"0".repeat(n-l)}t=""===i?e:"".concat(e,".").concat(i)}return t=null!==o?1<(a=t.split(".")).length?((r=a[0]).includes("-")?a[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):a[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),a.join(".")):(e=a[0]).includes("-")?e[0]+e.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):e.replace(/(?=(?!^)(?:\d{3})+$)/g,","):t}function tokenizer(r){for(var e=[],t=0,n=null,o=r.length;t<o;)if(n=r[t],/\s/.test(n))t++;else if("+-".includes(n)){var a=e[e.length-1];if(0===e.length||"+-".includes(a)||"("===a){for(var i=n,n=r[++t];/[a-zA-Z\d._]/.test(n);)i+=n,n=r[++t];e.push(i)}else e.push(n),t++}else if("*/%()".includes(n))e.push(n),t++;else if(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++t>=o));)n=r[t];e.push(l)}else if(/\d/.test(n)){for(var u="";/[\d.]/.test(n)&&(u+=n,!(++t>=o));)n=r[t];e.push(u)}return e}var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var t=_createSuper(n);function n(r){var e;return _classCallCheck(this,n),(e=t.call(this,r)).name="CalculatorError",e.message=r,e}return _createClass(n)}(),TokensFillError$1=function(){_inherits(n,_wrapNativeSuper(Error));var t=_createSuper(n);function n(r){var e;return _classCallCheck(this,n),(e=t.call(this,r)).name="TokensFillError",e.message=r,e}return _createClass(n)}();function fillTokens(r,e){var t=e._fillData;return void 0===e._fillData&&(t=e),r.map(function(r){if(/^[a-zA-z_][\w_]*$/.test(r)){var e=t[r];if(void 0!==e)return"number"==typeof e?e.toString():e;throw new TokensFillError$1("错误的参数:".concat(r," 请确认他存在"))}return r})}function fmt(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=parseArgs(e),o=tokenizer(n.expr),a=null;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data)if(null===(a=void 0!==n.data._fillData?n.data:a)||void 0===a.fillError&&void 0===a.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError)return a.fillError||a.error;throw r}if(null===n.fmt)throw"表达式没有格式化部分";return format(o[0],n.fmt)}var version="0.0.30";function token2postfix(r){for(var e=[],t=[],n=r;0<n.length;){var o=n.shift();if(isOperator(o))if("("===o)e.push(o);else if(")"===o){for(var a=e.pop();"("!==a&&0<e.length;)t.push(a),a=e.pop();if("("!==a)throw"error: unmatched ()"}else{for(;prioraty(o,e[e.length-1])&&0<e.length;)t.push(e.pop());e.push(o)}else t.push(o)}if(0<e.length){if(")"===e[e.length-1]||"("===e[e.length-1])throw"error: unmatched ()";for(;0<e.length;)t.push(e.pop())}return t}function evalPostfix(r){for(var e=[];0<r.length;){var t=r.shift();if(isOperator(t)){if(e.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var n=e.pop(),o=e.pop();switch("string"==typeof n&&(n=new Decimal__default.default(n)),"string"==typeof o&&(o=new Decimal__default.default(o)),t){case"+":e.push(o.add(n));break;case"-":e.push(o.sub(n));break;case"*":e.push(o.mul(n));break;case"/":e.push(o.div(n));break;case"%":e.push(o.mod(n))}}else e.push(t)}if(1!==e.length)throw"unvalid expression";return e[0]}function calc(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=parseArgs(e),o=tokenizer(n.expr),a=null;if(null!==n.data)if(null===(a=void 0!==n.data._fillData?n.data:a)||void 0===a.fillError&&void 0===a.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError$1)return a.fillError||a.error;throw r}var o=token2postfix(o),i=null;if(null!==a){if(void 0!==a.calcError||void 0!==a.error)try{i=evalPostfix(o)}catch(r){if(r instanceof CalculatorError)return void 0!==a.calcError?a.calcError:a.error;throw r}}else i=evalPostfix(o);return i=null!==n.fmt?format(i,n.fmt):null!==i?i.toFixed():null}exports.calc=calc,exports.fmt=fmt,exports.version=version;
|
package/cjs/package.json
ADDED
package/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Decimal from"decimal.js";function _classCallCheck(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(r,t){for(var e=0;e<t.length;e++){var n=t[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,n.key,n)}}function _createClass(r,t,e){return t&&_defineProperties(r.prototype,t),e&&_defineProperties(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function _inherits(r,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(t&&t.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),t&&_setPrototypeOf(r,t)}function _getPrototypeOf(r){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(r){return r.__proto__||Object.getPrototypeOf(r)})(r)}function _setPrototypeOf(r,t){return(_setPrototypeOf=Object.setPrototypeOf||function(r,t){return r.__proto__=t,r})(r,t)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(r){return!1}}function _construct(r,t,e){return(_construct=_isNativeReflectConstruct()?Reflect.construct:function(r,t,e){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(r,n));return e&&_setPrototypeOf(t,e.prototype),t}).apply(null,arguments)}function _isNativeFunction(r){return-1!==Function.toString.call(r).indexOf("[native code]")}function _wrapNativeSuper(r){var e="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(r){if(null===r||!_isNativeFunction(r))return r;if("function"!=typeof r)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(r))return e.get(r);e.set(r,t)}function t(){return _construct(r,arguments,_getPrototypeOf(this).constructor)}return t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(t,r)})(r)}function _assertThisInitialized(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function _possibleConstructorReturn(r,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(r)}function _createSuper(e){var n=_isNativeReflectConstruct();return function(){var r,t=_getPrototypeOf(e);return _possibleConstructorReturn(this,n?(r=_getPrototypeOf(this).constructor,Reflect.construct(t,arguments,r)):t.apply(this,arguments))}}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _unsupportedIterableToArray(r,t){if(r){if("string"==typeof r)return _arrayLikeToArray(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);return"Map"===(e="Object"===e&&r.constructor?r.constructor.name:e)||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?_arrayLikeToArray(r,t):void 0}}function _arrayLikeToArray(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function _nonIterableSpread(){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 isOperator(r){return-1<"+-*/%()".indexOf(r)}function getPrioraty(r){switch(r){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function prioraty(r,t){return getPrioraty(r)<=getPrioraty(t)}function isObj(r){return"[object Object]"===Object.prototype.toString.call(r)&&!Array.isArray(r)}function parseArgs(r){var t={expr:"",fmt:null,data:null},e="",n=r[0];if(1===r.length)"string"==typeof n?e=n:"number"==typeof n?e=n.toString():Array.isArray(n)&&(e=n[0]);else if(1<r.length){n=r[r.length-1];if(isObj(n))e=r[0],t.data=n;else for(var o=_toConsumableArray(r.shift());o.length||r.length;)var i=0===o.length?"":o.shift(),a=0===r.length?"":r.shift(),e=e+i+(a="number"==typeof a?a.toString():a)}var n=e.split("|");return 1===n.length?t.expr=n[0]:(t.expr=n[0],""!==(n=n[1]).trim()&&(t.fmt=n)),t}function format(r,t){var e="",n=(e=Decimal.isDecimal(r)?r.toFixed():"string"!=typeof r?r.toString():r,null),r=null,o=null,i=t.match(/(<=|>=|=)\s*(\d+)/);if(i&&(r=i[1],n=Number(i[2])),t.includes(",")&&(o=!0),null!==n){var i=e.split("."),t=i[0],a=1===i.length?"":i[1],l=a.length;switch(r){case"<=":a=l<=n?a:a.slice(0,n);break;case"=":l<n?a+="0".repeat(n-l):n<l&&(a=a.slice(0,n));break;case">=":a=n<=l?a:a+"0".repeat(n-l)}e=""===a?t:"".concat(t,".").concat(a)}return e=null!==o?1<(i=e.split(".")).length?((r=i[0]).includes("-")?i[0]=r[0]+r.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):i[0]=r.replace(/(?=(?!^)(?:\d{3})+$)/g,","),i.join(".")):(t=i[0]).includes("-")?t[0]+t.slice(1).replace(/(?=(?!^)(?:\d{3})+$)/g,","):t.replace(/(?=(?!^)(?:\d{3})+$)/g,","):e}function tokenizer(r){for(var t=[],e=0,n=null,o=r.length;e<o;)if(n=r[e],/\s/.test(n))e++;else if("+-".includes(n)){var i=t[t.length-1];if(0===t.length||"+-".includes(i)||"("===i){for(var a=n,n=r[++e];/[a-zA-Z\d._]/.test(n);)a+=n,n=r[++e];t.push(a)}else t.push(n),e++}else if("*/%()".includes(n))t.push(n),e++;else if(/[a-zA-Z_]/.test(n)){for(var l="";/[a-zA-Z0-9_]/.test(n)&&(l+=n,!(++e>=o));)n=r[e];t.push(l)}else if(/\d/.test(n)){for(var u="";/[\d.]/.test(n)&&(u+=n,!(++e>=o));)n=r[e];t.push(u)}return t}var CalculatorError=function(){_inherits(n,_wrapNativeSuper(Error));var e=_createSuper(n);function n(r){var t;return _classCallCheck(this,n),(t=e.call(this,r)).name="CalculatorError",t.message=r,t}return _createClass(n)}(),TokensFillError$1=function(){_inherits(n,_wrapNativeSuper(Error));var e=_createSuper(n);function n(r){var t;return _classCallCheck(this,n),(t=e.call(this,r)).name="TokensFillError",t.message=r,t}return _createClass(n)}();function fillTokens(r,t){var e=t._fillData;return void 0===t._fillData&&(e=t),r.map(function(r){if(/^[a-zA-z_][\w_]*$/.test(r)){var t=e[r];if(void 0!==t)return"number"==typeof t?t.toString():t;throw new TokensFillError$1("错误的参数:".concat(r," 请确认他存在"))}return r})}function fmt(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=parseArgs(t),o=tokenizer(n.expr),i=null;if(2<o.length)throw new Error("fmt并非用于计算, 不能传入多个标识:".concat(n.expr));if(1!==o.length)throw new Error("fmt接收了一个无法被解析的标识");if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError)return i.fillError||i.error;throw r}if(null===n.fmt)throw"表达式没有格式化部分";return format(o[0],n.fmt)}var version="0.0.30";function token2postfix(r){for(var t=[],e=[],n=r;0<n.length;){var o=n.shift();if(isOperator(o))if("("===o)t.push(o);else if(")"===o){for(var i=t.pop();"("!==i&&0<t.length;)e.push(i),i=t.pop();if("("!==i)throw"error: unmatched ()"}else{for(;prioraty(o,t[t.length-1])&&0<t.length;)e.push(t.pop());t.push(o)}else e.push(o)}if(0<t.length){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;0<t.length;)e.push(t.pop())}return e}function evalPostfix(r){for(var t=[];0<r.length;){var e=r.shift();if(isOperator(e)){if(t.length<2)throw new CalculatorError("错误的栈长度, 可能是无法计算的表达式");var n=t.pop(),o=t.pop();switch("string"==typeof n&&(n=new Decimal(n)),"string"==typeof o&&(o=new Decimal(o)),e){case"+":t.push(o.add(n));break;case"-":t.push(o.sub(n));break;case"*":t.push(o.mul(n));break;case"/":t.push(o.div(n));break;case"%":t.push(o.mod(n))}}else t.push(e)}if(1!==t.length)throw"unvalid expression";return t[0]}function calc(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];var n=parseArgs(t),o=tokenizer(n.expr),i=null;if(null!==n.data)if(null===(i=void 0!==n.data._fillData?n.data:i)||void 0===i.fillError&&void 0===i.error)o=fillTokens(o,n.data);else try{o=fillTokens(o,n.data)}catch(r){if(r instanceof TokensFillError$1)return i.fillError||i.error;throw r}var o=token2postfix(o),a=null;if(null!==i){if(void 0!==i.calcError||void 0!==i.error)try{a=evalPostfix(o)}catch(r){if(r instanceof CalculatorError)return void 0!==i.calcError?i.calcError:i.error;throw r}}else a=evalPostfix(o);return a=null!==n.fmt?format(a,n.fmt):null!==a?a.toFixed():null}export{calc,fmt,version};
|
package/es/package.json
ADDED
package/example/index.html
CHANGED
|
@@ -12,61 +12,10 @@
|
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
<script src="../
|
|
15
|
+
<!--<script src="./decimal.js.js"></script>-->
|
|
16
|
+
<script src="../browser/index.js"></script>
|
|
17
17
|
|
|
18
18
|
<script>
|
|
19
|
-
// console.log(calc)
|
|
20
|
-
// console.log(calc.calc("1+2"))
|
|
21
|
-
// console.dir(calc)
|
|
22
|
-
// console.log(calc)
|
|
23
|
-
|
|
24
|
-
// console.log(calc.calc)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// console.log(calc.calc("1 + 2"))
|
|
28
|
-
// const {calc} = calc
|
|
29
|
-
//
|
|
30
|
-
// console.log(calc)
|
|
31
|
-
// console.log(calc("1 + 2"))
|
|
32
|
-
|
|
33
|
-
// console.log(calc.calc("1+2"))
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// console.log(calc.calc("0.20000002*10000000000000000000000000000000000 |,"))
|
|
37
|
-
|
|
38
|
-
// let a = -0.00000001;
|
|
39
|
-
// let b = -1000000000000000000000.0000000000000000123456;
|
|
40
|
-
// let c = 123456789.000000123456789;
|
|
41
|
-
// console.log(a)
|
|
42
|
-
// console.log(b)
|
|
43
|
-
// console.log(parseFloat(c))
|
|
44
|
-
//
|
|
45
|
-
// function scienceNormal (num){
|
|
46
|
-
// // 将科学记数法转换成字符串
|
|
47
|
-
// let cur = num
|
|
48
|
-
// if(typeof num === 'number'){
|
|
49
|
-
// cur = num.toString()
|
|
50
|
-
// }
|
|
51
|
-
//
|
|
52
|
-
// // if(/^-?\/){
|
|
53
|
-
// // // 说明是科学记数法
|
|
54
|
-
// // }
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
// }
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// console.log(toNonExponential(1.0000000000000001e+23))
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// console.log("00000000000000000000000".length)
|
|
64
|
-
|
|
65
|
-
// console.log(numbro("11111111111111111111112222222222.123456123456123456123456123456").value())
|
|
66
|
-
// console.log(calc)
|
|
67
|
-
// import { calc } from "../src/calc";
|
|
68
|
-
|
|
69
|
-
console.log(js_calc)
|
|
70
19
|
|
|
71
20
|
|
|
72
21
|
</script>
|
package/example/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { tokenizer } from "../src/tokenizer.js";
|
|
2
|
+
import { token2postfix } from "../src/postfixExpr.js";
|
|
3
|
+
|
|
4
|
+
let t1 = tokenizer("-1 - (-22321 * 3)");
|
|
5
|
+
let t2 = tokenizer("1123 - (0.322 + -33.3) % 66");
|
|
6
|
+
let t3 = tokenizer("+0.888-22*(66--3.33)");
|
|
7
|
+
|
|
8
|
+
console.log(token2postfix(t2))
|
package/package.json
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "a-calc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"description": "JavaScript的字符串四则运算库, 支持格式化操作例如: 千分位格式化, 灵活指定小数点位数",
|
|
5
|
-
"main": "./
|
|
5
|
+
"main": "./es/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./es/index.js",
|
|
9
|
+
"require": "./cjs/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./es": {
|
|
12
|
+
"import": "./es/index.js",
|
|
13
|
+
"default": "./es/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./cjs": {
|
|
16
|
+
"require": "./cjs/index.js",
|
|
17
|
+
"default": "./cjs/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"browser": "./browser/index.js",
|
|
21
|
+
"module": "./es/index.js",
|
|
6
22
|
"typings": "./calc.d.ts",
|
|
7
23
|
"scripts": {
|
|
8
|
-
"
|
|
24
|
+
"dev": "rollup -c -w --environment build:dev",
|
|
25
|
+
"build": "rollup -c --environment build:build",
|
|
26
|
+
"build:w": "rollup -c -w --environment build:build",
|
|
27
|
+
"test": "cross-env ava"
|
|
9
28
|
},
|
|
10
29
|
"files": [
|
|
11
30
|
"example",
|
|
12
|
-
"
|
|
31
|
+
"es",
|
|
32
|
+
"cjs",
|
|
33
|
+
"browser",
|
|
13
34
|
"calc.d.ts"
|
|
14
35
|
],
|
|
15
36
|
"repository": {
|
|
16
37
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/Autumn-one/a-calc.git"
|
|
38
|
+
"url": "git+https://github.com/Autumn-one/a-calc-old.git"
|
|
18
39
|
},
|
|
19
40
|
"keywords": [
|
|
20
41
|
"四则运算",
|
|
@@ -26,14 +47,27 @@
|
|
|
26
47
|
"author": "Autumn",
|
|
27
48
|
"license": "MPL-2.0",
|
|
28
49
|
"bugs": {
|
|
29
|
-
"url": "https://github.com/Autumn-one/a-calc/issues"
|
|
30
|
-
},
|
|
31
|
-
"homepage": "https://github.com/Autumn-one/a-calc#readme",
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"numbro": "^2.3.6"
|
|
50
|
+
"url": "https://github.com/Autumn-one/a-calc-old/issues"
|
|
34
51
|
},
|
|
52
|
+
"homepage": "https://github.com/Autumn-one/a-calc-old#readme",
|
|
35
53
|
"devDependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
54
|
+
"@babel/core": "^7.17.10",
|
|
55
|
+
"@babel/preset-env": "^7.17.10",
|
|
56
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
57
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
58
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
59
|
+
"@rollup/plugin-node-resolve": "^13.2.1",
|
|
60
|
+
"ava": "^4.2.0",
|
|
61
|
+
"cross-env": "^7.0.3",
|
|
62
|
+
"glob": "^8.0.1",
|
|
63
|
+
"npm-run-all": "^4.1.5",
|
|
64
|
+
"rollup": "^2.70.2",
|
|
65
|
+
"rollup-plugin-livereload": "^2.0.5",
|
|
66
|
+
"rollup-plugin-serve": "^1.1.0",
|
|
67
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
68
|
+
"rollup-plugin-uglify": "^6.0.4"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"decimal.js": "^10.3.1"
|
|
38
72
|
}
|
|
39
73
|
}
|
package/LICENSE
DELETED
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
Mozilla Public License Version 2.0
|
|
2
|
-
==================================
|
|
3
|
-
|
|
4
|
-
1. Definitions
|
|
5
|
-
--------------
|
|
6
|
-
|
|
7
|
-
1.1. "Contributor"
|
|
8
|
-
means each individual or legal entity that creates, contributes to
|
|
9
|
-
the creation of, or owns Covered Software.
|
|
10
|
-
|
|
11
|
-
1.2. "Contributor Version"
|
|
12
|
-
means the combination of the Contributions of others (if any) used
|
|
13
|
-
by a Contributor and that particular Contributor's Contribution.
|
|
14
|
-
|
|
15
|
-
1.3. "Contribution"
|
|
16
|
-
means Covered Software of a particular Contributor.
|
|
17
|
-
|
|
18
|
-
1.4. "Covered Software"
|
|
19
|
-
means Source Code Form to which the initial Contributor has attached
|
|
20
|
-
the notice in Exhibit A, the Executable Form of such Source Code
|
|
21
|
-
Form, and Modifications of such Source Code Form, in each case
|
|
22
|
-
including portions thereof.
|
|
23
|
-
|
|
24
|
-
1.5. "Incompatible With Secondary Licenses"
|
|
25
|
-
means
|
|
26
|
-
|
|
27
|
-
(a) that the initial Contributor has attached the notice described
|
|
28
|
-
in Exhibit B to the Covered Software; or
|
|
29
|
-
|
|
30
|
-
(b) that the Covered Software was made available under the terms of
|
|
31
|
-
version 1.1 or earlier of the License, but not also under the
|
|
32
|
-
terms of a Secondary License.
|
|
33
|
-
|
|
34
|
-
1.6. "Executable Form"
|
|
35
|
-
means any form of the work other than Source Code Form.
|
|
36
|
-
|
|
37
|
-
1.7. "Larger Work"
|
|
38
|
-
means a work that combines Covered Software with other material, in
|
|
39
|
-
a separate file or files, that is not Covered Software.
|
|
40
|
-
|
|
41
|
-
1.8. "License"
|
|
42
|
-
means this document.
|
|
43
|
-
|
|
44
|
-
1.9. "Licensable"
|
|
45
|
-
means having the right to grant, to the maximum extent possible,
|
|
46
|
-
whether at the time of the initial grant or subsequently, any and
|
|
47
|
-
all of the rights conveyed by this License.
|
|
48
|
-
|
|
49
|
-
1.10. "Modifications"
|
|
50
|
-
means any of the following:
|
|
51
|
-
|
|
52
|
-
(a) any file in Source Code Form that results from an addition to,
|
|
53
|
-
deletion from, or modification of the contents of Covered
|
|
54
|
-
Software; or
|
|
55
|
-
|
|
56
|
-
(b) any new file in Source Code Form that contains any Covered
|
|
57
|
-
Software.
|
|
58
|
-
|
|
59
|
-
1.11. "Patent Claims" of a Contributor
|
|
60
|
-
means any patent claim(s), including without limitation, method,
|
|
61
|
-
process, and apparatus claims, in any patent Licensable by such
|
|
62
|
-
Contributor that would be infringed, but for the grant of the
|
|
63
|
-
License, by the making, using, selling, offering for sale, having
|
|
64
|
-
made, import, or transfer of either its Contributions or its
|
|
65
|
-
Contributor Version.
|
|
66
|
-
|
|
67
|
-
1.12. "Secondary License"
|
|
68
|
-
means either the GNU General Public License, Version 2.0, the GNU
|
|
69
|
-
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
70
|
-
Public License, Version 3.0, or any later versions of those
|
|
71
|
-
licenses.
|
|
72
|
-
|
|
73
|
-
1.13. "Source Code Form"
|
|
74
|
-
means the form of the work preferred for making modifications.
|
|
75
|
-
|
|
76
|
-
1.14. "You" (or "Your")
|
|
77
|
-
means an individual or a legal entity exercising rights under this
|
|
78
|
-
License. For legal entities, "You" includes any entity that
|
|
79
|
-
controls, is controlled by, or is under common control with You. For
|
|
80
|
-
purposes of this definition, "control" means (a) the power, direct
|
|
81
|
-
or indirect, to cause the direction or management of such entity,
|
|
82
|
-
whether by contract or otherwise, or (b) ownership of more than
|
|
83
|
-
fifty percent (50%) of the outstanding shares or beneficial
|
|
84
|
-
ownership of such entity.
|
|
85
|
-
|
|
86
|
-
2. License Grants and Conditions
|
|
87
|
-
--------------------------------
|
|
88
|
-
|
|
89
|
-
2.1. Grants
|
|
90
|
-
|
|
91
|
-
Each Contributor hereby grants You a world-wide, royalty-free,
|
|
92
|
-
non-exclusive license:
|
|
93
|
-
|
|
94
|
-
(a) under intellectual property rights (other than patent or trademark)
|
|
95
|
-
Licensable by such Contributor to use, reproduce, make available,
|
|
96
|
-
modify, display, perform, distribute, and otherwise exploit its
|
|
97
|
-
Contributions, either on an unmodified basis, with Modifications, or
|
|
98
|
-
as part of a Larger Work; and
|
|
99
|
-
|
|
100
|
-
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
|
101
|
-
for sale, have made, import, and otherwise transfer either its
|
|
102
|
-
Contributions or its Contributor Version.
|
|
103
|
-
|
|
104
|
-
2.2. Effective Date
|
|
105
|
-
|
|
106
|
-
The licenses granted in Section 2.1 with respect to any Contribution
|
|
107
|
-
become effective for each Contribution on the date the Contributor first
|
|
108
|
-
distributes such Contribution.
|
|
109
|
-
|
|
110
|
-
2.3. Limitations on Grant Scope
|
|
111
|
-
|
|
112
|
-
The licenses granted in this Section 2 are the only rights granted under
|
|
113
|
-
this License. No additional rights or licenses will be implied from the
|
|
114
|
-
distribution or licensing of Covered Software under this License.
|
|
115
|
-
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
116
|
-
Contributor:
|
|
117
|
-
|
|
118
|
-
(a) for any code that a Contributor has removed from Covered Software;
|
|
119
|
-
or
|
|
120
|
-
|
|
121
|
-
(b) for infringements caused by: (i) Your and any other third party's
|
|
122
|
-
modifications of Covered Software, or (ii) the combination of its
|
|
123
|
-
Contributions with other software (except as part of its Contributor
|
|
124
|
-
Version); or
|
|
125
|
-
|
|
126
|
-
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
127
|
-
its Contributions.
|
|
128
|
-
|
|
129
|
-
This License does not grant any rights in the trademarks, service marks,
|
|
130
|
-
or logos of any Contributor (except as may be necessary to comply with
|
|
131
|
-
the notice requirements in Section 3.4).
|
|
132
|
-
|
|
133
|
-
2.4. Subsequent Licenses
|
|
134
|
-
|
|
135
|
-
No Contributor makes additional grants as a result of Your choice to
|
|
136
|
-
distribute the Covered Software under a subsequent version of this
|
|
137
|
-
License (see Section 10.2) or under the terms of a Secondary License (if
|
|
138
|
-
permitted under the terms of Section 3.3).
|
|
139
|
-
|
|
140
|
-
2.5. Representation
|
|
141
|
-
|
|
142
|
-
Each Contributor represents that the Contributor believes its
|
|
143
|
-
Contributions are its original creation(s) or it has sufficient rights
|
|
144
|
-
to grant the rights to its Contributions conveyed by this License.
|
|
145
|
-
|
|
146
|
-
2.6. Fair Use
|
|
147
|
-
|
|
148
|
-
This License is not intended to limit any rights You have under
|
|
149
|
-
applicable copyright doctrines of fair use, fair dealing, or other
|
|
150
|
-
equivalents.
|
|
151
|
-
|
|
152
|
-
2.7. Conditions
|
|
153
|
-
|
|
154
|
-
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
155
|
-
in Section 2.1.
|
|
156
|
-
|
|
157
|
-
3. Responsibilities
|
|
158
|
-
-------------------
|
|
159
|
-
|
|
160
|
-
3.1. Distribution of Source Form
|
|
161
|
-
|
|
162
|
-
All distribution of Covered Software in Source Code Form, including any
|
|
163
|
-
Modifications that You create or to which You contribute, must be under
|
|
164
|
-
the terms of this License. You must inform recipients that the Source
|
|
165
|
-
Code Form of the Covered Software is governed by the terms of this
|
|
166
|
-
License, and how they can obtain a copy of this License. You may not
|
|
167
|
-
attempt to alter or restrict the recipients' rights in the Source Code
|
|
168
|
-
Form.
|
|
169
|
-
|
|
170
|
-
3.2. Distribution of Executable Form
|
|
171
|
-
|
|
172
|
-
If You distribute Covered Software in Executable Form then:
|
|
173
|
-
|
|
174
|
-
(a) such Covered Software must also be made available in Source Code
|
|
175
|
-
Form, as described in Section 3.1, and You must inform recipients of
|
|
176
|
-
the Executable Form how they can obtain a copy of such Source Code
|
|
177
|
-
Form by reasonable means in a timely manner, at a charge no more
|
|
178
|
-
than the cost of distribution to the recipient; and
|
|
179
|
-
|
|
180
|
-
(b) You may distribute such Executable Form under the terms of this
|
|
181
|
-
License, or sublicense it under different terms, provided that the
|
|
182
|
-
license for the Executable Form does not attempt to limit or alter
|
|
183
|
-
the recipients' rights in the Source Code Form under this License.
|
|
184
|
-
|
|
185
|
-
3.3. Distribution of a Larger Work
|
|
186
|
-
|
|
187
|
-
You may create and distribute a Larger Work under terms of Your choice,
|
|
188
|
-
provided that You also comply with the requirements of this License for
|
|
189
|
-
the Covered Software. If the Larger Work is a combination of Covered
|
|
190
|
-
Software with a work governed by one or more Secondary Licenses, and the
|
|
191
|
-
Covered Software is not Incompatible With Secondary Licenses, this
|
|
192
|
-
License permits You to additionally distribute such Covered Software
|
|
193
|
-
under the terms of such Secondary License(s), so that the recipient of
|
|
194
|
-
the Larger Work may, at their option, further distribute the Covered
|
|
195
|
-
Software under the terms of either this License or such Secondary
|
|
196
|
-
License(s).
|
|
197
|
-
|
|
198
|
-
3.4. Notices
|
|
199
|
-
|
|
200
|
-
You may not remove or alter the substance of any license notices
|
|
201
|
-
(including copyright notices, patent notices, disclaimers of warranty,
|
|
202
|
-
or limitations of liability) contained within the Source Code Form of
|
|
203
|
-
the Covered Software, except that You may alter any license notices to
|
|
204
|
-
the extent required to remedy known factual inaccuracies.
|
|
205
|
-
|
|
206
|
-
3.5. Application of Additional Terms
|
|
207
|
-
|
|
208
|
-
You may choose to offer, and to charge a fee for, warranty, support,
|
|
209
|
-
indemnity or liability obligations to one or more recipients of Covered
|
|
210
|
-
Software. However, You may do so only on Your own behalf, and not on
|
|
211
|
-
behalf of any Contributor. You must make it absolutely clear that any
|
|
212
|
-
such warranty, support, indemnity, or liability obligation is offered by
|
|
213
|
-
You alone, and You hereby agree to indemnify every Contributor for any
|
|
214
|
-
liability incurred by such Contributor as a result of warranty, support,
|
|
215
|
-
indemnity or liability terms You offer. You may include additional
|
|
216
|
-
disclaimers of warranty and limitations of liability specific to any
|
|
217
|
-
jurisdiction.
|
|
218
|
-
|
|
219
|
-
4. Inability to Comply Due to Statute or Regulation
|
|
220
|
-
---------------------------------------------------
|
|
221
|
-
|
|
222
|
-
If it is impossible for You to comply with any of the terms of this
|
|
223
|
-
License with respect to some or all of the Covered Software due to
|
|
224
|
-
statute, judicial order, or regulation then You must: (a) comply with
|
|
225
|
-
the terms of this License to the maximum extent possible; and (b)
|
|
226
|
-
describe the limitations and the code they affect. Such description must
|
|
227
|
-
be placed in a text file included with all distributions of the Covered
|
|
228
|
-
Software under this License. Except to the extent prohibited by statute
|
|
229
|
-
or regulation, such description must be sufficiently detailed for a
|
|
230
|
-
recipient of ordinary skill to be able to understand it.
|
|
231
|
-
|
|
232
|
-
5. Termination
|
|
233
|
-
--------------
|
|
234
|
-
|
|
235
|
-
5.1. The rights granted under this License will terminate automatically
|
|
236
|
-
if You fail to comply with any of its terms. However, if You become
|
|
237
|
-
compliant, then the rights granted under this License from a particular
|
|
238
|
-
Contributor are reinstated (a) provisionally, unless and until such
|
|
239
|
-
Contributor explicitly and finally terminates Your grants, and (b) on an
|
|
240
|
-
ongoing basis, if such Contributor fails to notify You of the
|
|
241
|
-
non-compliance by some reasonable means prior to 60 days after You have
|
|
242
|
-
come back into compliance. Moreover, Your grants from a particular
|
|
243
|
-
Contributor are reinstated on an ongoing basis if such Contributor
|
|
244
|
-
notifies You of the non-compliance by some reasonable means, this is the
|
|
245
|
-
first time You have received notice of non-compliance with this License
|
|
246
|
-
from such Contributor, and You become compliant prior to 30 days after
|
|
247
|
-
Your receipt of the notice.
|
|
248
|
-
|
|
249
|
-
5.2. If You initiate litigation against any entity by asserting a patent
|
|
250
|
-
infringement claim (excluding declaratory judgment actions,
|
|
251
|
-
counter-claims, and cross-claims) alleging that a Contributor Version
|
|
252
|
-
directly or indirectly infringes any patent, then the rights granted to
|
|
253
|
-
You by any and all Contributors for the Covered Software under Section
|
|
254
|
-
2.1 of this License shall terminate.
|
|
255
|
-
|
|
256
|
-
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
|
257
|
-
end user license agreements (excluding distributors and resellers) which
|
|
258
|
-
have been validly granted by You or Your distributors under this License
|
|
259
|
-
prior to termination shall survive termination.
|
|
260
|
-
|
|
261
|
-
************************************************************************
|
|
262
|
-
* *
|
|
263
|
-
* 6. Disclaimer of Warranty *
|
|
264
|
-
* ------------------------- *
|
|
265
|
-
* *
|
|
266
|
-
* Covered Software is provided under this License on an "as is" *
|
|
267
|
-
* basis, without warranty of any kind, either expressed, implied, or *
|
|
268
|
-
* statutory, including, without limitation, warranties that the *
|
|
269
|
-
* Covered Software is free of defects, merchantable, fit for a *
|
|
270
|
-
* particular purpose or non-infringing. The entire risk as to the *
|
|
271
|
-
* quality and performance of the Covered Software is with You. *
|
|
272
|
-
* Should any Covered Software prove defective in any respect, You *
|
|
273
|
-
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
274
|
-
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
275
|
-
* essential part of this License. No use of any Covered Software is *
|
|
276
|
-
* authorized under this License except under this disclaimer. *
|
|
277
|
-
* *
|
|
278
|
-
************************************************************************
|
|
279
|
-
|
|
280
|
-
************************************************************************
|
|
281
|
-
* *
|
|
282
|
-
* 7. Limitation of Liability *
|
|
283
|
-
* -------------------------- *
|
|
284
|
-
* *
|
|
285
|
-
* Under no circumstances and under no legal theory, whether tort *
|
|
286
|
-
* (including negligence), contract, or otherwise, shall any *
|
|
287
|
-
* Contributor, or anyone who distributes Covered Software as *
|
|
288
|
-
* permitted above, be liable to You for any direct, indirect, *
|
|
289
|
-
* special, incidental, or consequential damages of any character *
|
|
290
|
-
* including, without limitation, damages for lost profits, loss of *
|
|
291
|
-
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
292
|
-
* and all other commercial damages or losses, even if such party *
|
|
293
|
-
* shall have been informed of the possibility of such damages. This *
|
|
294
|
-
* limitation of liability shall not apply to liability for death or *
|
|
295
|
-
* personal injury resulting from such party's negligence to the *
|
|
296
|
-
* extent applicable law prohibits such limitation. Some *
|
|
297
|
-
* jurisdictions do not allow the exclusion or limitation of *
|
|
298
|
-
* incidental or consequential damages, so this exclusion and *
|
|
299
|
-
* limitation may not apply to You. *
|
|
300
|
-
* *
|
|
301
|
-
************************************************************************
|
|
302
|
-
|
|
303
|
-
8. Litigation
|
|
304
|
-
-------------
|
|
305
|
-
|
|
306
|
-
Any litigation relating to this License may be brought only in the
|
|
307
|
-
courts of a jurisdiction where the defendant maintains its principal
|
|
308
|
-
place of business and such litigation shall be governed by laws of that
|
|
309
|
-
jurisdiction, without reference to its conflict-of-law provisions.
|
|
310
|
-
Nothing in this Section shall prevent a party's ability to bring
|
|
311
|
-
cross-claims or counter-claims.
|
|
312
|
-
|
|
313
|
-
9. Miscellaneous
|
|
314
|
-
----------------
|
|
315
|
-
|
|
316
|
-
This License represents the complete agreement concerning the subject
|
|
317
|
-
matter hereof. If any provision of this License is held to be
|
|
318
|
-
unenforceable, such provision shall be reformed only to the extent
|
|
319
|
-
necessary to make it enforceable. Any law or regulation which provides
|
|
320
|
-
that the language of a contract shall be construed against the drafter
|
|
321
|
-
shall not be used to construe this License against a Contributor.
|
|
322
|
-
|
|
323
|
-
10. Versions of the License
|
|
324
|
-
---------------------------
|
|
325
|
-
|
|
326
|
-
10.1. New Versions
|
|
327
|
-
|
|
328
|
-
Mozilla Foundation is the license steward. Except as provided in Section
|
|
329
|
-
10.3, no one other than the license steward has the right to modify or
|
|
330
|
-
publish new versions of this License. Each version will be given a
|
|
331
|
-
distinguishing version number.
|
|
332
|
-
|
|
333
|
-
10.2. Effect of New Versions
|
|
334
|
-
|
|
335
|
-
You may distribute the Covered Software under the terms of the version
|
|
336
|
-
of the License under which You originally received the Covered Software,
|
|
337
|
-
or under the terms of any subsequent version published by the license
|
|
338
|
-
steward.
|
|
339
|
-
|
|
340
|
-
10.3. Modified Versions
|
|
341
|
-
|
|
342
|
-
If you create software not governed by this License, and you want to
|
|
343
|
-
create a new license for such software, you may create and use a
|
|
344
|
-
modified version of this License if you rename the license and remove
|
|
345
|
-
any references to the name of the license steward (except to note that
|
|
346
|
-
such modified license differs from this License).
|
|
347
|
-
|
|
348
|
-
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
|
349
|
-
Licenses
|
|
350
|
-
|
|
351
|
-
If You choose to distribute Source Code Form that is Incompatible With
|
|
352
|
-
Secondary Licenses under the terms of this version of the License, the
|
|
353
|
-
notice described in Exhibit B of this License must be attached.
|
|
354
|
-
|
|
355
|
-
Exhibit A - Source Code Form License Notice
|
|
356
|
-
-------------------------------------------
|
|
357
|
-
|
|
358
|
-
This Source Code Form is subject to the terms of the Mozilla Public
|
|
359
|
-
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
360
|
-
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
361
|
-
|
|
362
|
-
If it is not possible or desirable to put the notice in a particular
|
|
363
|
-
file, then You may include the notice in a location (such as a LICENSE
|
|
364
|
-
file in a relevant directory) where a recipient would be likely to look
|
|
365
|
-
for such a notice.
|
|
366
|
-
|
|
367
|
-
You may add additional accurate notices of copyright ownership.
|
|
368
|
-
|
|
369
|
-
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
370
|
-
---------------------------------------------------------
|
|
371
|
-
|
|
372
|
-
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
373
|
-
defined by the Mozilla Public License, v. 2.0.
|
package/dist/calc.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("numbro")):"function"==typeof define&&define.amd?define(["numbro"],t):"object"==typeof exports?exports.a_calc=t(require("numbro")):e.a_calc=t(e.numbro)}(this,(function(e){return(()=>{"use strict";var t={655:t=>{t.exports=e}},r={};function n(e){var l=r[e];if(void 0!==l)return l.exports;var s=r[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{n.r(l),n.d(l,{calc:()=>p,expr2que:()=>r,fmt:()=>a});var e=n(655),t=n.n(e);function r(e){let t=[],r="",n=e.search(/\S/);for(let l=0,s=e.length;l<s;l++){let s=e[l];if(l===n&&"+-".includes(s))r+=s;else if(" "===s||"+-*/%()".includes(s)){if("+-".includes(s)&&"(+-*/%".includes(t[t.length-1])){r+=s;continue}""!==r&&(t.push(r),r="")," "!==s&&t.push(s)}else r+=s}return""!==r&&(t.push(r),r=null),t}function s(e){let t={expr:"",fmt:""},r="",n=e[0];if(1===e.length&&"string"==typeof n)r=n;else if(1===e.length&&"number"==typeof n)r=n.toString();else if(1===e.length&&Array.isArray(n))r=n[0];else if(e.length>1){let t=e.shift();for(;t.length<1&&e.length<1;){let n=t.shift();void 0===n&&(n="");let l=e.shift();void 0===l?l="":"number"==typeof l&&(l=l.toString()),r=r+n+l}}let l=r.split("|");return 1===l.length?t.expr=l[0]:(t.expr=l[0],t.fmt=l[1]),t}function o(e){if("string"!=typeof e&&(e=e.toString()),!e.includes("e"))return e;let t=e.match(/^(-?[\d.]+)e([+-])(\d+)$/);if(null===t)throw new Error(`科学计数法模式匹配出错: ${e}`);let r=t[1],n=t[2],l=t[3],s="";r.includes("-")&&(s="-",r=r.replace("-",""));let o=0;if(-1!==r.indexOf(".")){let e=r.split(".");o="+"===n?e[1].length:e[0].length,r=e.join("")}else"-"===n&&(o=1);let i=l-o,a="";return a="-"===n?"0."+"0".repeat(i)+r:r+"0".repeat(i),s+a}function i(e,t){let r="",n=function(e){let t={thousandSeparated:null,mantissa:null,mantissa_type:null},r=e.match(/(<=|>=|=)\s*(\d+)/);return r&&(t.mantissa_type=r[1],t.mantissa=Number(r[2])),-1!==e.lastIndexOf(",")&&(t.thousandSeparated=!0),t}(t);const{thousandSeparated:l,mantissa:s,mantissa_type:i}=n;let a={};if(l&&!e.value().toString().includes("e")&&(a.thousandSeparated=l),i)switch(i){case"=":a.mantissa=s,r=e.format(a);break;case"<=":a.mantissa=s,a.trimMantissa=!0,r=e.format(a);break;case">=":let t=o(e.value().toString()).split(".");1===t.length||t[1].length<s?(a.mantissa=s,r=e.format(a)):r=e.format(a);break;default:throw new Error("尾数符号错误!")}else r=e.format(a);return r}function a(...e){let r=s(e),{expr:n,fmt:l}=r;return n=n.trim(),o(i(t()(n),l))}function u(e){return"+-*/%()".indexOf(e)>-1}function f(e){switch(e){case"+":case"-":return 1;case"*":case"/":case"%":return 2;default:return 0}}function p(...e){let n="",l=s(e),a=r(l.expr);if(1===a.length)return o(i(t()(a[0]),l.fmt));let p=function(e){let r=[];for(;e.length>0;){let n=e.shift();if(u(n)){if(r.length<2)throw"unvalid stack length";let e=r.pop(),l=r.pop();switch("string"==typeof e&&(e=t()(e)),"string"==typeof l&&(l=t()(l)),n){case"+":r.push(l.add(e));break;case"-":r.push(l.subtract(e));break;case"*":r.push(l.multiply(e));break;case"/":r.push(l.divide(e));break;case"%":r.push(t()(Number(l.value())%Number(e.value())))}}else r.push(n)}if(1!==r.length)throw"unvalid expression";return r[0]}(function(e){let t=[],r=[],n=e;for(;n.length>0;){let e=n.shift();if(u(e))if("("===e)t.push(e);else if(")"===e){let e=t.pop();for(;"("!==e&&t.length>0;)r.push(e),e=t.pop();if("("!==e)throw"error: unmatched ()"}else{for(;l=e,s=t[t.length-1],f(l)<=f(s)&&t.length>0;)r.push(t.pop());t.push(e)}else r.push(e)}var l,s;if(t.length>0){if(")"===t[t.length-1]||"("===t[t.length-1])throw"error: unmatched ()";for(;t.length>0;)r.push(t.pop())}return r}(a));return n=l.fmt?i(p,l.fmt):p.value(),o(n)}})(),l})()}));
|
|
2
|
-
//# sourceMappingURL=calc.js.map
|
package/dist/calc.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calc.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,WACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,UAAWJ,GACO,iBAAZC,QACdA,QAAgB,OAAID,EAAQG,QAAQ,WAEpCJ,EAAa,OAAIC,EAAQD,EAAa,QARxC,CASGO,MAAM,SAASC,GAClB,M,kCCVAL,EAAOD,QAAUM,ICCbC,EAA2B,GAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaV,QAGrB,IAAIC,EAASM,EAAyBE,GAAY,CAGjDT,QAAS,IAOV,OAHAY,EAAoBH,GAAUR,EAAQA,EAAOD,QAASQ,GAG/CP,EAAOD,QCpBfQ,EAAoBK,EAAKZ,IACxB,IAAIa,EAASb,GAAUA,EAAOc,WAC7B,IAAOd,EAAiB,QACxB,IAAM,EAEP,OADAO,EAAoBQ,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,GCLRN,EAAoBQ,EAAI,CAAChB,EAASkB,KACjC,IAAI,IAAIC,KAAOD,EACXV,EAAoBY,EAAEF,EAAYC,KAASX,EAAoBY,EAAEpB,EAASmB,IAC5EE,OAAOC,eAAetB,EAASmB,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EX,EAAoBY,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFlB,EAAoBsB,EAAK9B,IACH,oBAAX+B,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAetB,EAAS+B,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAAetB,EAAS,aAAc,CAAEiC,OAAO,K,+FCDvD,SAASC,EAAUC,GAEf,IAAIC,EAAU,GAEVC,EAAU,GAEVC,EAASH,EAAKI,OAAO,MAEzB,IAAM,IAAIC,EAAI,EAAGC,EAAMN,EAAKO,OAAQF,EAAIC,EAAKD,IAAM,CAC/C,IAAIG,EAAMR,EAAKK,GAEf,GAAKA,IAAMF,GAAU,KAAKM,SAASD,GAC/BN,GAAWM,OAIf,GAAa,MAARA,GAXO,UAWkBC,SAASD,GAAO,CAC1C,GAAK,KAAKC,SAASD,IAAQ,SAASC,SAASR,EAAQA,EAAQM,OAAS,IAAM,CACxEL,GAAWM,EACX,SAGa,KAAZN,IACDD,EAAQS,KAAKR,GACbA,EAAU,IAED,MAARM,GACDP,EAAQS,KAAKF,QAGjBN,GAAWM,EAUnB,MANiB,KAAZN,IACDD,EAAQS,KAAKR,GACbA,EAAU,MAIPD,EC5CX,SAASU,EAAWC,GAEhB,IAAIC,EAAS,CACTb,KAAM,GACNc,IAAK,IAILC,EAAU,GACVC,EAAOJ,EAAK,GAGhB,GAAqB,IAAhBA,EAAKL,QAAgC,iBAATS,EAC7BD,EAAUC,OACP,GAAmB,IAAhBJ,EAAKL,QAAgC,iBAATS,EAClCD,EAAUC,EAAKC,gBACb,GAAqB,IAAhBL,EAAKL,QAAgBW,MAAMC,QAAQH,GAC1CD,EAAUC,EAAK,QACZ,GAAKJ,EAAKL,OAAS,EAAI,CAC1B,IAAIa,EAASR,EAAKS,QAClB,KAAQD,EAAOb,OAAS,GAAKK,EAAKL,OAAS,GAAI,CAC3C,IAAIe,EAAOF,EAAOC,aACJ7C,IAAT8C,IACDA,EAAO,IAEX,IAAIC,EAAOX,EAAKS,aACF7C,IAAT+C,EACDA,EAAO,GACiB,iBAATA,IACfA,EAAOA,EAAKN,YAGhBF,EAAUA,EAAUO,EAAOC,GAMnC,IAAIC,EAAUT,EAAQU,MAAM,KAS5B,OARwB,IAAnBD,EAAQjB,OACTM,EAAOb,KAAOwB,EAAQ,IAEtBX,EAAOb,KAAOwB,EAAQ,GACtBX,EAAOC,IAAMU,EAAQ,IAIlBX,EC9CX,SAASa,EAAcC,GAMnB,GAJqB,iBAAXA,IACNA,EAASA,EAAOV,aAGdU,EAAOlB,SAAS,KAClB,OAAOkB,EAGX,IAAIC,EAAUD,EAAOE,MAAM,4BAC3B,GAAiB,OAAZD,EACD,MAAM,IAAIE,MAAM,gBAAiBH,KAErC,IAAII,EAAWH,EAAQ,GACnBI,EAAYJ,EAAQ,GACpBK,EAAQL,EAAQ,GAEhBM,EAAS,GACRH,EAAStB,SAAS,OACnByB,EAAS,IACTH,EAAWA,EAASI,QAAQ,IAAK,KAGrC,IACIC,EAAa,EAGjB,IAAmB,IAJJL,EAASM,QAAQ,KAIT,CACnB,IAAIC,EAASP,EAASN,MAAM,KAExBW,EADe,MAAdJ,EACYM,EAAO,GAAG/B,OAEV+B,EAAO,GAAG/B,OAE3BwB,EAAWO,EAAOC,KAAK,QACJ,MAAdP,IACLI,EAAa,GAGjB,IAAII,EAAcP,EAAQG,EAEtBK,EAAY,GAMhB,OAJIA,EADa,MAAdT,EACa,KAAO,IAAIU,OAAOF,GAAeT,EAEjCA,EAAW,IAAIW,OAAOF,GAE/BN,EAASO,ECvBpB,SAASE,EAAWC,EAAMC,GAEtB,IAAIhC,EAAS,GAETiC,EA3BR,SAAsBD,GAElB,IAAIE,EAAS,CACTC,kBAAmB,KACnBC,SAAU,KACVC,cAAe,MAIfC,EAAWN,EAAOhB,MAAM,qBAW5B,OAVKsB,IACDJ,EAAOG,cAAgBC,EAAS,GAChCJ,EAAOE,SAAWG,OAAOD,EAAS,MAGJ,IAA7BN,EAAOQ,YAAY,OACpBN,EAAOC,mBAAoB,GAIxBD,EAOMO,CAAYT,GACzB,MAAM,kBACFG,EAAiB,SACjBC,EAAQ,cACRC,GACAJ,EAEJ,IAAIS,EAAW,GAGf,GAFKP,IAAsBJ,EAAK9C,QAAQmB,WAAWR,SAAS,OAAO8C,EAASP,kBAAoBA,GAE3FE,EACD,OAASA,GACL,IAAK,IACDK,EAASN,SAAWA,EACpBpC,EAAS+B,EAAKY,OAAOD,GACrB,MACJ,IAAK,KACDA,EAASN,SAAWA,EACpBM,EAASE,cAAe,EACxB5C,EAAS+B,EAAKY,OAAOD,GACrB,MACJ,IAAK,KACD,IAEIG,EAAShC,EAFAkB,EAAK9C,QAEemB,YAAYQ,MAAM,KAE5B,IAAlBiC,EAAOnD,QAAgBmD,EAAO,GAAGnD,OAAS0C,GAC3CM,EAASN,SAAWA,EACpBpC,EAAS+B,EAAKY,OAAOD,IAErB1C,EAAS+B,EAAKY,OAAOD,GAEzB,MACJ,QACI,MAAM,IAAIzB,MAAM,gBAGxBjB,EAAS+B,EAAKY,OAAOD,GAIzB,OAAO1C,EClEX,SAASC,KAAQF,GACb,IAAImC,EAASpC,EAAUC,IACnB,KAAEZ,EAAMc,IAAK+B,GAAWE,EAO5B,OAJA/C,EAAOA,EAAK2D,OAILjC,EAAaiB,EAFH,IAAO3C,GAEkB6C,ICd9C,SAASe,EAAY9D,GAGjB,MADqB,UACCuC,QAAQvC,IAAU,EAG5C,SAAS+D,EAAa/D,GAElB,OAASA,GACL,IAAK,IACL,IAAK,IACD,OAAO,EACX,IAAK,IACL,IAAK,IACL,IAAK,IACD,OAAO,EACX,QACI,OAAO,GCiDnB,SAASgE,KAASlD,GAEd,IAAIC,EAAS,GAETkD,EAAUpD,EAAUC,GAEpBoD,EAAUjE,EAASgE,EAAQ/D,MAC/B,GAAwB,IAAnBgE,EAAQzD,OACT,OAAOmB,EACHiB,EAAU,IAAOqB,EAAQ,IAAKD,EAAQjD,MAI9C,IAAImD,EAtER,SAAsBD,GAElB,IAAIE,EAAc,GAClB,KAAQF,EAAQzD,OAAS,GAAI,CACzB,IAAIC,EAAMwD,EAAQ3C,QAElB,GAAMuC,EAAWpD,GAEV,CACH,GAAK0D,EAAY3D,OAAS,EACtB,KAAM,uBAEV,IAAI4D,EAAMD,EAAYE,MAClBC,EAAMH,EAAYE,MAStB,OARoB,iBAARD,IACRA,EAAM,IAAOA,IAGG,iBAARE,IACRA,EAAM,IAAOA,IAGR7D,GACL,IAAK,IACD0D,EAAYxD,KAAK2D,EAAIC,IAAIH,IACzB,MACJ,IAAK,IACDD,EAAYxD,KAAK2D,EAAIE,SAASJ,IAC9B,MACJ,IAAK,IACDD,EAAYxD,KAAK2D,EAAIG,SAASL,IAC9B,MACJ,IAAK,IACDD,EAAYxD,KAAK2D,EAAII,OAAON,IAC5B,MACJ,IAAK,IACDD,EAAYxD,KACR,IACI0C,OAAOiB,EAAIvE,SACXsD,OAAOe,EAAIrE,iBAhC3BoE,EAAYxD,KAAKF,GA0CzB,GAA4B,IAAvB0D,EAAY3D,OACb,KAAM,qBAEN,OAAO2D,EAAY,GAkBPQ,CC7EpB,SAAwBC,GAEpB,IAAIC,EAAY,GACZC,EAAY,GAEZb,EAAUW,EAEd,KAAQX,EAAQzD,OAAS,GAAI,CACzB,IAAIC,EAAMwD,EAAQ3C,QAElB,GAAKuC,EAAWpD,GACZ,GAAa,MAARA,EACDoE,EAAUlE,KAAKF,QACZ,GAAa,MAARA,EAAc,CACtB,IAAIsE,EAAKF,EAAUR,MACnB,KAAe,MAAPU,GAAcF,EAAUrE,OAAS,GACrCsE,EAAUnE,KAAKoE,GACfA,EAAKF,EAAUR,MAEnB,GAAY,MAAPU,EACD,KAAM,0BAEP,CAGH,KFNGC,EEMcvE,EFNVwE,EEMeJ,EAAUA,EAAUrE,OAAS,GFJxDsD,EAAYkB,IAAOlB,EAAYmB,IEIgCJ,EAAUrE,OAAS,GACzEsE,EAAUnE,KAAKkE,EAAUR,OAG7BQ,EAAUlE,KAAKF,QAGnBqE,EAAUnE,KAAKF,GFb3B,IAAmBuE,EAAIC,EEiBnB,GAAKJ,EAAUrE,OAAS,EAAI,CACxB,GAAyC,MAApCqE,EAAUA,EAAUrE,OAAS,IAAkD,MAApCqE,EAAUA,EAAUrE,OAAS,GACzE,KAAM,sBAEV,KAAQqE,EAAUrE,OAAS,GAEvBsE,EAAUnE,KAAKkE,EAAUR,OAGjC,OAAOS,EDgCqBI,CAAcjB,IAW1C,OANInD,EADCkD,EAAQjD,IACA6B,EAAUsB,EAAWF,EAAQjD,KAG7BmD,EAAUnE,QAGhB4B,EAAab,K","sources":["webpack://a_calc/webpack/universalModuleDefinition","webpack://a_calc/external umd {\"root\":\"numbro\",\"commonjs\":\"numbro\",\"commonjs2\":\"numbro\",\"amd\":\"numbro\"}","webpack://a_calc/webpack/bootstrap","webpack://a_calc/webpack/runtime/compat get default export","webpack://a_calc/webpack/runtime/define property getters","webpack://a_calc/webpack/runtime/hasOwnProperty shorthand","webpack://a_calc/webpack/runtime/make namespace object","webpack://a_calc/./src/expr2que.js","webpack://a_calc/./src/parse_args.js","webpack://a_calc/./src/science.js","webpack://a_calc/./src/fmt_numbro.js","webpack://a_calc/./src/fmt.js","webpack://a_calc/./src/utils.js","webpack://a_calc/./src/calc.js","webpack://a_calc/./src/infix2postfix.js"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"numbro\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"numbro\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"a_calc\"] = factory(require(\"numbro\"));\n\telse\n\t\troot[\"a_calc\"] = factory(root[\"numbro\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE__655__) {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__655__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\r\n* 格式化计算式到队列\r\n* */\r\n\r\nfunction expr2que (expr) {\r\n\r\n let atomArr = []; // 原子列表\r\n\r\n let tempStr = ''; // 临时存储数字的字符串\r\n let symbolStr = '+-*/%()'; // 遇到这样的标识表示临时存储字符串应该进入队列了\r\n let fIndex = expr.search(/\\S/); // 储存第一个非空白字符的位置\r\n\r\n for ( let i = 0, len = expr.length; i < len; i++ ) {\r\n let cur = expr[i];\r\n // 如果碰到符号连着符号的情况,例如某个负数前面就是括号, 某个负数前面有一加号 开头就是数字的\r\n if ( i === fIndex && '+-'.includes(cur) ) { // 处理第一个是负数的情况\r\n tempStr += cur;\r\n continue;\r\n }\r\n\r\n if ( cur === ' ' || symbolStr.includes(cur) ) {\r\n if ( '+-'.includes(cur) && '(+-*/%'.includes(atomArr[atomArr.length - 1]) ) {\r\n tempStr += cur;\r\n continue;\r\n }\r\n\r\n if ( tempStr !== '' ) {\r\n atomArr.push(tempStr);\r\n tempStr = '';\r\n }\r\n if ( cur !== ' ' ) {\r\n atomArr.push(cur);\r\n }\r\n } else {\r\n tempStr += cur; // 如果不是那些特殊表示字符则不断向临时存储字符串添加字符\r\n }\r\n }\r\n\r\n if ( tempStr !== '' ) {\r\n atomArr.push(tempStr);\r\n tempStr = null;\r\n }\r\n\r\n\r\n return atomArr;\r\n\r\n}\r\n\r\nexport { expr2que };\r\n\r\n\r\n","function parseArgs (args) {\r\n // 处理传进来的参数, 输出统一格式的参数\r\n let result = {\r\n expr: '',\r\n fmt: '',\r\n };\r\n\r\n // 先定义一个最终的拼接字符串, 这个字符串经过一些判断计算得到\r\n let calcStr = '';\r\n let arg1 = args[0];\r\n\r\n\r\n if ( args.length === 1 && typeof arg1 === 'string' ) {\r\n calcStr = arg1;\r\n } else if(args.length === 1 && typeof arg1 === 'number'){\r\n calcStr = arg1.toString()\r\n }else if ( args.length === 1 && Array.isArray(arg1) ) {\r\n calcStr = arg1[0];\r\n } else if ( args.length > 1 ) {\r\n let strArr = args.shift();\r\n while ( strArr.length < 1 && args.length < 1 ) {\r\n let str1 = strArr.shift();\r\n if ( str1 === undefined ) {\r\n str1 = '';\r\n }\r\n let str2 = args.shift();\r\n if ( str2 === undefined ) {\r\n str2 = '';\r\n } else if ( typeof str2 === 'number' ) {\r\n str2 = str2.toString();\r\n }\r\n\r\n calcStr = calcStr + str1 + str2;\r\n\r\n }\r\n }\r\n\r\n\r\n let calcArr = calcStr.split('|');\r\n if ( calcArr.length === 1 ) {\r\n result.expr = calcArr[0];\r\n } else {\r\n result.expr = calcArr[0];\r\n result.fmt = calcArr[1];\r\n }\r\n\r\n\r\n return result;\r\n\r\n}\r\n\r\nexport { parseArgs };\r\n","// 处理科学记数法的问题\r\nfunction scienceToStr (numStr) {\r\n // 判断是否是科学记数法, 如果是就处理不是就直接返回原来的值\r\n if(typeof numStr !== 'string'){\r\n numStr = numStr.toString()\r\n }\r\n\r\n if ( !numStr.includes('e') ) {\r\n return numStr;\r\n }\r\n\r\n let pattern = numStr.match(/^(-?[\\d.]+)e([+-])(\\d+)$/);\r\n if ( pattern === null ) {\r\n throw new Error(`科学计数法模式匹配出错: ${ numStr }`);\r\n }\r\n let base_str = pattern[1];\r\n let direction = pattern[2];\r\n let count = pattern[3]; // 这不是最终的count, 最终的count需要这个值减去 diff_count\r\n\r\n let symbol = ''; // 是否有负号\r\n if ( base_str.includes('-') ) {\r\n symbol = '-';\r\n base_str = base_str.replace('-', '');\r\n }\r\n\r\n let dotIndex = base_str.indexOf('.'); // 查找点的位置\r\n let diff_count = 0;\r\n\r\n\r\n if ( dotIndex !== -1 ) {\r\n let numArr = base_str.split('.');\r\n if ( direction === '+' ) {\r\n diff_count = numArr[1].length;\r\n } else {\r\n diff_count = numArr[0].length;\r\n }\r\n base_str = numArr.join('');\r\n }else if(direction === \"-\"){\r\n diff_count = 1\r\n }\r\n\r\n let final_count = count - diff_count;\r\n\r\n let final_num = \"\" // 最终返回的数字\r\n if(direction === \"-\"){\r\n final_num = \"0.\" + \"0\".repeat(final_count) + base_str\r\n }else{\r\n final_num = base_str + \"0\".repeat(final_count)\r\n }\r\n return symbol + final_num\r\n\r\n}\r\n\r\nexport { scienceToStr };\r\n","import {scienceToStr} from \"./science\";\r\n\r\n// 格式化对象\r\nfunction parseFmtStr (fmtStr) {\r\n // 根据格式化字符串导出一个对象 {thousandSeparated: null,mantissa: null,mantissa_type: null }\r\n let argObj = {\r\n thousandSeparated: null,\r\n mantissa: null,\r\n mantissa_type: null,\r\n };\r\n\r\n // 说明存在格式化字符串, 开始正则匹配\r\n let matchArr = fmtStr.match(/(<=|>=|=)\\s*(\\d+)/);\r\n if ( matchArr ) {\r\n argObj.mantissa_type = matchArr[1];\r\n argObj.mantissa = Number(matchArr[2]);\r\n }\r\n\r\n if ( fmtStr.lastIndexOf(',') !== -1 ) {\r\n argObj.thousandSeparated = true;\r\n }\r\n\r\n\r\n return argObj;\r\n}\r\n\r\nfunction fmtNumbro (numb, fmtStr) {\r\n // 根据 fmtArgs 格式化一个 numbro 对象, 并返回最终结果\r\n let result = ''; // 最后的返回结果\r\n\r\n let fmtObj = parseFmtStr(fmtStr);\r\n const {\r\n thousandSeparated,\r\n mantissa,\r\n mantissa_type,\r\n } = fmtObj;\r\n\r\n let fmtParam = {}; // 直接传给numbro的参数\r\n if ( thousandSeparated && !numb.value().toString().includes(\"e\") ) fmtParam.thousandSeparated = thousandSeparated;\r\n\r\n if ( mantissa_type ) { // 如果设置了位数相关就处理一下\r\n switch ( mantissa_type ) {\r\n case '=':\r\n fmtParam.mantissa = mantissa;\r\n result = numb.format(fmtParam);\r\n break;\r\n case '<=':\r\n fmtParam.mantissa = mantissa;\r\n fmtParam.trimMantissa = true;\r\n result = numb.format(fmtParam);\r\n break;\r\n case '>=':\r\n let resStr = numb.value();\r\n // 这里有可能toString之后是科学记数法,所以套一个科学记数法的方法\r\n let resArr = scienceToStr(resStr.toString()).split('.');\r\n\r\n if ( resArr.length === 1 || resArr[1].length < mantissa ) {\r\n fmtParam.mantissa = mantissa;\r\n result = numb.format(fmtParam);\r\n } else {\r\n result = numb.format(fmtParam);\r\n }\r\n break;\r\n default:\r\n throw new Error('尾数符号错误!');\r\n }\r\n } else {\r\n result = numb.format(fmtParam);\r\n }\r\n\r\n\r\n return result;\r\n}\r\n\r\nexport {\r\n fmtNumbro\r\n}\r\n","import { parseArgs } from './parse_args';\r\nimport numbro from 'numbro';\r\nimport { fmtNumbro } from './fmt_numbro';\r\nimport { scienceToStr } from './science';\r\n\r\nfunction fmt (...args) {\r\n let argObj = parseArgs(args);\r\n let { expr, fmt: fmtStr } = argObj;\r\n\r\n // 对表达式进行trim 操作\r\n expr = expr.trim();\r\n\r\n let exprNumbro = numbro(expr);\r\n\r\n return scienceToStr(fmtNumbro(exprNumbro, fmtStr));\r\n}\r\n\r\nexport { fmt };\r\n","function isOperator (value) {\r\n // 判断一个数字是否是操作符\r\n let operatorString = '+-*/%()';\r\n return operatorString.indexOf(value) > -1;\r\n}\r\n\r\nfunction getPrioraty (value) {\r\n // 将一个运算符转换成优先级数值\r\n switch ( value ) {\r\n case '+':\r\n case '-':\r\n return 1;\r\n case '*':\r\n case '/':\r\n case '%':\r\n return 2;\r\n default:\r\n return 0; // 括号为\r\n }\r\n}\r\n\r\nfunction prioraty (o1, o2) {\r\n // 判断 o1 优先级是否小于等于 o2 优先级\r\n return getPrioraty(o1) <= getPrioraty(o2);\r\n}\r\n\r\n\r\nexport {\r\n getPrioraty,\r\n isOperator,\r\n prioraty\r\n};\r\n","import numbro from \"numbro\";\r\nimport { expr2que } from \"./expr2que\";\r\nimport { fmt } from \"./fmt\";\r\nimport { scienceToStr } from \"./science\";\r\nimport { parseArgs } from \"./parse_args\";\r\nimport { isOperator } from \"./utils\";\r\nimport { infix2postfix } from \"./infix2postfix\";\r\nimport { fmtNumbro } from \"./fmt_numbro\";\r\n\r\nfunction evalPostfix (exprArr) {\r\n // 根据中缀表示法计算结果\r\n let outputStack = [];\r\n while ( exprArr.length > 0 ) {\r\n let cur = exprArr.shift();\r\n\r\n if ( !isOperator(cur) ) {\r\n outputStack.push(cur);\r\n } else {\r\n if ( outputStack.length < 2 ) {\r\n throw \"unvalid stack length\";\r\n }\r\n let sec = outputStack.pop();\r\n let fir = outputStack.pop();\r\n if ( typeof sec === \"string\" ) {\r\n sec = numbro(sec);\r\n }\r\n\r\n if ( typeof fir === \"string\" ) {\r\n fir = numbro(fir);\r\n }\r\n\r\n switch ( cur ) {\r\n case \"+\":\r\n outputStack.push(fir.add(sec));\r\n break;\r\n case \"-\":\r\n outputStack.push(fir.subtract(sec));\r\n break;\r\n case \"*\":\r\n outputStack.push(fir.multiply(sec));\r\n break;\r\n case \"/\":\r\n outputStack.push(fir.divide(sec));\r\n break;\r\n case \"%\":\r\n outputStack.push(\r\n numbro(\r\n Number(fir.value()) %\r\n Number(sec.value()),\r\n ),\r\n );\r\n break;\r\n }\r\n\r\n\r\n }\r\n }\r\n\r\n if ( outputStack.length !== 1 ) {\r\n throw \"unvalid expression\";\r\n } else {\r\n return outputStack[0];\r\n }\r\n}\r\n\r\n\r\nfunction calc (...args) {\r\n // 最终返回的字符串计算的方法\r\n let result = \"\"; // 计算的结果\r\n\r\n let argsObj = parseArgs(args); // 格式化后的参数, 只有表达式和格式化字符串\r\n\r\n let exprArr = expr2que(argsObj.expr);\r\n if ( exprArr.length === 1 ) { // 只有一个参数的时候直接进行格式化\r\n return scienceToStr(\r\n fmtNumbro(numbro(exprArr[0]), argsObj.fmt)\r\n );\r\n }\r\n\r\n let resNumbro = evalPostfix(infix2postfix(exprArr));\r\n\r\n // 根据 mantissa 和 mantissa_type 去处理尾数 根据 thousand 判断是否支持千分位\r\n\r\n if ( argsObj.fmt ) { // 如果有格式化字符串那么需要进行格式化字符串的处理\r\n result = fmtNumbro(resNumbro, argsObj.fmt);\r\n\r\n } else {\r\n result = resNumbro.value();\r\n }\r\n\r\n return scienceToStr(result);\r\n};\r\n\r\nexport {\r\n calc,\r\n expr2que,\r\n fmt,\r\n};\r\n","import { isOperator, prioraty } from './utils';\r\n\r\nfunction infix2postfix (expQue) {\r\n // 中缀表示法转后缀表示法\r\n let symbolQue = []; // 符号队列\r\n let outputQue = []; // 结果队列\r\n\r\n let exprArr = expQue; // 表达式列表\r\n\r\n while ( exprArr.length > 0 ) {\r\n let cur = exprArr.shift(); // 输入队列从头部取出一个\r\n\r\n if ( isOperator(cur) ) {\r\n if ( cur === '(' ) {\r\n symbolQue.push(cur);\r\n } else if ( cur === ')' ) {\r\n let po = symbolQue.pop();\r\n while ( po !== '(' && symbolQue.length > 0 ) {\r\n outputQue.push(po);\r\n po = symbolQue.pop();\r\n }\r\n if ( po !== '(' ) { // 如果找不到左括号说明括号匹配有问题\r\n throw 'error: unmatched ()';\r\n }\r\n } else {\r\n // 循环判断当前的运算符如果优先级比输出队列底部小或等就将输出队列的最后运算符放到结果队列\r\n\r\n while ( prioraty(cur, symbolQue[symbolQue.length - 1]) && symbolQue.length > 0 ) {\r\n outputQue.push(symbolQue.pop());\r\n }\r\n // 将当前运算符放到输出队列\r\n symbolQue.push(cur);\r\n }\r\n } else {\r\n outputQue.push(cur);\r\n }\r\n }\r\n\r\n if ( symbolQue.length > 0 ) {\r\n if ( symbolQue[symbolQue.length - 1] === ')' || symbolQue[symbolQue.length - 1] === '(' ) {\r\n throw 'error: unmatched ()';\r\n }\r\n while ( symbolQue.length > 0 ) {\r\n // 如果没有括号 最后把剩余在输出队列的内容添加到结果队列\r\n outputQue.push(symbolQue.pop());\r\n }\r\n }\r\n return outputQue;\r\n\r\n}\r\n\r\n\r\nexport { infix2postfix };\r\n"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE__655__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","expr2que","expr","atomArr","tempStr","fIndex","search","i","len","length","cur","includes","push","parseArgs","args","result","fmt","calcStr","arg1","toString","Array","isArray","strArr","shift","str1","str2","calcArr","split","scienceToStr","numStr","pattern","match","Error","base_str","direction","count","symbol","replace","diff_count","indexOf","numArr","join","final_count","final_num","repeat","fmtNumbro","numb","fmtStr","fmtObj","argObj","thousandSeparated","mantissa","mantissa_type","matchArr","Number","lastIndexOf","parseFmtStr","fmtParam","format","trimMantissa","resArr","trim","isOperator","getPrioraty","calc","argsObj","exprArr","resNumbro","outputStack","sec","pop","fir","add","subtract","multiply","divide","evalPostfix","expQue","symbolQue","outputQue","po","o1","o2","infix2postfix"],"sourceRoot":""}
|
package/example/index.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
let {calc,fmt} = require("../dist/calc.js")
|
|
2
|
-
|
|
3
|
-
// console.log(calc`-0.1 + -0.2 * 0.3`)
|
|
4
|
-
|
|
5
|
-
// console.log(calc("0.000000000000010000 * 2 | ,"))
|
|
6
|
-
// 0.00000000000001
|
|
7
|
-
// console.log(fmt("1111111.123456 | =2,"))
|
|
8
|
-
|
|
9
|
-
// console.log(calc("0.0000001 + 0.0000001 | >= 5"))
|
|
10
|
-
|
|
11
|
-
// console.log(calc("10000000 + 100000000 | =10 ,"))
|
|
12
|
-
|
|
13
|
-
console.log(calc("100 % 11 * 3"))
|
|
14
|
-
console.log(100 % 11 * 3)
|
package/example/index.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import a_calc from "../dist/calc.js";
|
|
2
|
-
|
|
3
|
-
// console.log(calc("1 + 2 | =2"))
|
|
4
|
-
// console.log(fmt("10000|,"))
|
|
5
|
-
|
|
6
|
-
const { calc, fmt } = a_calc;
|
|
7
|
-
|
|
8
|
-
// console.log(calc("1+1|>=2"));
|
|
9
|
-
// console.log(fmt("10000|,"));
|
|
10
|
-
|
|
11
|
-
// console.log(calc("0.1 + 0.2"))
|
|
12
|
-
|
|
13
|
-
// console.log(fmt(""))
|
|
14
|
-
|
|
15
|
-
// console.log(m)
|
|
16
|
-
// console.log(expr2que("1 + 2"))
|
|
17
|
-
// console.log(fmt)
|
|
18
|
-
|
|
19
|
-
// console.log(fmt("1000 |,"))
|
|
20
|
-
|
|
21
|
-
// console.log(m);
|
|
22
|
-
// console.log(expr2que("1000"))
|
package/example/numbro.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).numbro=e()}}(function(){return function a(o,u,c){function s(t,e){if(!u[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(l)return l(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=u[t]={exports:{}};o[t][0].call(i.exports,function(e){return s(o[t][1][e]||e)},i,i.exports,a,o,u,c)}return u[t].exports}for(var l="function"==typeof require&&require,e=0;e<c.length;e++)s(c[e]);return s}({1:[function(e,r,t){!function(e){"use strict";var t,T=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,U=Math.ceil,R=Math.floor,I="[BigNumber Error] ",$=I+"Number primitive has more than 15 significant digits: ",G=1e14,V=14,q=9007199254740991,Z=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],z=1e7,W=1e9;function H(e){var t=0|e;return 0<e||e===t?t:t-1}function Y(e){for(var t,r,n=1,i=e.length,a=e[0]+"";n<i;){for(t=e[n++]+"",r=V-t.length;r--;t="0"+t);a+=t}for(i=a.length;48===a.charCodeAt(--i););return a.slice(0,i+1||1)}function K(e,t){var r,n,i=e.c,a=t.c,o=e.s,u=t.s,c=e.e,s=t.e;if(!o||!u)return null;if(r=i&&!i[0],n=a&&!a[0],r||n)return r?n?0:-u:o;if(o!=u)return o;if(r=o<0,n=c==s,!i||!a)return n?0:!i^r?1:-1;if(!n)return s<c^r?1:-1;for(u=(c=i.length)<(s=a.length)?c:s,o=0;o<u;o++)if(i[o]!=a[o])return i[o]>a[o]^r?1:-1;return c==s?0:s<c^r?1:-1}function J(e,t,r,n){if(e<t||r<e||e!==R(e))throw Error(I+(n||"Argument")+("number"==typeof e?e<t||r<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function X(e){var t=e.c.length-1;return H(e.e/V)==t&&e.c[t]%2!=0}function Q(e,t){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function ee(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}(t=function e(t){var v,f,g,r,s,m,o,u,c,l,p,n=A.prototype={constructor:A,toString:null,valueOf:null},h=new A(1),y=20,b=4,d=-7,w=21,S=-1e7,O=1e7,x=!1,a=1,N=0,B={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},M="0123456789abcdefghijklmnopqrstuvwxyz";function A(e,t){var r,n,i,a,o,u,c,s,l=this;if(!(l instanceof A))return new A(e,t);if(null==t){if(e&&!0===e._isBigNumber)return l.s=e.s,void(!e.c||e.e>O?l.c=l.e=null:e.e<S?l.c=[l.e=0]:(l.e=e.e,l.c=e.c.slice()));if((u="number"==typeof e)&&0*e==0){if(l.s=1/e<0?(e=-e,-1):1,e===~~e){for(a=0,o=e;10<=o;o/=10,a++);return void(O<a?l.c=l.e=null:(l.e=a,l.c=[e]))}s=String(e)}else{if(!T.test(s=String(e)))return g(l,s,u);l.s=45==s.charCodeAt(0)?(s=s.slice(1),-1):1}-1<(a=s.indexOf("."))&&(s=s.replace(".","")),0<(o=s.search(/e/i))?(a<0&&(a=o),a+=+s.slice(o+1),s=s.substring(0,o)):a<0&&(a=s.length)}else{if(J(t,2,M.length,"Base"),10==t)return j(l=new A(e),y+l.e+1,b);if(s=String(e),u="number"==typeof e){if(0*e!=0)return g(l,s,u,t);if(l.s=1/e<0?(s=s.slice(1),-1):1,A.DEBUG&&15<s.replace(/^0\.0*|\./,"").length)throw Error($+e)}else l.s=45===s.charCodeAt(0)?(s=s.slice(1),-1):1;for(r=M.slice(0,t),a=o=0,c=s.length;o<c;o++)if(r.indexOf(n=s.charAt(o))<0){if("."==n){if(a<o){a=c;continue}}else if(!i&&(s==s.toUpperCase()&&(s=s.toLowerCase())||s==s.toLowerCase()&&(s=s.toUpperCase()))){i=!0,o=-1,a=0;continue}return g(l,String(e),u,t)}u=!1,-1<(a=(s=f(s,t,10,l.s)).indexOf("."))?s=s.replace(".",""):a=s.length}for(o=0;48===s.charCodeAt(o);o++);for(c=s.length;48===s.charCodeAt(--c););if(s=s.slice(o,++c)){if(c-=o,u&&A.DEBUG&&15<c&&(q<e||e!==R(e)))throw Error($+l.s*e);if((a=a-o-1)>O)l.c=l.e=null;else if(a<S)l.c=[l.e=0];else{if(l.e=a,l.c=[],o=(a+1)%V,a<0&&(o+=V),o<c){for(o&&l.c.push(+s.slice(0,o)),c-=V;o<c;)l.c.push(+s.slice(o,o+=V));o=V-(s=s.slice(o)).length}else o-=c;for(;o--;s+="0");l.c.push(+s)}}else l.c=[l.e=0]}function D(e,t,r,n){for(var i,a,o=[0],u=0,c=e.length;u<c;){for(a=o.length;a--;o[a]*=t);for(o[0]+=n.indexOf(e.charAt(u++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}function E(e,t,r){var n,i,a,o,u=0,c=e.length,s=t%z,l=t/z|0;for(e=e.slice();c--;)u=((i=s*(a=e[c]%z)+(n=l*a+(o=e[c]/z|0)*s)%z*z+u)/r|0)+(n/z|0)+l*o,e[c]=i%r;return u&&(e=[u].concat(e)),e}function F(e,t,r,n){var i,a;if(r!=n)a=n<r?1:-1;else for(i=a=0;i<r;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function k(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&1<e.length;e.splice(0,1));}function i(e,t,r,n){var i,a,o,u,c;if(null==r?r=b:J(r,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,null==t)c=Y(e.c),c=1==n||2==n&&(o<=d||w<=o)?Q(c,o):ee(c,o,"0");else if(a=(e=j(new A(e),t,r)).e,u=(c=Y(e.c)).length,1==n||2==n&&(t<=a||a<=d)){for(;u<t;c+="0",u++);c=Q(c,a)}else if(t-=o,c=ee(c,a,"0"),u<a+1){if(0<--t)for(c+=".";t--;c+="0");}else if(0<(t+=a-u))for(a+1==u&&(c+=".");t--;c+="0");return e.s<0&&i?"-"+c:c}function _(e,t){for(var r,n=1,i=new A(e[0]);n<e.length;n++){if(!(r=new A(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function L(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];10<=i;i/=10,n++);return(r=n+r*V-1)>O?e.c=e.e=null:r<S?e.c=[e.e=0]:(e.e=r,e.c=t),e}function j(e,t,r,n){var i,a,o,u,c,s,l,f=e.c,g=Z;if(f){e:{for(i=1,u=f[0];10<=u;u/=10,i++);if((a=t-i)<0)a+=V,o=t,l=(c=f[s=0])/g[i-o-1]%10|0;else if((s=U((a+1)/V))>=f.length){if(!n)break e;for(;f.length<=s;f.push(0));c=l=0,o=(a%=V)-V+(i=1)}else{for(c=u=f[s],i=1;10<=u;u/=10,i++);l=(o=(a%=V)-V+i)<0?0:c/g[i-o-1]%10|0}if(n=n||t<0||null!=f[s+1]||(o<0?c:c%g[i-o-1]),n=r<4?(l||n)&&(0==r||r==(e.s<0?3:2)):5<l||5==l&&(4==r||n||6==r&&(0<a?0<o?c/g[i-o]:0:f[s-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=g[(V-t%V)%V],e.e=-t||0):f[0]=e.e=0,e;if(0==a?(f.length=s,u=1,s--):(f.length=s+1,u=g[V-a],f[s]=0<o?R(c/g[i-o]%g[o])*u:0),n)for(;;){if(0==s){for(a=1,o=f[0];10<=o;o/=10,a++);for(o=f[0]+=u,u=1;10<=o;o/=10,u++);a!=u&&(e.e++,f[0]==G&&(f[0]=1));break}if(f[s]+=u,f[s]!=G)break;f[s--]=0,u=1}for(a=f.length;0===f[--a];f.pop());}e.e>O?e.c=e.e=null:e.e<S&&(e.c=[e.e=0])}return e}function P(e){var t,r=e.e;return null===r?e.toString():(t=Y(e.c),t=r<=d||w<=r?Q(t,r):ee(t,r,"0"),e.s<0?"-"+t:t)}return A.clone=e,A.ROUND_UP=0,A.ROUND_DOWN=1,A.ROUND_CEIL=2,A.ROUND_FLOOR=3,A.ROUND_HALF_UP=4,A.ROUND_HALF_DOWN=5,A.ROUND_HALF_EVEN=6,A.ROUND_HALF_CEIL=7,A.ROUND_HALF_FLOOR=8,A.EUCLID=9,A.config=A.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(I+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(J(r=e[t],0,W,t),y=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(J(r=e[t],0,8,t),b=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(J(r[0],-W,0,t),J(r[1],0,W,t),d=r[0],w=r[1]):(J(r,-W,W,t),d=-(w=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)J(r[0],-W,-1,t),J(r[1],1,W,t),S=r[0],O=r[1];else{if(J(r,-W,W,t),!r)throw Error(I+t+" cannot be zero: "+r);S=-(O=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(I+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw x=!r,Error(I+"crypto unavailable");x=r}else x=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(J(r=e[t],0,9,t),a=r),e.hasOwnProperty(t="POW_PRECISION")&&(J(r=e[t],0,W,t),N=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(I+t+" not an object: "+r);B=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.$|[+-.\s]|(.).*\1/.test(r))throw Error(I+t+" invalid: "+r);M=r}}return{DECIMAL_PLACES:y,ROUNDING_MODE:b,EXPONENTIAL_AT:[d,w],RANGE:[S,O],CRYPTO:x,MODULO_MODE:a,POW_PRECISION:N,FORMAT:B,ALPHABET:M}},A.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!A.DEBUG)return!0;var t,r,n=e.c,i=e.e,a=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===a||-1===a)&&-W<=i&&i<=W&&i===R(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%V)<1&&(t+=V),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||G<=r||r!==R(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===a||1===a||-1===a))return!0;throw Error(I+"Invalid BigNumber: "+e)},A.maximum=A.max=function(){return _(arguments,n.lt)},A.minimum=A.min=function(){return _(arguments,n.gt)},A.random=(r=9007199254740992,s=Math.random()*r&2097151?function(){return R(Math.random()*r)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,a,o=0,u=[],c=new A(h);if(null==e?e=y:J(e,0,W),i=U(e/V),x)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));o<i;)9e15<=(a=131072*t[o]+(t[o+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),t[o]=r[0],t[o+1]=r[1]):(u.push(a%1e14),o+=2);o=i/2}else{if(!crypto.randomBytes)throw x=!1,Error(I+"crypto unavailable");for(t=crypto.randomBytes(i*=7);o<i;)9e15<=(a=281474976710656*(31&t[o])+1099511627776*t[o+1]+4294967296*t[o+2]+16777216*t[o+3]+(t[o+4]<<16)+(t[o+5]<<8)+t[o+6])?crypto.randomBytes(7).copy(t,o):(u.push(a%1e14),o+=7);o=i/7}if(!x)for(;o<i;)(a=s())<9e15&&(u[o++]=a%1e14);for(i=u[--o],e%=V,i&&e&&(a=Z[V-e],u[o]=R(i/a)*a);0===u[o];u.pop(),o--);if(o<0)u=[n=0];else{for(n=-1;0===u[0];u.splice(0,1),n-=V);for(o=1,a=u[0];10<=a;a/=10,o++);o<V&&(n-=V-o)}return c.e=n,c.c=u,c}),A.sum=function(){for(var e=1,t=arguments,r=new A(t[0]);e<t.length;)r=r.plus(t[e++]);return r},m="0123456789",f=function(e,t,r,n,i){var a,o,u,c,s,l,f,g,p=e.indexOf("."),d=y,h=b;for(0<=p&&(c=N,N=0,e=e.replace(".",""),l=(g=new A(t)).pow(e.length-p),N=c,g.c=D(ee(Y(l.c),l.e,"0"),10,r,m),g.e=g.c.length),u=c=(f=D(e,t,r,i?(a=M,m):(a=m,M))).length;0==f[--c];f.pop());if(!f[0])return a.charAt(0);if(p<0?--u:(l.c=f,l.e=u,l.s=n,f=(l=v(l,g,d,h,r)).c,s=l.r,u=l.e),p=f[o=u+d+1],c=r/2,s=s||o<0||null!=f[o+1],s=h<4?(null!=p||s)&&(0==h||h==(l.s<0?3:2)):c<p||p==c&&(4==h||s||6==h&&1&f[o-1]||h==(l.s<0?8:7)),o<1||!f[0])e=s?ee(a.charAt(1),-d,a.charAt(0)):a.charAt(0);else{if(f.length=o,s)for(--r;++f[--o]>r;)f[o]=0,o||(++u,f=[1].concat(f));for(c=f.length;!f[--c];);for(p=0,e="";p<=c;e+=a.charAt(f[p++]));e=ee(e,u,a.charAt(0))}return e},v=function(e,t,r,n,i){var a,o,u,c,s,l,f,g,p,d,h,v,m,y,b,w,S,O=e.s==t.s?1:-1,x=e.c,N=t.c;if(!(x&&x[0]&&N&&N[0]))return new A(e.s&&t.s&&(x?!N||x[0]!=N[0]:N)?x&&0==x[0]||!N?0*O:O/0:NaN);for(p=(g=new A(O)).c=[],O=r+(o=e.e-t.e)+1,i||(i=G,o=H(e.e/V)-H(t.e/V),O=O/V|0),u=0;N[u]==(x[u]||0);u++);if(N[u]>(x[u]||0)&&o--,O<0)p.push(1),c=!0;else{for(y=x.length,w=N.length,O+=2,1<(s=R(i/(N[u=0]+1)))&&(N=E(N,s,i),x=E(x,s,i),w=N.length,y=x.length),m=w,h=(d=x.slice(0,w)).length;h<w;d[h++]=0);S=N.slice(),S=[0].concat(S),b=N[0],N[1]>=i/2&&b++;do{if(s=0,(a=F(N,d,w,h))<0){if(v=d[0],w!=h&&(v=v*i+(d[1]||0)),1<(s=R(v/b)))for(i<=s&&(s=i-1),f=(l=E(N,s,i)).length,h=d.length;1==F(l,d,f,h);)s--,k(l,w<f?S:N,f,i),f=l.length,a=1;else 0==s&&(a=s=1),f=(l=N.slice()).length;if(f<h&&(l=[0].concat(l)),k(d,l,h,i),h=d.length,-1==a)for(;F(N,d,w,h)<1;)s++,k(d,w<h?S:N,h,i),h=d.length}else 0===a&&(s++,d=[0]);p[u++]=s,d[0]?d[h++]=x[m]||0:(d=[x[m]],h=1)}while((m++<y||null!=d[0])&&O--);c=null!=d[0],p[0]||p.splice(0,1)}if(i==G){for(u=1,O=p[0];10<=O;O/=10,u++);j(g,r+(g.e=u+o*V-1)+1,n,c)}else g.e=o,g.r=+c;return g},o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,c=/^\.([^.]+)$/,l=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g,g=function(e,t,r,n){var i,a=r?t:t.replace(p,"");if(l.test(a))e.s=isNaN(a)?null:a<0?-1:1;else{if(!r&&(a=a.replace(o,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,a=a.replace(u,"$1").replace(c,"0.$1")),t!=a))return new A(a,i);if(A.DEBUG)throw Error(I+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},n.absoluteValue=n.abs=function(){var e=new A(this);return e.s<0&&(e.s=1),e},n.comparedTo=function(e,t){return K(this,new A(e,t))},n.decimalPlaces=n.dp=function(e,t){var r,n,i;if(null!=e)return J(e,0,W),null==t?t=b:J(t,0,8),j(new A(this),e+this.e+1,t);if(!(r=this.c))return null;if(n=((i=r.length-1)-H(this.e/V))*V,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},n.dividedBy=n.div=function(e,t){return v(this,new A(e,t),y,b)},n.dividedToIntegerBy=n.idiv=function(e,t){return v(this,new A(e,t),0,1)},n.exponentiatedBy=n.pow=function(e,t){var r,n,i,a,o,u,c,s,l=this;if((e=new A(e)).c&&!e.isInteger())throw Error(I+"Exponent not an integer: "+P(e));if(null!=t&&(t=new A(t)),o=14<e.e,!l.c||!l.c[0]||1==l.c[0]&&!l.e&&1==l.c.length||!e.c||!e.c[0])return s=new A(Math.pow(+P(l),o?2-X(e):+P(e))),t?s.mod(t):s;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new A(NaN);(n=!u&&l.isInteger()&&t.isInteger())&&(l=l.mod(t))}else{if(9<e.e&&(0<l.e||l.e<-1||(0==l.e?1<l.c[0]||o&&24e7<=l.c[1]:l.c[0]<8e13||o&&l.c[0]<=9999975e7)))return a=l.s<0&&X(e)?-0:0,-1<l.e&&(a=1/a),new A(u?1/a:a);N&&(a=U(N/V+2))}for(c=o?(r=new A(.5),u&&(e.s=1),X(e)):(i=Math.abs(+P(e)))%2,s=new A(h);;){if(c){if(!(s=s.times(l)).c)break;a?s.c.length>a&&(s.c.length=a):n&&(s=s.mod(t))}if(i){if(0===(i=R(i/2)))break;c=i%2}else if(j(e=e.times(r),e.e+1,1),14<e.e)c=X(e);else{if(0==(i=+P(e)))break;c=i%2}l=l.times(l),a?l.c&&l.c.length>a&&(l.c.length=a):n&&(l=l.mod(t))}return n?s:(u&&(s=h.div(s)),t?s.mod(t):a?j(s,N,b,void 0):s)},n.integerValue=function(e){var t=new A(this);return null==e?e=b:J(e,0,8),j(t,t.e+1,e)},n.isEqualTo=n.eq=function(e,t){return 0===K(this,new A(e,t))},n.isFinite=function(){return!!this.c},n.isGreaterThan=n.gt=function(e,t){return 0<K(this,new A(e,t))},n.isGreaterThanOrEqualTo=n.gte=function(e,t){return 1===(t=K(this,new A(e,t)))||0===t},n.isInteger=function(){return!!this.c&&H(this.e/V)>this.c.length-2},n.isLessThan=n.lt=function(e,t){return K(this,new A(e,t))<0},n.isLessThanOrEqualTo=n.lte=function(e,t){return-1===(t=K(this,new A(e,t)))||0===t},n.isNaN=function(){return!this.s},n.isNegative=function(){return this.s<0},n.isPositive=function(){return 0<this.s},n.isZero=function(){return!!this.c&&0==this.c[0]},n.minus=function(e,t){var r,n,i,a,o=this,u=o.s;if(t=(e=new A(e,t)).s,!u||!t)return new A(NaN);if(u!=t)return e.s=-t,o.plus(e);var c=o.e/V,s=e.e/V,l=o.c,f=e.c;if(!c||!s){if(!l||!f)return l?(e.s=-t,e):new A(f?o:NaN);if(!l[0]||!f[0])return f[0]?(e.s=-t,e):new A(l[0]?o:3==b?-0:0)}if(c=H(c),s=H(s),l=l.slice(),u=c-s){for((i=(a=u<0)?(u=-u,l):(s=c,f)).reverse(),t=u;t--;i.push(0));i.reverse()}else for(n=(a=(u=l.length)<(t=f.length))?u:t,u=t=0;t<n;t++)if(l[t]!=f[t]){a=l[t]<f[t];break}if(a&&(i=l,l=f,f=i,e.s=-e.s),0<(t=(n=f.length)-(r=l.length)))for(;t--;l[r++]=0);for(t=G-1;u<n;){if(l[--n]<f[n]){for(r=n;r&&!l[--r];l[r]=t);--l[r],l[n]+=G}l[n]-=f[n]}for(;0==l[0];l.splice(0,1),--s);return l[0]?L(e,l,s):(e.s=3==b?-1:1,e.c=[e.e=0],e)},n.modulo=n.mod=function(e,t){var r,n,i=this;return e=new A(e,t),!i.c||!e.s||e.c&&!e.c[0]?new A(NaN):!e.c||i.c&&!i.c[0]?new A(i):(9==a?(n=e.s,e.s=1,r=v(i,e,0,3),e.s=n,r.s*=n):r=v(i,e,0,a),(e=i.minus(r.times(e))).c[0]||1!=a||(e.s=i.s),e)},n.multipliedBy=n.times=function(e,t){var r,n,i,a,o,u,c,s,l,f,g,p,d,h,v,m=this,y=m.c,b=(e=new A(e,t)).c;if(!(y&&b&&y[0]&&b[0]))return!m.s||!e.s||y&&!y[0]&&!b||b&&!b[0]&&!y?e.c=e.e=e.s=null:(e.s*=m.s,y&&b?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=H(m.e/V)+H(e.e/V),e.s*=m.s,(c=y.length)<(f=b.length)&&(d=y,y=b,b=d,i=c,c=f,f=i),i=c+f,d=[];i--;d.push(0));for(h=G,v=z,i=f;0<=--i;){for(r=0,g=b[i]%v,p=b[i]/v|0,a=i+(o=c);i<a;)r=((s=g*(s=y[--o]%v)+(u=p*s+(l=y[o]/v|0)*g)%v*v+d[a]+r)/h|0)+(u/v|0)+p*l,d[a--]=s%h;d[a]=r}return r?++n:d.splice(0,1),L(e,d,n)},n.negated=function(){var e=new A(this);return e.s=-e.s||null,e},n.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new A(e,t)).s,!i||!t)return new A(NaN);if(i!=t)return e.s=-t,n.minus(e);var a=n.e/V,o=e.e/V,u=n.c,c=e.c;if(!a||!o){if(!u||!c)return new A(i/0);if(!u[0]||!c[0])return c[0]?e:new A(u[0]?n:0*i)}if(a=H(a),o=H(o),u=u.slice(),i=a-o){for((r=0<i?(o=a,c):(i=-i,u)).reverse();i--;r.push(0));r.reverse()}for((i=u.length)-(t=c.length)<0&&(r=c,c=u,u=r,t=i),i=0;t;)i=(u[--t]=u[t]+c[t]+i)/G|0,u[t]=G===u[t]?0:u[t]%G;return i&&(u=[i].concat(u),++o),L(e,u,o)},n.precision=n.sd=function(e,t){var r,n,i;if(null!=e&&e!==!!e)return J(e,1,W),null==t?t=b:J(t,0,8),j(new A(this),e,t);if(!(r=this.c))return null;if(n=(i=r.length-1)*V+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];10<=i;i/=10,n++);}return e&&this.e+1>n&&(n=this.e+1),n},n.shiftedBy=function(e){return J(e,-q,q),this.times("1e"+e)},n.squareRoot=n.sqrt=function(){var e,t,r,n,i,a=this,o=a.c,u=a.s,c=a.e,s=y+4,l=new A("0.5");if(1!==u||!o||!o[0])return new A(!u||u<0&&(!o||o[0])?NaN:o?a:1/0);if((r=0==(u=Math.sqrt(+P(a)))||u==1/0?(((t=Y(o)).length+c)%2==0&&(t+="0"),u=Math.sqrt(+t),c=H((c+1)/2)-(c<0||c%2),new A(t=u==1/0?"1e"+c:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+c)):new A(u+"")).c[0])for((u=(c=r.e)+s)<3&&(u=0);;)if(i=r,r=l.times(i.plus(v(a,i,s,1))),Y(i.c).slice(0,u)===(t=Y(r.c)).slice(0,u)){if(r.e<c&&--u,"9999"!=(t=t.slice(u-3,u+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(j(r,r.e+y+2,1),e=!r.times(r).eq(a));break}if(!n&&(j(i,i.e+y+2,0),i.times(i).eq(a))){r=i;break}s+=4,u+=4,n=1}return j(r,r.e+y+1,b,e)},n.toExponential=function(e,t){return null!=e&&(J(e,0,W),e++),i(this,e,t,1)},n.toFixed=function(e,t){return null!=e&&(J(e,0,W),e=e+this.e+1),i(this,e,t)},n.toFormat=function(e,t,r){var n;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=B;else if("object"!=typeof r)throw Error(I+"Argument not an object: "+r);if(n=this.toFixed(e,t),this.c){var i,a=n.split("."),o=+r.groupSize,u=+r.secondaryGroupSize,c=r.groupSeparator||"",s=a[0],l=a[1],f=this.s<0,g=f?s.slice(1):s,p=g.length;if(u&&(i=o,o=u,p-=u=i),0<o&&0<p){for(i=p%o||o,s=g.substr(0,i);i<p;i+=o)s+=c+g.substr(i,o);0<u&&(s+=c+g.slice(i)),f&&(s="-"+s)}n=l?s+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?l.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):l):s}return(r.prefix||"")+n+(r.suffix||"")},n.toFraction=function(e){var t,r,n,i,a,o,u,c,s,l,f,g,p=this,d=p.c;if(null!=e&&(!(u=new A(e)).isInteger()&&(u.c||1!==u.s)||u.lt(h)))throw Error(I+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+P(u));if(!d)return new A(p);for(t=new A(h),s=r=new A(h),n=c=new A(h),g=Y(d),a=t.e=g.length-p.e-1,t.c[0]=Z[(o=a%V)<0?V+o:o],e=!e||0<u.comparedTo(t)?0<a?t:s:u,o=O,O=1/0,u=new A(g),c.c[0]=0;l=v(u,t,0,1),1!=(i=r.plus(l.times(n))).comparedTo(e);)r=n,n=i,s=c.plus(l.times(i=s)),c=i,t=u.minus(l.times(i=t)),u=i;return i=v(e.minus(r),n,0,1),c=c.plus(i.times(s)),r=r.plus(i.times(n)),c.s=s.s=p.s,f=v(s,n,a*=2,b).minus(p).abs().comparedTo(v(c,r,a,b).minus(p).abs())<1?[s,n]:[c,r],O=o,f},n.toNumber=function(){return+P(this)},n.toPrecision=function(e,t){return null!=e&&J(e,1,W),i(this,e,t,2)},n.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(t=null==e?i<=d||w<=i?Q(Y(r.c),i):ee(Y(r.c),i,"0"):10===e?ee(Y((r=j(new A(r),y+i+1,b)).c),r.e,"0"):(J(e,2,M.length,"Base"),f(ee(Y(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},n.valueOf=n.toJSON=function(){return P(this)},n._isBigNumber=!0,C&&(n[Symbol.toStringTag]="BigNumber",n[Symbol.for("nodejs.util.inspect.custom")]=n.valueOf),null!=t&&A.set(t),A}()).default=t.BigNumber=t,void 0!==r&&r.exports?r.exports=t:(e=e||("undefined"!=typeof self&&self?self:window)).BigNumber=t}(this)},{}],2:[function(e,t,r){"use strict";t.exports={languageTag:"en-US",delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},spaceSeparated:!1,ordinal:function(e){var t=e%10;return 1==~~(e%100/10)?"th":1==t?"st":2==t?"nd":3==t?"rd":"th"},bytes:{binarySuffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],decimalSuffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},currency:{symbol:"$",position:"prefix",code:"USD"},currencyFormat:{thousandSeparated:!0,totalLength:4,spaceSeparated:!0,spaceSeparatedCurrency:!0},formats:{fourDigits:{totalLength:4,spaceSeparated:!0},fullWithTwoDecimals:{output:"currency",thousandSeparated:!0,mantissa:2},fullWithTwoDecimalsNoCurrency:{thousandSeparated:!0,mantissa:2},fullWithNoDecimals:{output:"currency",thousandSeparated:!0,mantissa:0}}}},{}],3:[function(e,t,r){"use strict";function I(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,i=!1,a=void 0;try{for(var o,u=e[Symbol.iterator]();!(n=(o=u.next()).done)&&(r.push(o.value),!t||r.length!==t);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var $=e("./globalState"),o=e("./validating"),u=e("./parsing"),i=e("bignumber.js"),G={trillion:Math.pow(10,12),billion:Math.pow(10,9),million:Math.pow(10,6),thousand:Math.pow(10,3)},V={totalLength:0,characteristic:0,forceAverage:!1,average:!1,mantissa:-1,optionalMantissa:!0,thousandSeparated:!1,spaceSeparated:!1,negative:"sign",forceSign:!1,roundingFunction:Math.round,spaceSeparatedAbbreviation:!1},n=$.currentBytes(),d=n.binarySuffixes,h=n.decimalSuffixes,a={general:{scale:1024,suffixes:h,marker:"bd"},binary:{scale:1024,suffixes:d,marker:"b"},decimal:{scale:1e3,suffixes:h,marker:"d"}};function c(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=2<arguments.length?arguments[2]:void 0;if("string"==typeof t&&(t=u.parseFormat(t)),!o.validateFormat(t))return"ERROR: invalid format";var n=t.prefix||"",i=t.postfix||"",a=function(e,t,r){switch(t.output){case"currency":return t=s(t,$.currentCurrencyDefaultFormat()),function(e,t,r){var n=r.currentCurrency(),i=Object.assign({},t),a=Object.assign({},V,i),o=void 0,u="",c=!!a.totalLength||!!a.forceAverage||a.average,s=i.currencyPosition||n.position,l=i.currencySymbol||n.symbol,f=void 0!==a.spaceSeparatedCurrency?a.spaceSeparatedCurrency:a.spaceSeparated;void 0===i.lowPrecision&&(i.lowPrecision=!1);f&&(u=" ");"infix"===s&&(o=u+l+u);var g=m({instance:e,providedFormat:i,state:r,decimalSeparator:o});"prefix"===s&&(g=e._value<0&&"sign"===a.negative?"-".concat(u).concat(l).concat(g.slice(1)):0<e._value&&a.forceSign?"+".concat(u).concat(l).concat(g.slice(1)):l+u+g);s&&"postfix"!==s||(u=!a.spaceSeparatedAbbreviation&&c?"":u,g=g+u+l);return g}(e,t,$);case"percent":return t=s(t,$.currentPercentageDefaultFormat()),function(e,t,r,n){var i=t.prefixSymbol,a=m({instance:n(100*e._value),providedFormat:t,state:r}),o=Object.assign({},V,t);if(i)return"%".concat(o.spaceSeparated?" ":"").concat(a);return"".concat(a).concat(o.spaceSeparated?" ":"","%")}(e,t,$,r);case"byte":return t=s(t,$.currentByteDefaultFormat()),function(e,t,r,n){var i=t.base||"binary",a=Object.assign({},V,t),o=r.currentBytes(),u=o.binarySuffixes,c=o.decimalSuffixes,s={general:{scale:1024,suffixes:c||h,marker:"bd"},binary:{scale:1024,suffixes:u||d,marker:"b"},decimal:{scale:1e3,suffixes:c||h,marker:"d"}}[i],l=v(e._value,s.suffixes,s.scale),f=l.value,g=l.suffix,p=m({instance:n(f),providedFormat:t,state:r,defaults:r.currentByteDefaultFormat()});return"".concat(p).concat(a.spaceSeparated?" ":"").concat(g)}(e,t,$,r);case"time":return t=s(t,$.currentTimeDefaultFormat()),function(e){var t=Math.floor(e._value/60/60),r=Math.floor((e._value-60*t*60)/60),n=Math.round(e._value-60*t*60-60*r);return"".concat(t,":").concat(r<10?"0":"").concat(r,":").concat(n<10?"0":"").concat(n)}(e);case"ordinal":return t=s(t,$.currentOrdinalDefaultFormat()),function(e,t,r){var n=r.currentOrdinal(),i=Object.assign({},V,t),a=m({instance:e,providedFormat:t,state:r}),o=n(e._value);return"".concat(a).concat(i.spaceSeparated?" ":"").concat(o)}(e,t,$);case"number":default:return m({instance:e,providedFormat:t,numbro:r})}}(e,t,r);return a=(a=n+a)+i}function v(e,t,r){var n=t[0],i=Math.abs(e);if(r<=i){for(var a=1;a<t.length;++a){var o=Math.pow(r,a),u=Math.pow(r,a+1);if(o<=i&&i<u){n=t[a],e/=o;break}}n===t[0]&&(e/=Math.pow(r,t.length-1),n=t[t.length-1])}return{value:e,suffix:n}}function g(e){for(var t="",r=0;r<e;r++)t+="0";return t}function q(e,t,r){var n=2<arguments.length&&void 0!==r?r:Math.round;return-1!==e.toString().indexOf("e")?function(e,t){var r=e.toString(),n=I(r.split("e"),2),i=n[0],a=n[1],o=I(i.split("."),2),u=o[0],c=o[1],s=void 0===c?"":c;if(0<+a)r=u+s+g(a-s.length);else{var l=".";l=+u<0?"-0".concat(l):"0".concat(l);var f=(g(-a-1)+Math.abs(u)+s).substr(0,t);f.length<t&&(f+=g(t-f.length)),r=l+f}return 0<+a&&0<t&&(r+=".".concat(g(t))),r}(e,t):new i(n(+"".concat(e,"e+").concat(t))/Math.pow(10,t)).toFixed(t)}function Z(e,t,r,n,i){var a=n.currentDelimiters(),o=a.thousands;i=i||a.decimal;var u=a.thousandsSize||3,c=e.toString(),s=c.split(".")[0],l=c.split(".")[1],f=t<0&&0===s.indexOf("-");r&&(f&&(s=s.slice(1)),function(e,t){for(var r=[],n=0,i=e;0<i;i--)n===t&&(r.unshift(i),n=0),n++;return r}(s.length,u).forEach(function(e,t){s=s.slice(0,e+t)+o+s.slice(e+t)}),f&&(s="-".concat(s)));return c=l?s+i+l:s}function m(e){var t=e.instance,r=e.providedFormat,n=e.state,i=void 0===n?$:n,a=e.decimalSeparator,o=e.defaults,u=void 0===o?i.currentDefaults():o,c=t._value;if(0===c&&i.hasZeroFormat())return i.getZeroFormat();if(!isFinite(c))return c.toString();var s,l,f,g,p,d,h,v,m=Object.assign({},V,u,r),y=m.totalLength,b=y?0:m.characteristic,w=m.optionalCharacteristic,S=m.forceAverage,O=m.lowPrecision,x=!!y||!!S||m.average,N=y?-1:x&&void 0===r.mantissa?0:m.mantissa,B=!y&&(void 0===r.optionalMantissa?-1===N:m.optionalMantissa),M=m.trimMantissa,A=m.thousandSeparated,D=m.spaceSeparated,E=m.negative,F=m.forceSign,k=m.exponential,_=m.roundingFunction,L="";if(x){var j=function(e){var t=e.value,r=e.forceAverage,n=e.lowPrecision,i=void 0===n||n,a=e.abbreviations,o=e.spaceSeparated,u=void 0!==o&&o,c=e.totalLength,s=void 0===c?0:c,l=e.roundingFunction,f=void 0===l?Math.round:l,g="",p=Math.abs(t),d=-1;if(r&&a[r]&&G[r]?(g=a[r],t/=G[r]):p>=G.trillion||i&&1===f(p/G.trillion)?(g=a.trillion,t/=G.trillion):p<G.trillion&&p>=G.billion||i&&1===f(p/G.billion)?(g=a.billion,t/=G.billion):p<G.billion&&p>=G.million||i&&1===f(p/G.million)?(g=a.million,t/=G.million):(p<G.million&&p>=G.thousand||i&&1===f(p/G.thousand))&&(g=a.thousand,t/=G.thousand),g=g&&(u?" ":"")+g,s){var h=t<0,v=t.toString().split(".")[0],m=h?v.length-1:v.length;d=Math.max(s-m,0)}return{value:t,abbreviation:g,mantissaPrecision:d}}({value:c,forceAverage:S,lowPrecision:O,abbreviations:i.currentAbbreviations(),spaceSeparated:D,roundingFunction:_,totalLength:y});c=j.value,L+=j.abbreviation,y&&(N=j.mantissaPrecision)}if(k){var P=(l=(s={value:c,characteristicPrecision:b}).value,f=s.characteristicPrecision,g=void 0===f?0:f,p=I(l.toExponential().split("e"),2),d=p[0],h=p[1],v=+d,g&&1<g&&(v*=Math.pow(10,g-1),h=0<=(h-=g-1)?"+".concat(h):h),{value:v,abbreviation:"e".concat(h)});c=P.value,L=P.abbreviation+L}var T,C,U,R=function(e,t,r,n,i,a){if(-1===n)return e;var o=q(t,n,a),u=I(o.toString().split("."),2),c=u[0],s=u[1],l=void 0===s?"":s;if(l.match(/^0+$/)&&(r||i))return c;var f=l.match(/0+$/);return i&&f?"".concat(c,".").concat(l.toString().slice(0,f.index)):o.toString()}(c.toString(),c,B,N,M,_);return R=Z(R=function(e,t,r,n){var i=e,a=I(i.toString().split("."),2),o=a[0],u=a[1];if(o.match(/^-?0$/)&&r)return u?"".concat(o.replace("0",""),".").concat(u):o.replace("0","");var c=t<0&&0===o.indexOf("-");if(c&&(o=o.slice(1),i=i.slice(1)),o.length<n)for(var s=n-o.length,l=0;l<s;l++)i="0".concat(i);return c&&(i="-".concat(i)),i.toString()}(R,c,w,b),c,A,i,a),(x||k)&&(R=R+L),(F||c<0)&&(T=R,U=E,R=0===(C=c)?T:0==+T?T.replace("-",""):0<C?"+".concat(T):"sign"===U?T:"(".concat(T.replace("-",""),")")),R}function s(e,t){if(!e)return t;var r=Object.keys(e);return 1===r.length&&"output"===r[0]?t:e}t.exports=function(n){return{format:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return c.apply(void 0,t.concat([n]))},getByteUnit:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){var t=a.general;return v(e._value,t.suffixes,t.scale).suffix}.apply(void 0,t.concat([n]))},getBinaryByteUnit:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){var t=a.binary;return v(e._value,t.suffixes,t.scale).suffix}.apply(void 0,t.concat([n]))},getDecimalByteUnit:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){var t=a.decimal;return v(e._value,t.suffixes,t.scale).suffix}.apply(void 0,t.concat([n]))},formatOrDefault:s}}},{"./globalState":4,"./parsing":8,"./validating":10,"bignumber.js":1}],4:[function(e,t,r){"use strict";var i=e("./en-US"),n=e("./validating"),a=e("./parsing"),o={},u=void 0,c={},s=null,l={};function f(e){u=e}function g(){return c[u]}o.languages=function(){return Object.assign({},c)},o.currentLanguage=function(){return u},o.currentBytes=function(){return g().bytes||{}},o.currentCurrency=function(){return g().currency},o.currentAbbreviations=function(){return g().abbreviations},o.currentDelimiters=function(){return g().delimiters},o.currentOrdinal=function(){return g().ordinal},o.currentDefaults=function(){return Object.assign({},g().defaults,l)},o.currentOrdinalDefaultFormat=function(){return Object.assign({},o.currentDefaults(),g().ordinalFormat)},o.currentByteDefaultFormat=function(){return Object.assign({},o.currentDefaults(),g().byteFormat)},o.currentPercentageDefaultFormat=function(){return Object.assign({},o.currentDefaults(),g().percentageFormat)},o.currentCurrencyDefaultFormat=function(){return Object.assign({},o.currentDefaults(),g().currencyFormat)},o.currentTimeDefaultFormat=function(){return Object.assign({},o.currentDefaults(),g().timeFormat)},o.setDefaults=function(e){e=a.parseFormat(e),n.validateFormat(e)&&(l=e)},o.getZeroFormat=function(){return s},o.setZeroFormat=function(e){return s="string"==typeof e?e:null},o.hasZeroFormat=function(){return null!==s},o.languageData=function(e){if(e){if(c[e])return c[e];throw new Error('Unknown tag "'.concat(e,'"'))}return g()},o.registerLanguage=function(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(!n.validateLanguage(e))throw new Error("Invalid language data");c[e.languageTag]=e,t&&f(e.languageTag)},o.setLanguage=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:i.languageTag;if(!c[e]){var r=e.split("-")[0],n=Object.keys(c).find(function(e){return e.split("-")[0]===r});return c[n]?void f(n):void f(t)}f(e)},o.registerLanguage(i),u=i.languageTag,t.exports=o},{"./en-US":2,"./parsing":8,"./validating":10}],5:[function(n,e,t){"use strict";e.exports=function(t){return{loadLanguagesInNode:function(e){return r=t,void e.forEach(function(t){var e=void 0;try{e=n("../languages/".concat(t))}catch(e){console.error('Unable to load "'.concat(t,'". No matching language file found.'))}e&&r.registerLanguage(e)});var r}}}},{}],6:[function(e,t,r){"use strict";var c=e("bignumber.js");function a(e,t,r){var n=new c(e._value),i=t;return r.isNumbro(t)&&(i=t._value),i=new c(i),e._value=n.minus(i).toNumber(),e}t.exports=function(u){return{add:function(e,t){return n=t,i=u,a=new c((r=e)._value),o=n,i.isNumbro(n)&&(o=n._value),o=new c(o),r._value=a.plus(o).toNumber(),r;var r,n,i,a,o},subtract:function(e,t){return a(e,t,u)},multiply:function(e,t){return n=t,i=u,a=new c((r=e)._value),o=n,i.isNumbro(n)&&(o=n._value),o=new c(o),r._value=a.times(o).toNumber(),r;var r,n,i,a,o},divide:function(e,t){return n=t,i=u,a=new c((r=e)._value),o=n,i.isNumbro(n)&&(o=n._value),o=new c(o),r._value=a.dividedBy(o).toNumber(),r;var r,n,i,a,o},set:function(e,t){return r=e,i=n=t,u.isNumbro(n)&&(i=n._value),r._value=i,r;var r,n,i},difference:function(e,t){return r=t,a(i=(n=u)(e._value),r,n),Math.abs(i._value);var r,n,i},BigNumber:c}}},{"bignumber.js":1}],7:[function(e,t,r){"use strict";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)}}var a=e("./globalState"),n=e("./validating"),o=e("./loading")(p),u=e("./unformatting"),c=e("./formatting")(p),s=e("./manipulating")(p),l=e("./parsing"),f=function(){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this._value=e}var e,r,n;return e=t,(r=[{key:"clone",value:function(){return p(this._value)}},{key:"format",value:function(e){var t=0<arguments.length&&void 0!==e?e:{};return c.format(this,t)}},{key:"formatCurrency",value:function(e){return"string"==typeof e&&(e=l.parseFormat(e)),(e=c.formatOrDefault(e,a.currentCurrencyDefaultFormat())).output="currency",c.format(this,e)}},{key:"formatTime",value:function(e){var t=0<arguments.length&&void 0!==e?e:{};return t.output="time",c.format(this,t)}},{key:"binaryByteUnits",value:function(){return c.getBinaryByteUnit(this)}},{key:"decimalByteUnits",value:function(){return c.getDecimalByteUnit(this)}},{key:"byteUnits",value:function(){return c.getByteUnit(this)}},{key:"difference",value:function(e){return s.difference(this,e)}},{key:"add",value:function(e){return s.add(this,e)}},{key:"subtract",value:function(e){return s.subtract(this,e)}},{key:"multiply",value:function(e){return s.multiply(this,e)}},{key:"divide",value:function(e){return s.divide(this,e)}},{key:"set",value:function(e){return s.set(this,g(e))}},{key:"value",value:function(){return this._value}},{key:"valueOf",value:function(){return this._value}}])&&i(e.prototype,r),n&&i(e,n),t}();function g(e){var t=e;return p.isNumbro(e)?t=e._value:"string"==typeof e?t=p.unformat(e):isNaN(e)&&(t=NaN),t}function p(e){return new f(g(e))}p.version="2.3.6",p.isNumbro=function(e){return e instanceof f},p.language=a.currentLanguage,p.registerLanguage=a.registerLanguage,p.setLanguage=a.setLanguage,p.languages=a.languages,p.languageData=a.languageData,p.zeroFormat=a.setZeroFormat,p.defaultFormat=a.currentDefaults,p.setDefaults=a.setDefaults,p.defaultCurrencyFormat=a.currentCurrencyDefaultFormat,p.validate=n.validate,p.loadLanguagesInNode=o.loadLanguagesInNode,p.unformat=u.unformat,p.BigNumber=s.BigNumber,t.exports=p},{"./formatting":3,"./globalState":4,"./loading":5,"./manipulating":6,"./parsing":8,"./unformatting":9,"./validating":10}],8:[function(e,t,r){"use strict";t.exports={parseFormat:function(e){var t,r,n,i,a,o,u,c,s,l,f,g,p,d,h,v,m,y,b,w,S,O,x=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return"string"!=typeof e?e:(r=x,e=(n=(t=e).match(/^{([^}]*)}/))?(r.prefix=n[1],t.slice(n[0].length)):t,a=x,function(e,t){if(-1===e.indexOf("$")){if(-1===e.indexOf("%"))return-1!==e.indexOf("bd")?(t.output="byte",t.base="general"):-1!==e.indexOf("b")?(t.output="byte",t.base="binary"):-1!==e.indexOf("d")?(t.output="byte",t.base="decimal"):-1===e.indexOf(":")?-1!==e.indexOf("o")&&(t.output="ordinal"):t.output="time";t.output="percent"}else t.output="currency"}(e=(o=(i=e).match(/{([^}]*)}$/))?(a.postfix=o[1],i.slice(0,-o[0].length)):i,x),u=x,(c=e.match(/[1-9]+[0-9]*/))&&(u.totalLength=+c[0]),s=x,(l=e.split(".")[0].match(/0+/))&&(s.characteristic=l[0].length),function(e,t){if(-1!==e.indexOf(".")){var r=e.split(".")[0];t.optionalCharacteristic=-1===r.indexOf("0")}}(e,x),f=x,-1!==e.indexOf("a")&&(f.average=!0),p=x,-1!==(g=e).indexOf("K")?p.forceAverage="thousand":-1!==g.indexOf("M")?p.forceAverage="million":-1!==g.indexOf("B")?p.forceAverage="billion":-1!==g.indexOf("T")&&(p.forceAverage="trillion"),function(e,t){var r=e.split(".")[1];if(r){var n=r.match(/0+/);n&&(t.mantissa=n[0].length)}}(e,x),h=x,(d=e).match(/\[\.]/)?h.optionalMantissa=!0:d.match(/\./)&&(h.optionalMantissa=!1),v=x,(m=e.split(".")[1])&&(v.trimMantissa=-1!==m.indexOf("[")),y=x,-1!==e.indexOf(",")&&(y.thousandSeparated=!0),b=x,-1!==e.indexOf(" ")&&(b.spaceSeparated=!0,b.spaceSeparatedCurrency=!0,(b.average||b.forceAverage)&&(b.spaceSeparatedAbbreviation=!0)),S=x,(w=e).match(/^\+?\([^)]*\)$/)&&(S.negative="parenthesis"),w.match(/^\+?-/)&&(S.negative="sign"),O=x,e.match(/^\+/)&&(O.forceSign=!0),x)}}},{}],9:[function(g,e,t){"use strict";var M=[{key:"ZiB",factor:Math.pow(1024,7)},{key:"ZB",factor:Math.pow(1e3,7)},{key:"YiB",factor:Math.pow(1024,8)},{key:"YB",factor:Math.pow(1e3,8)},{key:"TiB",factor:Math.pow(1024,4)},{key:"TB",factor:Math.pow(1e3,4)},{key:"PiB",factor:Math.pow(1024,5)},{key:"PB",factor:Math.pow(1e3,5)},{key:"MiB",factor:Math.pow(1024,2)},{key:"MB",factor:Math.pow(1e3,2)},{key:"KiB",factor:Math.pow(1024,1)},{key:"KB",factor:Math.pow(1e3,1)},{key:"GiB",factor:Math.pow(1024,3)},{key:"GB",factor:Math.pow(1e3,3)},{key:"EiB",factor:Math.pow(1024,6)},{key:"EB",factor:Math.pow(1e3,6)},{key:"B",factor:1}];function A(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function p(e,t,r,n,i,a,o){var u=2<arguments.length&&void 0!==r?r:"",c=3<arguments.length?n:void 0,s=4<arguments.length?i:void 0,l=5<arguments.length?a:void 0,f=6<arguments.length?o:void 0;if(""!==e)return e===s?0:function e(t,r,n,i,a,o,u){var c=2<arguments.length&&void 0!==n?n:"",s=3<arguments.length?i:void 0,l=4<arguments.length?a:void 0,f=5<arguments.length?o:void 0,g=6<arguments.length?u:void 0;if(!isNaN(+t))return+t;var p="",d=t.replace(/(^[^(]*)\((.*)\)([^)]*$)/,"$1$2$3");if(d!==t)return-1*e(d,r,c,s,l,f,g);for(var h=0;h<M.length;h++){var v=M[h];if((p=t.replace(RegExp("([0-9 ])(".concat(v.key,")$")),"$1"))!==t)return e(p,r,c,s,l,f,g)*v.factor}if((p=t.replace("%",""))!==t)return e(p,r,c,s,l,f,g)/100;var m=parseFloat(t);if(!isNaN(m)){var y=s(m);if(y&&"."!==y&&(p=t.replace(new RegExp("".concat(A(y),"$")),""))!==t)return e(p,r,c,s,l,f,g);var b={};Object.keys(f).forEach(function(e){b[f[e]]=e});for(var w=Object.keys(b).sort().reverse(),S=w.length,O=0;O<S;O++){var x=w[O],N=b[x];if((p=t.replace(x,""))!==t){var B=void 0;switch(N){case"thousand":B=Math.pow(10,3);break;case"million":B=Math.pow(10,6);break;case"billion":B=Math.pow(10,9);break;case"trillion":B=Math.pow(10,12)}return e(p,r,c,s,l,f,g)*B}}}}(function(e,t,r){var n=2<arguments.length&&void 0!==r?r:"",i=e.replace(n,"");return i=(i=i.replace(new RegExp("([0-9])".concat(A(t.thousands),"([0-9])"),"g"),"$1$2")).replace(t.decimal,".")}(e,t,u),t,u,c,s,l,f)}e.exports={unformat:function(e,t){var r,n,i,a=g("./globalState"),o=a.currentDelimiters(),u=a.currentCurrency().symbol,c=a.currentOrdinal(),s=a.getZeroFormat(),l=a.currentAbbreviations(),f=void 0;if("string"==typeof e)f=function(e,t){if(e.indexOf(":")&&":"!==t.thousands){var r=e.split(":");if(3===r.length){var n=+r[0],i=+r[1],a=+r[2];return!isNaN(n)&&!isNaN(i)&&!isNaN(a)}}}(e,o)?(r=e.split(":"),n=+r[0],i=+r[1],+r[2]+60*i+3600*n):p(e,o,u,c,s,l,t);else{if("number"!=typeof e)return;f=e}if(void 0!==f)return f}}},{"./globalState":4}],10:[function(e,t,r){"use strict";function n(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i=e("./unformatting"),a=/^[a-z]{2,3}(-[a-zA-Z]{4})?(-([A-Z]{2}|[0-9]{3}))?$/,g={output:{type:"string",validValues:["currency","percent","byte","time","ordinal","number"]},base:{type:"string",validValues:["decimal","binary","general"],restriction:function(e,t){return"byte"===t.output},message:"`base` must be provided only when the output is `byte`",mandatory:function(e){return"byte"===e.output}},characteristic:{type:"number",restriction:function(e){return 0<=e},message:"value must be positive"},prefix:"string",postfix:"string",forceAverage:{type:"string",validValues:["trillion","billion","million","thousand"]},average:"boolean",lowPrecision:{type:"boolean",restriction:function(e,t){return!0===t.average},message:"`lowPrecision` must be provided only when the option `average` is set"},currencyPosition:{type:"string",validValues:["prefix","infix","postfix"]},currencySymbol:"string",totalLength:{type:"number",restrictions:[{restriction:function(e){return 0<=e},message:"value must be positive"},{restriction:function(e,t){return!t.exponential},message:"`totalLength` is incompatible with `exponential`"}]},mantissa:{type:"number",restriction:function(e){return 0<=e},message:"value must be positive"},optionalMantissa:"boolean",trimMantissa:"boolean",roundingFunction:"function",optionalCharacteristic:"boolean",thousandSeparated:"boolean",spaceSeparated:"boolean",spaceSeparatedCurrency:"boolean",spaceSeparatedAbbreviation:"boolean",abbreviations:{type:"object",children:{thousand:"string",million:"string",billion:"string",trillion:"string"}},negative:{type:"string",validValues:["sign","parenthesis"]},forceSign:"boolean",exponential:{type:"boolean"},prefixSymbol:{type:"boolean",restriction:function(e,t){return"percent"===t.output},message:"`prefixSymbol` can be provided only when the output is `percent`"}},o={languageTag:{type:"string",mandatory:!0,restriction:function(e){return e.match(a)},message:"the language tag must follow the BCP 47 specification (see https://tools.ieft.org/html/bcp47)"},delimiters:{type:"object",children:{thousands:"string",decimal:"string",thousandsSize:"number"},mandatory:!0},abbreviations:{type:"object",children:{thousand:{type:"string",mandatory:!0},million:{type:"string",mandatory:!0},billion:{type:"string",mandatory:!0},trillion:{type:"string",mandatory:!0}},mandatory:!0},spaceSeparated:"boolean",spaceSeparatedCurrency:"boolean",ordinal:{type:"function",mandatory:!0},bytes:{type:"object",children:{binarySuffixes:"object",decimalSuffixes:"object"}},currency:{type:"object",children:{symbol:"string",position:"string",code:"string"},mandatory:!0},defaults:"format",ordinalFormat:"format",byteFormat:"format",percentageFormat:"format",currencyFormat:"format",timeDefaults:"format",formats:{type:"object",children:{fourDigits:{type:"format",mandatory:!0},fullWithTwoDecimals:{type:"format",mandatory:!0},fullWithTwoDecimalsNoCurrency:{type:"format",mandatory:!0},fullWithNoDecimals:{type:"format",mandatory:!0}}}};function u(e){return void 0!==i.unformat(e)}function p(c,s,l,e){var t=3<arguments.length&&void 0!==e&&e,r=Object.keys(c).map(function(e){if(!s[e])return console.error("".concat(l," Invalid key: ").concat(e)),!1;var t=c[e],r=s[e];if("string"==typeof r&&(r={type:r}),"format"===r.type){if(!p(t,g,"[Validate ".concat(e,"]"),!0))return!1}else if(f(t)!==r.type)return console.error("".concat(l," ").concat(e,' type mismatched: "').concat(r.type,'" expected, "').concat(f(t),'" provided')),!1;if(r.restrictions&&r.restrictions.length)for(var n=r.restrictions.length,i=0;i<n;i++){var a=r.restrictions[i],o=a.restriction,u=a.message;if(!o(t,c))return console.error("".concat(l," ").concat(e," invalid value: ").concat(u)),!1}if(r.restriction&&!r.restriction(t,c))return console.error("".concat(l," ").concat(e," invalid value: ").concat(r.message)),!1;if(r.validValues&&-1===r.validValues.indexOf(t))return console.error("".concat(l," ").concat(e," invalid value: must be among ").concat(JSON.stringify(r.validValues),', "').concat(t,'" provided')),!1;if(r.children&&!p(t,r.children,"[Validate ".concat(e,"]")))return!1;return!0});return t||r.push.apply(r,n(Object.keys(s).map(function(e){var t=s[e];if("string"==typeof t&&(t={type:t}),t.mandatory){var r=t.mandatory;if("function"==typeof r&&(r=r(c)),r&&void 0===c[e])return console.error("".concat(l,' Missing mandatory key "').concat(e,'"')),!1}return!0}))),r.reduce(function(e,t){return e&&t},!0)}function c(e){return p(e,g,"[Validate format]")}t.exports={validate:function(e,t){var r=u(e),n=c(t);return r&&n},validateFormat:c,validateInput:u,validateLanguage:function(e){return p(e,o,"[Validate language]")}}},{"./unformatting":9}]},{},[7])(7)});
|
|
2
|
-
//# sourceMappingURL=numbro.min.js.map
|