UNPKG

precise-calculator

Version:
2 lines 34.8 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("precise-calculator",[],e):"object"==typeof exports?exports["precise-calculator"]=e():t["precise-calculator"]=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=3)}([function(t,e,r){(function(t){var n=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n<e.length;n++)r[e[n]]=Object.getOwnPropertyDescriptor(t,e[n]);return r},i=/%[sdj%]/g;e.format=function(t){if(!d(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(s(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,o=n.length,u=String(t).replace(i,(function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}})),c=n[r];r<o;c=n[++r])y(c)||!m(c)?u+=" "+c:u+=" "+s(c);return u},e.deprecate=function(r,n){if(void 0!==t&&!0===t.noDeprecation)return r;if(void 0===t)return function(){return e.deprecate(r,n).apply(this,arguments)};var i=!1;return function(){if(!i){if(t.throwDeprecation)throw new Error(n);t.traceDeprecation?console.trace(n):console.error(n),i=!0}return r.apply(this,arguments)}};var o,u={};function s(t,r){var n={seen:[],stylize:a};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),v(r)?n.showHidden=r:r&&e._extend(n,r),b(n.showHidden)&&(n.showHidden=!1),b(n.depth)&&(n.depth=2),b(n.colors)&&(n.colors=!1),b(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),l(n,t,n.depth)}function c(t,e){var r=s.styles[e];return r?"["+s.colors[r][0]+"m"+t+"["+s.colors[r][1]+"m":t}function a(t,e){return t}function l(t,r,n){if(t.customInspect&&r&&x(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return d(i)||(i=l(t,i,n)),i}var o=function(t,e){if(b(e))return t.stylize("undefined","undefined");if(d(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(_(e))return t.stylize(""+e,"number");if(v(e))return t.stylize(""+e,"boolean");if(y(e))return t.stylize("null","null")}(t,r);if(o)return o;var u=Object.keys(r),s=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(r)),O(r)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return f(r);if(0===u.length){if(x(r)){var c=r.name?": "+r.name:"";return t.stylize("[Function"+c+"]","special")}if(g(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(w(r))return t.stylize(Date.prototype.toString.call(r),"date");if(O(r))return f(r)}var a,m="",S=!1,k=["{","}"];(h(r)&&(S=!0,k=["[","]"]),x(r))&&(m=" [Function"+(r.name?": "+r.name:"")+"]");return g(r)&&(m=" "+RegExp.prototype.toString.call(r)),w(r)&&(m=" "+Date.prototype.toUTCString.call(r)),O(r)&&(m=" "+f(r)),0!==u.length||S&&0!=r.length?n<0?g(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),a=S?function(t,e,r,n,i){for(var o=[],u=0,s=e.length;u<s;++u)j(e,String(u))?o.push(p(t,e,r,n,String(u),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(p(t,e,r,n,i,!0))})),o}(t,r,n,s,u):u.map((function(e){return p(t,r,n,s,e,S)})),t.seen.pop(),function(t,e,r){if(t.reduce((function(t,e){return e.indexOf("\n")>=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(a,m,k)):k[0]+m+k[1]}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function p(t,e,r,n,i,o){var u,s,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(s=t.stylize("[Setter]","special")),j(n,i)||(u="["+i+"]"),s||(t.seen.indexOf(c.value)<0?(s=y(r)?l(t,c.value,null):l(t,c.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+s.split("\n").map((function(t){return" "+t})).join("\n")):s=t.stylize("[Circular]","special")),b(u)){if(o&&i.match(/^\d+$/))return s;(u=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+s}function h(t){return Array.isArray(t)}function v(t){return"boolean"==typeof t}function y(t){return null===t}function _(t){return"number"==typeof t}function d(t){return"string"==typeof t}function b(t){return void 0===t}function g(t){return m(t)&&"[object RegExp]"===S(t)}function m(t){return"object"==typeof t&&null!==t}function w(t){return m(t)&&"[object Date]"===S(t)}function O(t){return m(t)&&("[object Error]"===S(t)||t instanceof Error)}function x(t){return"function"==typeof t}function S(t){return Object.prototype.toString.call(t)}function k(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(r){if(b(o)&&(o=t.env.NODE_DEBUG||""),r=r.toUpperCase(),!u[r])if(new RegExp("\\b"+r+"\\b","i").test(o)){var n=t.pid;u[r]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",r,n,t)}}else u[r]=function(){};return u[r]},e.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=h,e.isBoolean=v,e.isNull=y,e.isNullOrUndefined=function(t){return null==t},e.isNumber=_,e.isString=d,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=b,e.isRegExp=g,e.isObject=m,e.isDate=w,e.isError=O,e.isFunction=x,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(6);var $=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function N(){var t=new Date,e=[k(t.getHours()),k(t.getMinutes()),k(t.getSeconds())].join(":");return[t.getDate(),$[t.getMonth()],e].join(" ")}function j(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",N(),e.format.apply(e,arguments))},e.inherits=r(7),e._extend=function(t,e){if(!e||!m(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var R="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function E(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(R&&t[R]){var e;if("function"!=typeof(e=t[R]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,R,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise((function(t,n){e=t,r=n})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(t,n){t?r(t):e(n)}));try{t.apply(this,i)}catch(t){r(t)}return n}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),R&&Object.defineProperty(e,R,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,n(t))},e.promisify.custom=R,e.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function r(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,u=function(){return i.apply(o,arguments)};e.apply(this,r).then((function(e){t.nextTick(u,null,e)}),(function(e){t.nextTick(E,e,u)}))}return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.defineProperties(r,n(e)),r}}).call(this,r(5))},function(t,e,r){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e,r){return(i="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,r){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(r):i.value}})(t,e,r||t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=c(t);if(e){var i=c(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return s(this,r)}}function s(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function f(t,e,r){return e&&l(t.prototype,e),r&&l(t,r),t}var p=r(0).inspect,h=r(2),v=h.upRound,y=h.evenRound,_=h.format,d=Math.pow,b=Math.ceil,g=Math.floor,m=Math.round,w=Math.abs,O=function(){function t(e){if(a(this,t),e)if(void 0===e._vi){var r=e.toString(),n=r.lastIndexOf("e");if(n>0){this._p=0-Number(r.slice(n+1));var i=r.indexOf(".");i<0?this._vi=Number(r.slice(0,n)):(this._p+=n-i-1,this._p<0?this._vi=Number(r)*d(10,this._p):this._vi=Number(r.slice(0,i)+r.slice(i+1,n))),this._v=null}else{var o=r.indexOf(".");o<0?(this._vi=this._v=Number(e),this._p=0):(this._vi=Number(r.substr(0,o)+r.substr(o+1)),this._p=r.length-o-1,this._v=null)}}else this._vi=e._vi,this._p=e._p,this._v=e._v;else this._vi=0,this._p=0,this._v=null}return f(t,[{key:"add",value:function(t){if(t){var e,r=t.toString(),n=r.indexOf("e"),i=0;if(n>0){i=-Number(r.slice(n+1));var o=r.indexOf(".");o<0?e=Number(r.slice(0,n)):(e=Number(r.slice(0,o)+r.slice(o+1,n)),i+=n-o-1)}else{var u=r.indexOf(".");u<0?e=Number(t):(e=Number(r.substr(0,u)+r.substr(u+1)),i=r.length-u-1)}i>this._p?(this._vi=this._vi*d(10,i-this._p)+e,this._p=i):this._vi=this._vi+e*d(10,this._p-i),this._v=null}return this}},{key:"$add",value:function(t){return t._p>this._p?(this._vi=this._vi*d(10,t._p-this._p)+t._vi,this._p=t._p):this._vi=this._vi+t._vi*d(10,this._p-t._p),this._v=null,this}},{key:"sub",value:function(t){if(t){var e,r=t.toString(),n=r.indexOf("."),i=0;n<0?e=Number(t):(e=Number(r.substr(0,n)+r.substr(n+1)),i=r.length-n-1),i>this._p?(this._vi=this._vi*d(10,i-this._p)-e,this._p=i):this._vi=this._vi-e*d(10,this._p-i),this._v=null}return this}},{key:"$sub",value:function(t){return t._p>this._p?(this._vi=this._vi*d(10,t._p-this._p)-t._vi,this._p=t._p):this._vi=this._vi-t._vi*d(10,this._p-t._p),this._v=null,this}},{key:"mul",value:function(t){if(t){var e,r=t.toString(),n=r.indexOf("."),i=0;n<0?e=Number(t):(e=Number(r.substr(0,n)+r.substr(n+1)),i=r.length-n-1),this._vi=this._vi*e,this._p=this._p+i}else this._vi=0,this._p=0;return this._v=null,this}},{key:"$mul",value:function(t){return this._vi=this._vi*t._vi,this._p=this._p+t._p,this._v=null,this}},{key:"div",value:function(t){if(t){var e,r=t.toString(),n=r.indexOf("e"),i=0;if(n>0){i=-Number(r.slice(n+1));var o=r.indexOf(".");o<0?e=Number(r.slice(0,n)):(e=Number(r.slice(0,o)+r.slice(o+1,n)),i+=n-o-1)}else{var u=r.indexOf(".");u<0?e=Number(t):(e=Number(r.substr(0,u)+r.substr(u+1)),i=r.length-u-1)}if(this._vi=this._vi/e,(n=(r=this._vi.toString()).indexOf("e"))<0){var s=r.indexOf(".");s>0?(this._vi=Number(r.substr(0,s)+r.substr(s+1)),this._p=this._p-i+r.length-s-1):this._p-=i}else{var c=Number(r.substr(n+1)),a=r.indexOf(".");this._vi=Number(r.substr(0,a)+r.substring(a+1,n)),this._p=this._p-i+n-a-1-c}}else this._vi=1/0,this._p=0;return this._v=null,this}},{key:"$div",value:function(t){this._vi=this._vi/t._vi;var e=this._vi.toString(),r=e.indexOf("e");if(r<0){var n=e.indexOf(".");n<0?this._p=this._p-t._p:(this._vi=Number(e.substr(0,n)+e.substr(n+1)),this._p=this._p-t._p+e.length-n-1)}else{var i=Number(e.substr(r+1)),o=e.indexOf(".");this._vi=Number(e.substr(0,o)+e.substring(o+1,r)),this._p=this._p-t._p+r-o-1-i}return this._v=null,this}},{key:"max",value:function(t){var e,r=t.toString(),n=r.indexOf("."),i=0;(n<0?e=Number(t):(e=Number(r.substr(0,n)+r.substr(n+1)),i=r.length-n-1),this._p>i)?e*d(10,this._p-i)>this._vi&&(this._p=i,this._vi=e,this._v=null):e>this._vi*d(10,i-this._p)&&(this._p=i,this._vi=e,this._v=null);return this}},{key:"$max",value:function(t){if(this._p>t._p){if(t._vi*d(10,this._p-t._p)>this._vi)return t}else{var e=this._vi*d(10,t._p-this._p);if(t._vi>e)return t}return this}},{key:"min",value:function(t){var e,r=t.toString(),n=r.indexOf("."),i=0;(n<0?e=Number(t):(e=Number(r.substr(0,n)+r.substr(n+1)),i=r.length-n-1),this._p>i)?e*d(10,this._p-i)<this._vi&&(this._p=i,this._vi=e,this._v=null):e<this._vi*d(10,i-this._p)&&(this._p=i,this._vi=e,this._v=null);return this}},{key:"$min",value:function(t){if(this._p>t._p){if(t._vi*d(10,this._p-t._p)<this._vi)return t}else{var e=this._vi*d(10,t._p-this._p);if(t._vi<e)return t}return this}},{key:"v",value:function(){return null===this._v&&(0===this._p?this._v=this._vi:this._v=Number(this.vs())),this._v}},{key:"value",value:function(){return this.v()}},{key:"vs",value:function(){if(this._p>0){if(this._vi<0){var t=this._vi.toString(),e=this._p-t.length+1;if(e<0)return e=1-e,t.substring(0,e)+"."+t.substring(e);for(t=t.slice(1);e-- >0;)t="0"+t;return"-0."+t}var r=this._vi.toString(),n=this._p-r.length;if(n<0)return n=0-n,r.substring(0,n)+"."+r.substring(n);for(;n-- >0;)r="0"+r;return"0."+r}if(this._p<0){for(var i=this._vi.toString(),o=0-this._p;o-- >0;)i+="0";return i}return this._vi.toString()}},{key:"ve",value:function(){if(0===this._vi)return this._vi.toString();for(var t=this._vi.toString(),e=t.length-1,r=(e-this._p).toString();e>0&&"0"===t[e];)e--;e++;var n="-"===t[0]?2:1;return e>n?"-"===r[0]?t.substr(0,n)+"."+t.substr(n)+"e"+r:t.substr(0,n)+"."+t.substr(n)+"e+"+r:"-"===r[0]?t.substr(0,n)+"e"+r:t.substr(0,n)+"e+"+r}},{key:"round",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return v(this._vi,this._p,t)}},{key:"rv",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.round(t)}},{key:"upRound",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return v(this._vi,this._p,t)}},{key:"uv",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.upRound(t)}},{key:"evenRound",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return y(this._vi,this._p,t)}},{key:"ev",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.evenRound(t)}},{key:"r",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.ru(t)}},{key:"ru",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._p>t){var e=this._vi.toString(),r=e.length-this._p+t;r<0?(this._vi=0,this._p=0):(this._vi=Number(e.substr(0,r))+m(Number("0."+e.substr(r))),this._p=t),this._v=null}return this}},{key:"re",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._p>t){var e=this._vi.toString(),r=e.length-this._p+t;r<0?(this._vi=0,this._p=0):(this._vi=y(Number(e.substr(0,r)+"."+e.substr(r)),0,0),this._p=t),this._v=null}return this}},{key:"rc",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._p>t){var e=this._vi.toString(),r=e.length-this._p+t;r<0?(this._vi=0,this._p=0):(this._vi=Number(e.substr(0,r))+b(Number("0."+e.substr(r))),this._p=t),this._v=null}return this}},{key:"rf",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._p>t){var e=this._vi.toString(),r=e.length-this._p+t;r<0?(this._vi=0,this._p=0):(this._vi=Number(e.substr(0,r)),this._p=t),this._v=null}return this}},{key:"ceil",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._p>t){var e=d(10,this._p-t);return b(this._vi/e)/d(10,t)}return this._p<0?this._vi*d(10,-this._p):this._vi/d(10,this._p)}},{key:"cv",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.ceil(t)}},{key:"floor",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._p>t){var e=d(10,this._p-t);return g(this._vi/e)/d(10,t)}return this._vi/d(10,this._p)}},{key:"fv",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.floor(t)}},{key:"fmt",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#,##0.00",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return this.format(t,e,r)}},{key:"format",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#,##0.00",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return _(this.v(),t,e,r)}},{key:"thousands",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2;return _(this.rv(t),"#,##0.","","",",",t)}},{key:"currency",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t=t||"",e&&this._vi>=0&&(t+="+"),_(this.rv(2),"#,##0.00",t,"")}},{key:"signed",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return t=t||"",this._vi>=0&&(t+="+"),_(this.rv(e),"0.00",t,"","",e)}},{key:"unsigned",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;t=t||"";var r=this.rv(e);return this._vi<0&&(r=r.toString().slice(1)),_(r,"0.",t,"","",e)}},{key:"debug",value:function(){return this._print(this._vi,this._p),this}},{key:"valueOf",value:function(){return this.v()}},{key:"toString",value:function(){return this.vs()}},{key:"toJSON",value:function(){return this.v()}},{key:p.custom,value:function(){return this.v()}},{key:"isZero",value:function(){return 0===this._vi}},{key:"positive",value:function(){return this._vi>0}},{key:"negative",value:function(){return this._vi<0}},{key:"abs",value:function(){return this._vi=w(this._vi),this._v=null,this}}]),t}(),x=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}(r,t);var e=u(r);function r(t){var n;return a(this,r),n=e.call(this,t),t&&t._vi||n.check(t),n}return f(r,[{key:"check",value:function(t){if(isNaN(t))throw new Error("Invalid number[".concat(t,"]"))}},{key:"$check",value:function(t){if(void 0===t._vi)throw new Error("Invalid calculator[".concat(t,"]"))}},{key:"add",value:function(t){return this.check(t),i(c(r.prototype),"add",this).call(this,t)}},{key:"$add",value:function(t){return this.$check(t),i(c(r.prototype),"$add",this).call(this,t)}},{key:"sub",value:function(t){return this.check(t),i(c(r.prototype),"sub",this).call(this,t)}},{key:"$sub",value:function(t){return this.$check(t),i(c(r.prototype),"$sub",this).call(this,t)}},{key:"mul",value:function(t){return this.check(t),i(c(r.prototype),"mul",this).call(this,t)}},{key:"$mul",value:function(t){return this.$check(t),i(c(r.prototype),"$mul",this).call(this,t)}},{key:"div",value:function(t){return this.check(t),i(c(r.prototype),"div",this).call(this,t)}},{key:"$div",value:function(t){return this.$check(t),i(c(r.prototype),"$div",this).call(this,t)}}]),r}(O);function S(t){return new S.Calculator(t)}O.prototype._print=console.error.bind(console,"[debug]"),S.setDebug=function(t){O.prototype._print=t},S.resetDebug=function(){O.prototype._print=console.error.bind(console,"[debug]")},S.Calculator=O,S.StrictCalculator=x,S.$=S,S.strict=function(t){return new x(t)},S.withStrict=function(){return S.Calculator=x,this},S.withoutStrict=function(){return S.Calculator=O,this},t.exports=S},function(t,e){var r=Math.pow,n=Math.floor,i=Math.round;t.exports={upRound:function(t,e,n){return n?i(t*r(10,n-e))/r(10,n):i(t/r(10,e))},format:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#,##0.00",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:",",o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:void 0,u=(t=t.toString()).indexOf("."),s=e.indexOf("."),c=o>=0?o:e.length-s-1;if(s<0)s=e.length,u<0?u=t.length:t=t.substr(0,u);else if(0===c)u<0&&(u=t.length);else if(u<0)for(u=t.length,t+=".";c-- >0;)t+="0";else if((c-=t.length-u-1)<0)t=t.slice(0,c);else for(;c-- >0;)t+="0";if(s>0&&e.indexOf("#")>-1){if(s=s-e.indexOf(i)-1,isNaN(t[0])){var a=(u-1)%s;if(a>0){for(var l=t.substr(0,++a);a<u;a+=s)l=l+i+t.substr(a,s);return r+l+t.substr(u)+n}a=s+1;for(var f=t.substr(0,a);a<u;a+=s)f=f+i+t.substr(a,s);return r+f+t.substr(u)+n}var p=u%s;if(p>0){for(var h=t.substr(0,p);p<u;p+=s)h=h+i+t.substr(p,s);return r+h+t.substr(u)+n}for(var v=t.substr(0,p+=s);p<u;p+=s)v=v+i+t.substr(p,s);return r+v+t.substr(u)+n}return r+t+n},evenRound:function(t,e,o){if(e>o){var u=r(10,o),s=t/r(10,e-o),c=n(s),a=s-c;return(a>.5-1e-8&&a<.5+1e-8?c%2==0?c:c+1:i(s))/u}if(o){var l=r(10,o),f=t*r(10,o-e),p=n(f),h=f-p;return(h>.5-1e-8&&h<.5+1e-8?p%2==0?p:p+1:i(f))/l}var v=t/r(10,e),y=n(v),_=v-y;return _>.5-1e-8&&_<.5+1e-8?y%2==0?y:y+1:i(v)}}},function(t,e,r){t.exports=r(4)},function(t,e,r){function n(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t)||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 i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var o=r(0).inspect,u=r(1),s=r(8),c=s.compile,a=s.build,l=s.$compile,f=r(2),p=f.format,h=f.evenRound,v=f.upRound,y=Math.pow,_=Math.ceil,d=Math.floor,b=Math.abs;u.format=p,u.evenRound=function(t,e){var r=t.toString(),n=r.indexOf(".");if(n<0){var i=Number(t);return h(i,0,e)}var o=Number(r.substr(0,n)+r.substr(n+1));return h(o,r.length-n-1,e)},u.upRound=function(t,e){var r=t.toString(),n=r.indexOf(".");if(n<0){var i=Number(t);return v(i,0,e)}var o=Number(r.substr(0,n)+r.substr(n+1));return v(o,r.length-n-1,e)},u.ceil=function(t,e){var r=t.toString(),n=r.indexOf(".");if(n<0)return Number(t);var i=r.length-n-1,o=Number(r.substr(0,n)+r.substr(n+1));if(i>e){var u=y(10,i-e);return _(o/u)/y(10,e)}return o/y(10,i)},u.floor=function(t,e){var r=t.toString(),n=r.indexOf(".");if(n<0)return Number(t);var i=r.length-n-1,o=Number(r.substr(0,n)+r.substr(n+1));if(i>e){var u=y(10,i-e);return d(o/u)/y(10,e)}return o/y(10,i)},u.max=function(t){void 0===t._vi&&(t=u(t));for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];for(var i=0,o=r;i<o.length;i++){var s=o[i];t=void 0===s._vi?t.max(s):t.$max(s)}return t.v()},u.$max=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];for(var i=0,o=r;i<o.length;i++){var u=o[i];t=t.$max(u)}return t},u.min=function(t){void 0===t._vi&&(t=u(t));for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];for(var i=0,o=r;i<o.length;i++){var s=o[i];t=void 0===s._vi?t.min(s):t.$min(s)}return t.v()},u.$min=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];for(var i=0,o=r;i<o.length;i++){var u=o[i];t=t.$min(u)}return t},u.pow=function(t,e){return y(t,e)},u.$pow=function(t,e){return void 0!==t._vi&&(t=t.v()),void 0!==e._vi&&(e=e.v()),u(y(t,e))},u.abs=function(t){return b(t)},u.$abs=function(t){return void 0===t._vi?u(b(t)):(t._vi=b(t._vi),t._v=null,t)},u.round=u.upRound,u.ROUND_HALF_UP=1,u.ROUND_HALF_EVEN=2,u.ROUND_HALF_CEIL=3,u.ROUND_HALF_FLOOR=4,u.setup=function(t){switch(t.roundRode){case 1:u.round=u.upRound,u.Calculator.prototype.r=u.Calculator.prototype.ru,u.Calculator.prototype.round=u.Calculator.prototype.upRound;break;case 2:u.round=u.evenRound,u.Calculator.prototype.r=u.Calculator.prototype.re,u.Calculator.prototype.round=u.Calculator.prototype.evenRound;break;case 3:u.round=u.ceil,u.Calculator.prototype.r=u.Calculator.prototype.rc,u.Calculator.prototype.round=u.Calculator.prototype.ceil;break;case 4:u.round=u.floor,u.Calculator.prototype.r=u.Calculator.prototype.rf,u.Calculator.prototype.round=u.Calculator.prototype.floor}};var g={};function m(t,e){var r=g[e];if(!r){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];r=g[e]=t.apply(void 0,[e].concat(i))}return r}var w={};function O(t,e){var r=w[e];if(!r){var i=(e.replace(/\{[^}]*\}/g,"").match(/(?:^|[^.\w])([_a-zA-Z]\w*)/g)||[]).reduce((function(t,e){return e=e.replace(/^.*?(\w+).*$/,"$1"),t.indexOf(e)<0&&t.push(e),t}),[]),u=t.apply(void 0,[e].concat(n(i)));(r=w[e]=function(t,e){return this.apply(void 0,n(t.map((function(t){return e[t]}))))}.bind(u,i)).exp=u.exp,r.args=i.join(","),r.toString=function(){return"({".concat(this.args,"}) => ").concat(this.exp)},r[o.custom]=function(){return"'".concat(this.toString(),"'")}}return r}u.build=a,u.compile=c,u.$compile=l,u.ccompile=m.bind(u,c),u.cc=u.ccompile,u.$ccompile=m.bind(u,l),u.$cc=u.$ccompile,u.ocompile=O.bind(u,c),u.oc=u.ocompile,u.$ocompile=O.bind(u,l),u.$oc=u.$ocompile,u.eval=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];var o=r.slice(0,r.length/2),u=r.slice(r.length/2);return c.apply(void 0,[t].concat(n(o))).apply(void 0,n(u))},t.exports=u},function(t,e){var r,n,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function s(t){if(r===setTimeout)return setTimeout(t,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(t){r=o}try{n="function"==typeof clearTimeout?clearTimeout:u}catch(t){n=u}}();var c,a=[],l=!1,f=-1;function p(){l&&c&&(l=!1,c.length?a=c.concat(a):f=-1,a.length&&h())}function h(){if(!l){var t=s(p);l=!0;for(var e=a.length;e;){for(c=a,a=[];++f<e;)c&&c[f].run();f=-1,e=a.length}c=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===u||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function v(t,e){this.fun=t,this.array=e}function y(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];a.push(new v(t,e)),1!==a.length||l||s(h)},v.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){function n(t,e,r){return(n=i()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&o(i,r.prototype),i}).apply(null,arguments)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var u=r(0).inspect,s=r(1),c=Math.pow,a="__G__"+Date.now(),l=function(){};function f(t){var e=0;do{e=0,t=t.replace(/([^*\/\s]+)\s*(\*|\/)\s*([^*\/\s]+)/,(function(t,r,n,i){l("[evalMD] %s %s %s",r,n,i),e=1;var o=/^\$(\.\$|[^.])/.test(i)||i.startsWith(a)?"*"===n?"$mul":"$div":"*"===n?"mul":"div";return"$"===r[0]?r+".".concat(o,"(").concat(i,")"):"$(".concat(r,").").concat(o,"(").concat(i,")")}))}while(e);return t}function p(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=[],n=a+"__as__"+Date.now()+"__",i=new RegExp(n+"(\\d+)","g"),o=/((?:(?!\s[+-]\s)[\s\S])+)\s+([+-])\s+((?:(?!\s[+-]\s)[\s\S])+)/,u=0,s=0;do{s=0,t=t.replace(o,(function(t,e,o,c){l("[evalAS] %s %s %s",e,o,c),s=1,u+=1;var f="+"===o?"add":"sub",p=e.trim().replace(i,(function(t,e){return r[e]}));return"$"===p[0]?p+=".":p="$(".concat(p,")."),/^\$(\.\$|[^.])/.test(c)||c.startsWith(a)?p+="$".concat(f,"(").concat(c.trim(),")"):p+="".concat(f,"(").concat(c.trim(),")"),r.push(p),n+(r.length-1)}))}while(s);return t=t.replace(i,(function(t,e){return r[e]})),u>0||"$"===t[0]&&!e?e?"$.$".concat(e,"(").concat(t,")"):t:e?t.indexOf("$")<0?"$.".concat(e,"(").concat(t,")"):"$.$".concat(e,"(").concat(t,")"):"$(".concat(t,")")}function h(t){var e=t.split(/\s*,\s*/);return e.length>1?e.map((function(t){return l("[evalArgs] %s",t),p(f(t))})).join(","):t}var v={round:"R",r:"R",upRound:"U",ru:"U",evenRound:"E",re:"E",ceil:"C",rc:"C",floor:"F",rf:"F"};function y(t){if(/([\)\d]+([\+\-\*\/])\s*[\(\d]+)/.test(t)||/([\)\d]+\s*([\+\-\*\/])[\(\d]+)/.test(t))throw new Error("运算符[".concat(RegExp.$2,"]前后必须保留空格:[").concat(RegExp.$1,"]"));t=t.replace(/^([\$\¥]?)(.*)(%?)$/,"($2){$1.$3}").replace(/\)\.(\w+)\(\s*(\d*)\s*\)/gm,(function(t,e,r){var n=v[e];if(!n)throw new Error("Unsupported format alias: "+e);return"){.".concat(r).concat(n,"}")}));var e=0,r=[],n=a+"__"+Date.now()+"__",i=new RegExp(n+"(\\d+)","g"),o=/(\w*)\(([^()]+)\)(?:\{(?:(\w+\([^)]*\));?)?([\$\¥]?)([#,\d]*)(\.?)(\d*)([a-zA-Z]*)([\%]?)\})?/g;do{e=0,t=t.replace(o,(function(t,o,u,s,a,v,y,_,d,b){e=1,l("[build] %s(%s)",o,u);var g=p(f(h(u).replace(i,(function(t,e){return r[e]}))),o);if(s&&(g+="."+s),d){var m={P:"mul(100)",R:"r",U:"ru",E:"re",C:"rc",F:"rf",S:"vs",s:"vs",e:"ve"}[d[0]];if(!m)throw new Error("无效的舍入方法["+d+"]");if("P"===d[0]&&(b=b||"%"),/^0+$/.test(_)&&(_=_.length),v||a||b){if(/\(.*\)/.test(m)?g+="."+m:"vs"!==m&&"ve"!==m&&(g+="."+m+"(".concat(_,")")),_>0&&(_=c(2,_).toString(2).substr(1)),v>0){var w=Number(v)-1;for(v=w>1?"0":"#";w-- >0;)v="#"+v;v.length>1&&(v="#,"+v)}g+=".format('".concat(v).concat(y).concat(_,"'"),b?g+=", '".concat(a||"","', '").concat(b,"'"):a&&(g+=", '".concat(a,"'")),g+=")"}else if(g+="vs"!==m&&"ve"!=m?"."+m+"(".concat(_,")"):_?".r(".concat(_,").").concat(m,"()"):".".concat(m,"()"),d.length>1&&"vs"!==m&&"ve"!==m){if(!/^\w[sSe]/.test(d))throw new Error("无效的舍入方法["+d[1]+"]");g+=".vs()"}}else if(v||_||a||b){if(_>0&&(_=c(2,Number(_)).toString(2).substr(1)),/^\d+$/.test(v)&&v>0){var O=Number(v)-1;for(v=O>1?"0":"#";O-- >0;)v="#"+v;v.length>1&&(v="#,"+v)}g+=".format('".concat(v).concat(y).concat(_,"'"),b?g+=", '".concat(a||"","', '").concat(b,"'"):a&&(g+=", '".concat(a,"'")),g+=")"}return r.push(g),n+(r.length-1)}))}while(e);return p(f(t.replace(i,(function(t,e){return r[e]}))))}function _(t,e){var r=y(e);if(/\.(f|format|v|vs|ve)\([^)]*\)$/.test(r)){if(!t)throw new Error("The expression is not allowed to contain the final result: ".concat(r))}else t&&(r+=".v()");for(var i=arguments.length,o=new Array(i>2?i-2:0),c=2;c<i;c++)o[c-2]=arguments[c];try{var a=n(Function,["$"].concat(o,["return "+r])).bind(s,s);return a.toString=function(){return"(".concat(this.args,") => ").concat(this.exp)},a[u.custom]=function(){return"'".concat(this.toString(),"'")},a.args=o.join(","),a.exp=r,l("[compile] %s -> %s",e,r),a}catch(t){throw t.exp=r,t.args=o,t.message+=": (".concat(o.join(","),") => ").concat(r),t}}t.exports={resetDebug:function(t){l=["true","on",!0,1].indexOf(t)<0?function(){}:console.error.bind(console)},evalAS:p,evalMD:f,build:y,$compile:function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return _.apply(void 0,[!1,t].concat(r))},compile:function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return _.apply(void 0,[!0,t].concat(r))}}}])})); //# sourceMappingURL=calculator.min.js.map