vue-lazy-calc
Version:
A simple calculator with lazy evaluation featuer
2 lines • 6.32 kB
JavaScript
(function(t,r){"object"===typeof exports&&"object"===typeof module?module.exports=r(require("vue")):"function"===typeof define&&define.amd?define([],r):"object"===typeof exports?exports["vue-lazy-calc"]=r(require("vue")):t["vue-lazy-calc"]=r(t["Vue"])})("undefined"!==typeof self?self:this,function(t){return function(t){var r={};function n(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"===typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)n.d(e,o,function(r){return t[r]}.bind(null,o));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s="fb15")}({"8bbf":function(r,n){r.exports=t},fb15:function(t,r,n){"use strict";var e;(n.r(r),"undefined"!==typeof window)&&((e=window.document.currentScript)&&(e=e.src.match(/(.+\/)[^\/]+\.js(\?.*)?$/))&&(n.p=e[1]));var o=n("8bbf"),i=n.n(o);function u(t,r){var n="function"===typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,o,i=n.call(t),u=[];try{while((void 0===r||r-- >0)&&!(e=i.next()).done)u.push(e.value)}catch(a){o={error:a}}finally{try{e&&!e.done&&(n=i["return"])&&n.call(i)}finally{if(o)throw o.error}}return u}function a(){for(var t=[],r=0;r<arguments.length;r++)t=t.concat(u(arguments[r]));return t}var s=function(){function t(){return this.compose=function(t){return t.reduceRight(function(t,r){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return r(t.apply(void 0,a(n)))}},function(t){return t})},this.operators=[],this}return t.prototype.clone=function(r){var n=new t;return n.operators=r,n},t.prototype.isInvalid=function(t){return Number.isNaN(+t)||!Number.isFinite(+t)},t.prototype.createRound=function(t,r){var n=this;void 0===r&&(r=0);var e=Math[t];return function(t){if(n.isInvalid(t)||n.isInvalid(r))return NaN;if(r=null==r?0:r>=0?Math.min(r,292):Math.max(r,-292),r){var o=(t+"e").split("e"),i=e(o[0]+"e"+(+o[1]+r));return o=(i+"e").split("e"),+(o[0]+"e"+(+o[1]-r))}return e(t)}},t.prototype.add=function(t){var r=this,n=function(n){var e=t.value();return r.isInvalid(n)||r.isInvalid(e)?NaN:+n+ +e};return this.clone(a([n],this.operators))},t.prototype.subtract=function(t){var r=this,n=t.value(),e=function(t){return r.isInvalid(t)||r.isInvalid(n)?NaN:+t-+n};return this.clone(a([e],this.operators))},t.prototype.multiply=function(t){var r=this,n=t.value(),e=function(t){return r.isInvalid(t)||r.isInvalid(n)?NaN:+t*+n};return this.clone(a([e],this.operators))},t.prototype.divide=function(t){var r=this,n=t.value(),e=function(t){return r.isInvalid(t)||r.isInvalid(n)?NaN:+t/+n};return this.clone(a([e],this.operators))},t.prototype.round=function(t){void 0===t&&(t=0);var r=this.createRound("round",t);return this.clone(a([r],this.operators))},t.prototype.ceil=function(t){void 0===t&&(t=0);var r=this.createRound("ceil",t);return this.clone(a([r],this.operators))},t.prototype.floor=function(t){void 0===t&&(t=0);var r=this.createRound("floor",t);return this.clone(a([r],this.operators))},t.prototype.do=function(t){var r=function(r){return t(r)};return this.clone(a([r],this.operators))},t.prototype.default=function(t){var r=this,n=function(n){return r.isInvalid(n)?t:+n};return this.clone(a([n],this.operators))},t.prototype.value=function(){return this.compose(this.operators)(0)},t}(),c=s,l=function(){function t(t){return void 0===t&&(t=0),this.initValue=0,this.compose=function(t){return t.reduceRight(function(t,r){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return r(t.apply(void 0,a(n)))}},function(t){return t})},this.initValue=t,this.operators=[],this}return t.prototype.createRound=function(t,r){var n=this;void 0===r&&(r=0);var e=Math[t];return function(t){if(n.isInvalid(t)||n.isInvalid(r))return NaN;if(r=null==r?0:r>=0?Math.min(r,292):Math.max(r,-292),r){var o=(t+"e").split("e"),i=e(o[0]+"e"+(+o[1]+r));return o=(i+"e").split("e"),+(o[0]+"e"+(+o[1]-r))}return e(t)}},t.prototype.isInvalid=function(t){return Number.isNaN(+t)||!Number.isFinite(+t)},t.prototype.clone=function(r){var n=new t(this.initValue);return n.operators=r,n},t.prototype.add=function(t){var r=this,n=function(n){return r.isInvalid(n)||r.isInvalid(t)?NaN:+n+ +t};return this.clone(a([n],this.operators))},t.prototype.divide=function(t){var r=this,n=function(n){return r.isInvalid(n)||r.isInvalid(t)?NaN:+n/+t};return this.clone(a([n],this.operators))},t.prototype.subtract=function(t){var r=this,n=function(n){return r.isInvalid(n)||r.isInvalid(t)?NaN:+n-+t};return this.clone(a([n],this.operators))},t.prototype.multiply=function(t){var r=this,n=function(n){return r.isInvalid(n)||r.isInvalid(t)?NaN:+n*+t};return this.clone(a([n],this.operators))},t.prototype.do=function(t){var r=function(r){return t(r)};return this.clone(a([r],this.operators))},t.prototype.ceil=function(t){void 0===t&&(t=0);var r=this.createRound("ceil",t);return this.clone(a([r],this.operators))},t.prototype.floor=function(t){void 0===t&&(t=0);var r=this.createRound("floor",t);return this.clone(a([r],this.operators))},t.prototype.round=function(t){void 0===t&&(t=0);var r=this.createRound("round",t);return this.clone(a([r],this.operators))},t.prototype.default=function(t){var r=this,n=function(n){return r.isInvalid(n)?t:n};return this.clone(a([n],this.operators))},t.prototype.value=function(){return this.compose(this.operators)(this.initValue)},t}(),f=function(){function t(){}return t.lazy=function(t){return void 0===t&&(t=0),new l(t)},t.stream=function(t){return t?(new c).add(t):new c},t}(),p={install:function(t,r){var n="$lzCalc";t.prototype[n]=f,Object.defineProperty(i.a,""+n,{get:function(){return f}})}},d=p;n.d(r,"LazyBase",function(){return f});r["default"]=d}})});
//# sourceMappingURL=vue-lazy-calc.umd.min.js.map