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

@oat-sa/expr-eval

Package Overview
Dependencies
Maintainers
19
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oat-sa/expr-eval - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

6

dist/bundle.js

@@ -215,3 +215,3 @@ (function (global, factory) {

}
return nstack[0];
return nstack[0] === -0 ? 0: nstack[0];
}

@@ -331,4 +331,4 @@

var item = tokens[i];
if (item.type === IVAR && !contains(symbols, item.value)) {
if (!withMembers) {
if (item.type === IVAR) {
if (!withMembers && !contains(symbols, item.value)) {
symbols.push(item.value);

@@ -335,0 +335,0 @@ } else if (prevVar !== null) {

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.exprEval=e()}(this,function(){"use strict";var t="INUMBER",e="IOP1",s="IOP2",r="IOP3",n="IVAR",i="IFUNCOP",o="IFUNCALL",p="IEXPR",a="IMEMBER";function h(t,e){this.type=t,this.value=void 0!==e&&null!==e?e:0}function u(t){return new h(e,t)}function c(t){return new h(s,t)}function l(t){return new h(r,t)}function f(i,h){for(var u,c,l,x,y=[],w=0;w<i.length;w++){var d=i[w],M=d.type;if(M===t)"number"==typeof d.value&&d.value<0?y.push("("+d.value+")"):y.push(v(d.value));else if(M===s)c=y.pop(),u=y.pop(),x=d.value,h?"^"===x?y.push("Math.pow("+u+", "+c+")"):"and"===x?y.push("(!!"+u+" && !!"+c+")"):"or"===x?y.push("(!!"+u+" || !!"+c+")"):"||"===x?y.push("(String("+u+") + String("+c+"))"):"=="===x?y.push("("+u+" === "+c+")"):"!="===x?y.push("("+u+" !== "+c+")"):y.push("("+u+" "+x+" "+c+")"):y.push("("+u+" "+x+" "+c+")");else if(M===r){if(l=y.pop(),c=y.pop(),u=y.pop(),"?"!==(x=d.value))throw new Error("invalid Expression");y.push("("+u+" ? "+c+" : "+l+")")}else if(M===n)y.push(d.value);else if(M===e)u=y.pop(),"-"===(x=d.value)||"+"===x?y.push("("+x+u+")"):h?"not"===x?y.push("(!"+u+")"):"!"===x?y.push("fac("+u+")"):y.push(x+"("+u+")"):"!"===x?y.push("("+u+"!)"):y.push("("+x+" "+u+")");else if(M===o){for(var g=d.value,E=[];g-- >0;)E.unshift(y.pop());x=y.pop(),y.push(x+"("+E.join(", ")+")")}else if(M===a)u=y.pop(),y.push(u+"."+d.value);else{if(M!==p)throw new Error("invalid Expression");y.push("("+f(d.value,h)+")")}}if(y.length>1)throw new Error("invalid Expression (parity)");return String(y[0])}function v(t){return"string"==typeof t?JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"):t}function x(t,e){for(var s=0;s<t.length;s++)if(t[s]===e)return!0;return!1}function y(t,e,s){for(var r=!!(s=s||{}).withMembers,i=null,o=0;o<t.length;o++){var h=t[o];h.type!==n||x(e,h.value)?h.type===a&&r&&null!==i?i+="."+h.value:h.type===p?y(h.value,e,s):null!==i&&(x(e,i)||e.push(i),i=null):r?null!==i?(x(e,i)||e.push(i),i=h.value):i=h.value:e.push(h.value)}null===i||x(e,i)||e.push(i)}function w(t,e){this.tokens=t,this.parser=e,this.unaryOps=e.unaryOps,this.binaryOps=e.binaryOps,this.ternaryOps=e.ternaryOps,this.functions=e.functions}h.prototype.toString=function(){switch(this.type){case t:case e:case s:case r:case n:case i:return this.value;case o:return"CALL "+this.value;case a:return"."+this.value;default:return"Invalid Instruction"}},w.prototype.simplify=function(i){return i=i||{},new w(function i(o,u,c,l,f){for(var v,x,y,w,d=[],M=[],g=0;g<o.length;g++){var E=o[g],k=E.type;if(k===t)d.push(E);else if(k===n&&f.hasOwnProperty(E.value))E=new h(t,f[E.value]),d.push(E);else if(k===s&&d.length>1)x=d.pop(),v=d.pop(),w=c[E.value],E=new h(t,w(v.value,x.value)),d.push(E);else if(k===r&&d.length>2)y=d.pop(),x=d.pop(),v=d.pop(),"?"===E.value?d.push(v.value?x.value:y.value):(w=l[E.value],E=new h(t,w(v.value,x.value,y.value)),d.push(E));else if(k===e&&d.length>0)v=d.pop(),w=u[E.value],E=new h(t,w(v.value)),d.push(E);else if(k===p){for(;d.length>0;)M.push(d.shift());M.push(new h(p,i(E.value,u,c,l,f)))}else if(k===a&&d.length>0)v=d.pop(),d.push(new h(t,v.value[E.value]));else{for(;d.length>0;)M.push(d.shift());M.push(E)}}for(;d.length>0;)M.push(d.shift());return M}(this.tokens,this.unaryOps,this.binaryOps,this.ternaryOps,i),this.parser)},w.prototype.substitute=function(t,i){return i instanceof w||(i=this.parser.parse(String(i))),new w(function t(i,o,a){for(var f=[],v=0;v<i.length;v++){var x=i[v],y=x.type;if(y===n&&x.value===o)for(var w=0;w<a.tokens.length;w++){var d,M=a.tokens[w];d=M.type===e?u(M.value):M.type===s?c(M.value):M.type===r?l(M.value):new h(M.type,M.value),f.push(d)}else y===p?f.push(new h(p,t(x.value,o,a))):f.push(x)}return f}(this.tokens,t,i),this.parser)},w.prototype.evaluate=function(h){return h=h||{},function h(u,c,l){for(var f,v,x,y,w=[],d=0;d<u.length;d++){var M=u[d],g=M.type;if(g===t)w.push(M.value);else if(g===s)v=w.pop(),f=w.pop(),"and"===M.value?w.push(!!f&&!!h(v,c,l)):"or"===M.value?w.push(!!f||!!h(v,c,l)):(y=c.binaryOps[M.value],w.push(y(f,v)));else if(g===r)x=w.pop(),v=w.pop(),f=w.pop(),"?"===M.value?w.push(h(f?v:x,c,l)):(y=c.ternaryOps[M.value],w.push(y(f,v,x)));else if(g===n)if(M.value in c.functions)w.push(c.functions[M.value]);else{var E=l[M.value];if(void 0===E)throw new Error("undefined variable: "+M.value);w.push(E)}else if(g===e)f=w.pop(),y=c.unaryOps[M.value],w.push(y(f));else if(g===i){if(v=w.pop(),f=w.pop(),!(y=c.functions[M.value]).apply||!y.call)throw new Error(y+" is not a function");w.push(y.apply(void 0,[f,v]))}else if(g===o){for(var k=M.value,b=[];k-- >0;)b.unshift(w.pop());if(!(y=w.pop()).apply||!y.call)throw new Error(y+" is not a function");w.push(y.apply(void 0,b))}else if(g===p)w.push(M.value);else{if(g!==a)throw new Error("invalid Expression");f=w.pop(),w.push(f[M.value])}}if(w.length>1)throw new Error("invalid Expression (parity)");return w[0]}(this.tokens,this,h)},w.prototype.toString=function(){return f(this.tokens,!1)},w.prototype.symbols=function(t){t=t||{};var e=[];return y(this.tokens,e,t),e},w.prototype.variables=function(t){t=t||{};var e=[];y(this.tokens,e,t);var s=this.functions;return e.filter(function(t){return!(t in s)})},w.prototype.toJSFunction=function(t,e){var s=this,r=new Function(t,"with(this.functions) with (this.ternaryOps) with (this.binaryOps) with (this.unaryOps) { return "+f(this.simplify(e).tokens,!0)+"; }");return function(){return r.apply(s,arguments)}};var d="TOP";function M(t,e,s){this.type=t,this.value=e,this.index=s}function g(t,e){this.pos=0,this.current=null,this.unaryOps=t.unaryOps,this.binaryOps=t.binaryOps,this.ternaryOps=t.ternaryOps,this.functions=t.functions,this.consts=t.consts,this.expression=e,this.savedPosition=0,this.savedCurrent=null,this.options=t.options}M.prototype.toString=function(){return this.type+": "+this.value},g.prototype.newToken=function(t,e,s){return new M(t,e,null!=s?s:this.pos)},g.prototype.save=function(){this.savedPosition=this.pos,this.savedCurrent=this.current},g.prototype.restore=function(){this.pos=this.savedPosition,this.current=this.savedCurrent},g.prototype.next=function(){return this.pos>=this.expression.length?this.newToken("TEOF","EOF"):this.isWhitespace()||this.isComment()?this.next():this.isRadixInteger()||this.isNumber()||this.isOperator()||this.isString()||this.isParen()||this.isComma()||this.isNamedOp()||this.isFuncOp()||this.isConst()||this.isName()?this.current:void this.parseError('Unknown character "'+this.expression.charAt(this.pos)+'"')},g.prototype.isString=function(){var t=!1,e=this.pos,s=this.expression.charAt(e);if("'"===s||'"'===s)for(var r=this.expression.indexOf(s,e+1);r>=0&&this.pos<this.expression.length;){if(this.pos=r+1,"\\"!==this.expression.charAt(r-1)){var n=this.expression.substring(e+1,r);this.current=this.newToken("TSTRING",this.unescape(n),e),t=!0;break}r=this.expression.indexOf(s,r+1)}return t},g.prototype.isParen=function(){var t=this.expression.charAt(this.pos);return("("===t||")"===t)&&(this.current=this.newToken("TPAREN",t),this.pos++,!0)},g.prototype.isComma=function(){return","===this.expression.charAt(this.pos)&&(this.current=this.newToken("TCOMMA",","),this.pos++,!0)},g.prototype.isConst=function(){for(var t=this.pos,e=t;e<this.expression.length;e++){var s=this.expression.charAt(e);if(s.toUpperCase()===s.toLowerCase()&&(e===this.pos||"_"!==s&&"."!==s&&(s<"0"||s>"9")))break}if(e>t){var r=this.expression.substring(t,e);if(r in this.consts)return this.current=this.newToken("TNUMBER",this.consts[r]),this.pos+=r.length,!0}return!1},g.prototype.isNamedOp=function(){for(var t=this.pos,e=t;e<this.expression.length;e++){var s=this.expression.charAt(e);if(s.toUpperCase()===s.toLowerCase()&&(e===this.pos||"_"!==s&&(s<"0"||s>"9")))break}if(e>t){var r=this.expression.substring(t,e);if(this.isOperatorEnabled(r)&&(r in this.binaryOps||r in this.unaryOps||r in this.ternaryOps))return this.current=this.newToken(d,r),this.pos+=r.length,!0}return!1},g.prototype.isFuncOp=function(){var t,e=this.expression.charAt(this.pos),s=this.pos+1,r=s;if("@"===e){for(;r<this.expression.length&&((e=this.expression.charAt(r)).toUpperCase()!==e.toLowerCase()||!(r===s||"_"!==e&&(e<"0"||e>"9")));r++);if(r>s&&(t=this.expression.substring(s,r))in this.functions)return this.current=this.newToken("TFUNCOP",t),this.pos=s+t.length,!0}return!1},g.prototype.isName=function(){for(var t=this.pos,e=t,s=!1;e<this.expression.length;e++){var r=this.expression.charAt(e);if(r.toUpperCase()===r.toLowerCase()){if(e===this.pos&&("$"===r||"_"===r)){"_"===r&&(s=!0);continue}if(e===this.pos||!s||"_"!==r&&(r<"0"||r>"9"))break}else s=!0}if(s){var n=this.expression.substring(t,e);return this.current=this.newToken("TNAME",n),this.pos+=n.length,!0}return!1},g.prototype.isWhitespace=function(){for(var t=!1,e=this.expression.charAt(this.pos);!(" "!==e&&"\t"!==e&&"\n"!==e&&"\r"!==e||(t=!0,this.pos++,this.pos>=this.expression.length));)e=this.expression.charAt(this.pos);return t};var E=/^[0-9a-f]{4}$/i;g.prototype.unescape=function(t){var e=t.indexOf("\\");if(e<0)return t;for(var s=t.substring(0,e);e>=0;){var r=t.charAt(++e);switch(r){case"'":s+="'";break;case'"':s+='"';break;case"\\":s+="\\";break;case"/":s+="/";break;case"b":s+="\b";break;case"f":s+="\f";break;case"n":s+="\n";break;case"r":s+="\r";break;case"t":s+="\t";break;case"u":var n=t.substring(e+1,e+5);E.test(n)||this.parseError("Illegal escape sequence: \\u"+n),s+=String.fromCharCode(parseInt(n,16)),e+=4;break;default:throw this.parseError('Illegal escape sequence: "\\'+r+'"')}++e;var i=t.indexOf("\\",e);s+=t.substring(e,i<0?t.length:i),e=i}return s},g.prototype.isComment=function(){return"/"===this.expression.charAt(this.pos)&&"*"===this.expression.charAt(this.pos+1)&&(this.pos=this.expression.indexOf("*/",this.pos)+2,1===this.pos&&(this.pos=this.expression.length),!0)},g.prototype.isRadixInteger=function(){var t,e,s=this.pos;if(s>=this.expression.length-2||"0"!==this.expression.charAt(s))return!1;if(++s,"x"===this.expression.charAt(s))t=16,e=/^[0-9a-f]$/i,++s;else{if("b"!==this.expression.charAt(s))return!1;t=2,e=/^[01]$/i,++s}for(var r=!1,n=s;s<this.expression.length;){var i=this.expression.charAt(s);if(!e.test(i))break;s++,r=!0}return r&&(this.current=this.newToken("TNUMBER",parseInt(this.expression.substring(n,s),t)),this.pos=s),r},g.prototype.isNumber=function(){for(var t,e=!1,s=this.pos,r=s,n=s,i=!1,o=!1;s<this.expression.length&&((t=this.expression.charAt(s))>="0"&&t<="9"||!i&&"."===t);)"."===t?i=!0:o=!0,s++,e=o;if(e&&(n=s),"e"===t||"E"===t){s++;for(var p=!0,a=!1;s<this.expression.length;){if(t=this.expression.charAt(s),!p||"+"!==t&&"-"!==t){if(!(t>="0"&&t<="9"))break;a=!0,p=!1}else p=!1;s++}a||(s=n)}return e?(this.current=this.newToken("TNUMBER",parseFloat(this.expression.substring(r,s))),this.pos=s):this.pos=n,e},g.prototype.isOperator=function(){var t=this.pos,e=this.expression.charAt(this.pos);if("+"===e||"-"===e||"*"===e||"/"===e||"%"===e||"^"===e||"?"===e||":"===e||"."===e)this.current=this.newToken(d,e);else if("∙"===e||"•"===e)this.current=this.newToken(d,"*");else if(">"===e)"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(d,">="),this.pos++):this.current=this.newToken(d,">");else if("<"===e)"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(d,"<="),this.pos++):this.current=this.newToken(d,"<");else if("|"===e){if("|"!==this.expression.charAt(this.pos+1))return!1;this.current=this.newToken(d,"||"),this.pos++}else if("="===e){if("="!==this.expression.charAt(this.pos+1))return!1;this.current=this.newToken(d,"=="),this.pos++}else{if("!"!==e)return!1;"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(d,"!="),this.pos++):this.current=this.newToken(d,e)}return this.pos++,!!this.isOperatorEnabled(this.current.value)||(this.pos=t,!1)};var k={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"remainder","^":"power","!":"factorial","<":"comparison",">":"comparison","<=":"comparison",">=":"comparison","==":"comparison","!=":"comparison","||":"concatenate",and:"logical",or:"logical",not:"logical","?":"conditional",":":"conditional"};function b(t,e,s){this.parser=t,this.tokens=e,this.current=null,this.nextToken=null,this.next(),this.savedCurrent=null,this.savedNextToken=null,this.allowMemberAccess=!1!==s.allowMemberAccess}g.prototype.isOperatorEnabled=function(t){var e=function(t){return k.hasOwnProperty(t)?k[t]:t}(t),s=this.options.operators||{};return"in"===e?!!s.in:!(e in s&&!s[e])},g.prototype.getCoordinates=function(){var t,e=0,s=-1;do{e++,t=this.pos-s,s=this.expression.indexOf("\n",s+1)}while(s>=0&&s<this.pos);return{line:e,column:t}},g.prototype.parseError=function(t){var e=this.getCoordinates();throw new Error("parse error ["+e.line+":"+e.column+"]: "+t)},b.prototype.next=function(){return this.current=this.nextToken,this.nextToken=this.tokens.next()},b.prototype.tokenMatches=function(t,e){return void 0===e||(Array.isArray(e)?x(e,t.value):"function"==typeof e?e(t):t.value===e)},b.prototype.save=function(){this.savedCurrent=this.current,this.savedNextToken=this.nextToken,this.tokens.save()},b.prototype.restore=function(){this.tokens.restore(),this.current=this.savedCurrent,this.nextToken=this.savedNextToken},b.prototype.accept=function(t,e){return!(this.nextToken.type!==t||!this.tokenMatches(this.nextToken,e))&&(this.next(),!0)},b.prototype.expect=function(t,e){if(!this.accept(t,e)){var s=this.tokens.getCoordinates();throw new Error("parse error ["+s.line+":"+s.column+"]: Expected "+(e||t))}},b.prototype.parseAtom=function(e){if(this.accept("TNAME"))e.push(new h(n,this.current.value));else if(this.accept("TNUMBER"))e.push(new h(t,this.current.value));else if(this.accept("TSTRING"))e.push(new h(t,this.current.value));else{if(!this.accept("TPAREN","("))throw new Error("unexpected "+this.nextToken);this.parseExpression(e),this.expect("TPAREN",")")}},b.prototype.parseExpression=function(t){this.parseConditionalExpression(t)},b.prototype.parseConditionalExpression=function(t){for(this.parseOrExpression(t);this.accept(d,"?");){var e=[],s=[];this.parseConditionalExpression(e),this.expect(d,":"),this.parseConditionalExpression(s),t.push(new h(p,e)),t.push(new h(p,s)),t.push(l("?"))}},b.prototype.parseOrExpression=function(t){for(this.parseAndExpression(t);this.accept(d,"or");){var e=[];this.parseAndExpression(e),t.push(new h(p,e)),t.push(c("or"))}},b.prototype.parseAndExpression=function(t){for(this.parseComparison(t);this.accept(d,"and");){var e=[];this.parseComparison(e),t.push(new h(p,e)),t.push(c("and"))}};var m=["==","!=","<","<=",">=",">","in"];b.prototype.parseComparison=function(t){for(this.parseAddSub(t);this.accept(d,m);){var e=this.current;this.parseAddSub(t),t.push(c(e.value))}};var O=["+","-","||"];b.prototype.parseAddSub=function(t){for(this.parseTerm(t);this.accept(d,O);){var e=this.current;this.parseTerm(t),t.push(c(e.value))}};var T=["*","/","%"];function A(t,e){return Number(t)+Number(e)}function C(t,e){return t-e}function N(t,e){return t*e}function P(t,e){return t/e}function F(t,e){return t%e}function I(t,e){return""+t+e}function S(t,e){return t===e}function R(t,e){return t!==e}function U(t,e){return t>e}function L(t,e){return t<e}function q(t,e){return t>=e}function B(t,e){return t<=e}function _(t,e){return Boolean(t&&e)}function $(t,e){return Boolean(t||e)}function G(t,e){return x(e,t)}function j(t){return(Math.exp(t)-Math.exp(-t))/2}function J(t){return(Math.exp(t)+Math.exp(-t))/2}function W(t){return t===1/0?1:t===-1/0?-1:(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))}function V(t){return t===-1/0?t:Math.log(t+Math.sqrt(t*t+1))}function X(t){return Math.log(t+Math.sqrt(t*t-1))}function z(t){return Math.log((1+t)/(1-t))/2}function D(t){return Math.log(t)*Math.LOG10E}function H(t){return-t}function K(t){return!t}function Q(t){return t<0?Math.ceil(t):Math.floor(t)}function Y(t){return Math.random()*(t||1)}function Z(t){return st(t+1)}b.prototype.parseTerm=function(t){for(this.parseFactor(t);this.accept(d,T);){var e=this.current;this.parseFactor(t),t.push(c(e.value))}},b.prototype.parseFactor=function(t){var e=this.tokens.unaryOps;if(this.save(),this.accept(d,function(t){return t.value in e}))if("-"!==this.current.value&&"+"!==this.current.value&&"TPAREN"===this.nextToken.type&&"("===this.nextToken.value)this.restore(),this.parseExponential(t);else{var s=this.current;this.parseFactor(t),t.push(u(s.value))}else this.parseExponential(t)},b.prototype.parseExponential=function(t){for(this.parsePostfixExpression(t);this.accept(d,"^");)this.parseFactor(t),t.push(c("^"))},b.prototype.parsePostfixExpression=function(t){for(this.parseFunctionOperator(t);this.accept(d,"!");)t.push(u("!"))},b.prototype.parseFunctionOperator=function(t){var e,s=this.tokens.functions;function r(t){return t.value in s}for(this.parseFunctionCall(t);this.accept("TFUNCOP",r);)e=this.current,this.parseFactor(t),t.push(new h(i,e.value))},b.prototype.parseFunctionCall=function(t){var e=this.tokens.unaryOps;if(this.accept(d,function(t){return t.value in e})){var s=this.current;this.parseAtom(t),t.push(u(s.value))}else for(this.parseMemberExpression(t);this.accept("TPAREN","(");)if(this.accept("TPAREN",")"))t.push(new h(o,0));else{var r=this.parseArgumentList(t);t.push(new h(o,r))}},b.prototype.parseArgumentList=function(t){for(var e=0;!this.accept("TPAREN",")");)for(this.parseExpression(t),++e;this.accept("TCOMMA");)this.parseExpression(t),++e;return e},b.prototype.parseMemberExpression=function(t){for(this.parseAtom(t);this.accept(d,".");){if(!this.allowMemberAccess)throw new Error('unexpected ".", member access is not permitted');this.expect("TNAME"),t.push(new h(a,this.current.value))}};var tt=4.7421875,et=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function st(t){var e,s;if(function(t){return isFinite(t)&&t===Math.round(t)}(t)){if(t<=0)return isFinite(t)?1/0:NaN;if(t>171)return 1/0;for(var r=t-2,n=t-1;r>1;)n*=r,r--;return 0===n&&(n=1),n}if(t<.5)return Math.PI/(Math.sin(Math.PI*t)*st(1-t));if(t>=171.35)return 1/0;if(t>85){var i=t*t,o=i*t,p=o*t,a=p*t;return Math.sqrt(2*Math.PI/t)*Math.pow(t/Math.E,t)*(1+1/(12*t)+1/(288*i)-139/(51840*o)-571/(2488320*p)+163879/(209018880*a)+5246819/(75246796800*a*t))}--t,s=et[0];for(var h=1;h<et.length;++h)s+=et[h]/(t+h);return e=t+tt+.5,Math.sqrt(2*Math.PI)*Math.pow(e,t+.5)*Math.exp(-e)*s}function rt(t){return String(t).length}function nt(){for(var t=0,e=0,s=0;s<arguments.length;s++){var r,n=Math.abs(arguments[s]);e<n?(t=t*(r=e/n)*r+1,e=n):t+=n>0?(r=n/e)*r:n}return e===1/0?1/0:e*Math.sqrt(t)}function it(t,e,s){return t?e:s}function ot(t,e){return void 0===e||0==+e?Math.round(t):(t=+t,e=-+e,isNaN(t)||"number"!=typeof e||e%1!=0?NaN:(t=t.toString().split("e"),+((t=(t=Math.round(+(t[0]+"e"+(t[1]?+t[1]-e:-e)))).toString().split("e"))[0]+"e"+(t[1]?+t[1]+e:e))))}function pt(t){this.options=t||{},this.unaryOps={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh||j,cosh:Math.cosh||J,tanh:Math.tanh||W,asinh:Math.asinh||V,acosh:Math.acosh||X,atanh:Math.atanh||z,sqrt:Math.sqrt,log:Math.log,ln:Math.log,lg:Math.log10||D,log10:Math.log10||D,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc||Q,"-":H,"+":Number,exp:Math.exp,not:K,length:rt,"!":Z},this.binaryOps={"+":A,"-":C,"*":N,"/":P,"%":F,"^":Math.pow,"||":I,"==":S,"!=":R,">":U,"<":L,">=":q,"<=":B,and:_,or:$,in:G},this.ternaryOps={"?":it},this.functions={random:Y,fac:Z,min:Math.min,max:Math.max,hypot:Math.hypot||nt,pyt:Math.hypot||nt,pow:Math.pow,atan2:Math.atan2,if:it,gamma:st,roundTo:ot},this.consts={E:Math.E,PI:Math.PI,true:!0,false:!1}}pt.prototype.parse=function(t){var e=[],s=new b(this,new g(this,t),{allowMemberAccess:this.options.allowMemberAccess});return s.parseExpression(e),s.expect("TEOF","EOF"),new w(e,this)},pt.prototype.evaluate=function(t,e){return this.parse(t).evaluate(e)};var at=new pt;return pt.parse=function(t){return at.parse(t)},pt.evaluate=function(t,e){return at.parse(t).evaluate(e)},{Parser:pt,Expression:w}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.exprEval=e()}(this,function(){"use strict";var t="INUMBER",e="IOP1",s="IOP2",r="IOP3",n="IVAR",i="IFUNCOP",o="IFUNCALL",p="IEXPR",a="IMEMBER";function h(t,e){this.type=t,this.value=void 0!==e&&null!==e?e:0}function u(t){return new h(e,t)}function c(t){return new h(s,t)}function l(t){return new h(r,t)}function f(i,h){for(var u,c,l,x,y=[],w=0;w<i.length;w++){var d=i[w],M=d.type;if(M===t)"number"==typeof d.value&&d.value<0?y.push("("+d.value+")"):y.push(v(d.value));else if(M===s)c=y.pop(),u=y.pop(),x=d.value,h?"^"===x?y.push("Math.pow("+u+", "+c+")"):"and"===x?y.push("(!!"+u+" && !!"+c+")"):"or"===x?y.push("(!!"+u+" || !!"+c+")"):"||"===x?y.push("(String("+u+") + String("+c+"))"):"=="===x?y.push("("+u+" === "+c+")"):"!="===x?y.push("("+u+" !== "+c+")"):y.push("("+u+" "+x+" "+c+")"):y.push("("+u+" "+x+" "+c+")");else if(M===r){if(l=y.pop(),c=y.pop(),u=y.pop(),"?"!==(x=d.value))throw new Error("invalid Expression");y.push("("+u+" ? "+c+" : "+l+")")}else if(M===n)y.push(d.value);else if(M===e)u=y.pop(),"-"===(x=d.value)||"+"===x?y.push("("+x+u+")"):h?"not"===x?y.push("(!"+u+")"):"!"===x?y.push("fac("+u+")"):y.push(x+"("+u+")"):"!"===x?y.push("("+u+"!)"):y.push("("+x+" "+u+")");else if(M===o){for(var g=d.value,E=[];g-- >0;)E.unshift(y.pop());x=y.pop(),y.push(x+"("+E.join(", ")+")")}else if(M===a)u=y.pop(),y.push(u+"."+d.value);else{if(M!==p)throw new Error("invalid Expression");y.push("("+f(d.value,h)+")")}}if(y.length>1)throw new Error("invalid Expression (parity)");return String(y[0])}function v(t){return"string"==typeof t?JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"):t}function x(t,e){for(var s=0;s<t.length;s++)if(t[s]===e)return!0;return!1}function y(t,e,s){for(var r=!!(s=s||{}).withMembers,i=null,o=0;o<t.length;o++){var h=t[o];h.type===n?r||x(e,h.value)?null!==i?(x(e,i)||e.push(i),i=h.value):i=h.value:e.push(h.value):h.type===a&&r&&null!==i?i+="."+h.value:h.type===p?y(h.value,e,s):null!==i&&(x(e,i)||e.push(i),i=null)}null===i||x(e,i)||e.push(i)}function w(t,e){this.tokens=t,this.parser=e,this.unaryOps=e.unaryOps,this.binaryOps=e.binaryOps,this.ternaryOps=e.ternaryOps,this.functions=e.functions}h.prototype.toString=function(){switch(this.type){case t:case e:case s:case r:case n:case i:return this.value;case o:return"CALL "+this.value;case a:return"."+this.value;default:return"Invalid Instruction"}},w.prototype.simplify=function(i){return i=i||{},new w(function i(o,u,c,l,f){for(var v,x,y,w,d=[],M=[],g=0;g<o.length;g++){var E=o[g],k=E.type;if(k===t)d.push(E);else if(k===n&&f.hasOwnProperty(E.value))E=new h(t,f[E.value]),d.push(E);else if(k===s&&d.length>1)x=d.pop(),v=d.pop(),w=c[E.value],E=new h(t,w(v.value,x.value)),d.push(E);else if(k===r&&d.length>2)y=d.pop(),x=d.pop(),v=d.pop(),"?"===E.value?d.push(v.value?x.value:y.value):(w=l[E.value],E=new h(t,w(v.value,x.value,y.value)),d.push(E));else if(k===e&&d.length>0)v=d.pop(),w=u[E.value],E=new h(t,w(v.value)),d.push(E);else if(k===p){for(;d.length>0;)M.push(d.shift());M.push(new h(p,i(E.value,u,c,l,f)))}else if(k===a&&d.length>0)v=d.pop(),d.push(new h(t,v.value[E.value]));else{for(;d.length>0;)M.push(d.shift());M.push(E)}}for(;d.length>0;)M.push(d.shift());return M}(this.tokens,this.unaryOps,this.binaryOps,this.ternaryOps,i),this.parser)},w.prototype.substitute=function(t,i){return i instanceof w||(i=this.parser.parse(String(i))),new w(function t(i,o,a){for(var f=[],v=0;v<i.length;v++){var x=i[v],y=x.type;if(y===n&&x.value===o)for(var w=0;w<a.tokens.length;w++){var d,M=a.tokens[w];d=M.type===e?u(M.value):M.type===s?c(M.value):M.type===r?l(M.value):new h(M.type,M.value),f.push(d)}else y===p?f.push(new h(p,t(x.value,o,a))):f.push(x)}return f}(this.tokens,t,i),this.parser)},w.prototype.evaluate=function(h){return h=h||{},function h(u,c,l){for(var f,v,x,y,w=[],d=0;d<u.length;d++){var M=u[d],g=M.type;if(g===t)w.push(M.value);else if(g===s)v=w.pop(),f=w.pop(),"and"===M.value?w.push(!!f&&!!h(v,c,l)):"or"===M.value?w.push(!!f||!!h(v,c,l)):(y=c.binaryOps[M.value],w.push(y(f,v)));else if(g===r)x=w.pop(),v=w.pop(),f=w.pop(),"?"===M.value?w.push(h(f?v:x,c,l)):(y=c.ternaryOps[M.value],w.push(y(f,v,x)));else if(g===n)if(M.value in c.functions)w.push(c.functions[M.value]);else{var E=l[M.value];if(void 0===E)throw new Error("undefined variable: "+M.value);w.push(E)}else if(g===e)f=w.pop(),y=c.unaryOps[M.value],w.push(y(f));else if(g===i){if(v=w.pop(),f=w.pop(),!(y=c.functions[M.value]).apply||!y.call)throw new Error(y+" is not a function");w.push(y.apply(void 0,[f,v]))}else if(g===o){for(var k=M.value,b=[];k-- >0;)b.unshift(w.pop());if(!(y=w.pop()).apply||!y.call)throw new Error(y+" is not a function");w.push(y.apply(void 0,b))}else if(g===p)w.push(M.value);else{if(g!==a)throw new Error("invalid Expression");f=w.pop(),w.push(f[M.value])}}if(w.length>1)throw new Error("invalid Expression (parity)");return-0===w[0]?0:w[0]}(this.tokens,this,h)},w.prototype.toString=function(){return f(this.tokens,!1)},w.prototype.symbols=function(t){t=t||{};var e=[];return y(this.tokens,e,t),e},w.prototype.variables=function(t){t=t||{};var e=[];y(this.tokens,e,t);var s=this.functions;return e.filter(function(t){return!(t in s)})},w.prototype.toJSFunction=function(t,e){var s=this,r=new Function(t,"with(this.functions) with (this.ternaryOps) with (this.binaryOps) with (this.unaryOps) { return "+f(this.simplify(e).tokens,!0)+"; }");return function(){return r.apply(s,arguments)}};var d="TOP";function M(t,e,s){this.type=t,this.value=e,this.index=s}function g(t,e){this.pos=0,this.current=null,this.unaryOps=t.unaryOps,this.binaryOps=t.binaryOps,this.ternaryOps=t.ternaryOps,this.functions=t.functions,this.consts=t.consts,this.expression=e,this.savedPosition=0,this.savedCurrent=null,this.options=t.options}M.prototype.toString=function(){return this.type+": "+this.value},g.prototype.newToken=function(t,e,s){return new M(t,e,null!=s?s:this.pos)},g.prototype.save=function(){this.savedPosition=this.pos,this.savedCurrent=this.current},g.prototype.restore=function(){this.pos=this.savedPosition,this.current=this.savedCurrent},g.prototype.next=function(){return this.pos>=this.expression.length?this.newToken("TEOF","EOF"):this.isWhitespace()||this.isComment()?this.next():this.isRadixInteger()||this.isNumber()||this.isOperator()||this.isString()||this.isParen()||this.isComma()||this.isNamedOp()||this.isFuncOp()||this.isConst()||this.isName()?this.current:void this.parseError('Unknown character "'+this.expression.charAt(this.pos)+'"')},g.prototype.isString=function(){var t=!1,e=this.pos,s=this.expression.charAt(e);if("'"===s||'"'===s)for(var r=this.expression.indexOf(s,e+1);r>=0&&this.pos<this.expression.length;){if(this.pos=r+1,"\\"!==this.expression.charAt(r-1)){var n=this.expression.substring(e+1,r);this.current=this.newToken("TSTRING",this.unescape(n),e),t=!0;break}r=this.expression.indexOf(s,r+1)}return t},g.prototype.isParen=function(){var t=this.expression.charAt(this.pos);return("("===t||")"===t)&&(this.current=this.newToken("TPAREN",t),this.pos++,!0)},g.prototype.isComma=function(){return","===this.expression.charAt(this.pos)&&(this.current=this.newToken("TCOMMA",","),this.pos++,!0)},g.prototype.isConst=function(){for(var t=this.pos,e=t;e<this.expression.length;e++){var s=this.expression.charAt(e);if(s.toUpperCase()===s.toLowerCase()&&(e===this.pos||"_"!==s&&"."!==s&&(s<"0"||s>"9")))break}if(e>t){var r=this.expression.substring(t,e);if(r in this.consts)return this.current=this.newToken("TNUMBER",this.consts[r]),this.pos+=r.length,!0}return!1},g.prototype.isNamedOp=function(){for(var t=this.pos,e=t;e<this.expression.length;e++){var s=this.expression.charAt(e);if(s.toUpperCase()===s.toLowerCase()&&(e===this.pos||"_"!==s&&(s<"0"||s>"9")))break}if(e>t){var r=this.expression.substring(t,e);if(this.isOperatorEnabled(r)&&(r in this.binaryOps||r in this.unaryOps||r in this.ternaryOps))return this.current=this.newToken(d,r),this.pos+=r.length,!0}return!1},g.prototype.isFuncOp=function(){var t,e=this.expression.charAt(this.pos),s=this.pos+1,r=s;if("@"===e){for(;r<this.expression.length&&((e=this.expression.charAt(r)).toUpperCase()!==e.toLowerCase()||!(r===s||"_"!==e&&(e<"0"||e>"9")));r++);if(r>s&&(t=this.expression.substring(s,r))in this.functions)return this.current=this.newToken("TFUNCOP",t),this.pos=s+t.length,!0}return!1},g.prototype.isName=function(){for(var t=this.pos,e=t,s=!1;e<this.expression.length;e++){var r=this.expression.charAt(e);if(r.toUpperCase()===r.toLowerCase()){if(e===this.pos&&("$"===r||"_"===r)){"_"===r&&(s=!0);continue}if(e===this.pos||!s||"_"!==r&&(r<"0"||r>"9"))break}else s=!0}if(s){var n=this.expression.substring(t,e);return this.current=this.newToken("TNAME",n),this.pos+=n.length,!0}return!1},g.prototype.isWhitespace=function(){for(var t=!1,e=this.expression.charAt(this.pos);!(" "!==e&&"\t"!==e&&"\n"!==e&&"\r"!==e||(t=!0,this.pos++,this.pos>=this.expression.length));)e=this.expression.charAt(this.pos);return t};var E=/^[0-9a-f]{4}$/i;g.prototype.unescape=function(t){var e=t.indexOf("\\");if(e<0)return t;for(var s=t.substring(0,e);e>=0;){var r=t.charAt(++e);switch(r){case"'":s+="'";break;case'"':s+='"';break;case"\\":s+="\\";break;case"/":s+="/";break;case"b":s+="\b";break;case"f":s+="\f";break;case"n":s+="\n";break;case"r":s+="\r";break;case"t":s+="\t";break;case"u":var n=t.substring(e+1,e+5);E.test(n)||this.parseError("Illegal escape sequence: \\u"+n),s+=String.fromCharCode(parseInt(n,16)),e+=4;break;default:throw this.parseError('Illegal escape sequence: "\\'+r+'"')}++e;var i=t.indexOf("\\",e);s+=t.substring(e,i<0?t.length:i),e=i}return s},g.prototype.isComment=function(){return"/"===this.expression.charAt(this.pos)&&"*"===this.expression.charAt(this.pos+1)&&(this.pos=this.expression.indexOf("*/",this.pos)+2,1===this.pos&&(this.pos=this.expression.length),!0)},g.prototype.isRadixInteger=function(){var t,e,s=this.pos;if(s>=this.expression.length-2||"0"!==this.expression.charAt(s))return!1;if(++s,"x"===this.expression.charAt(s))t=16,e=/^[0-9a-f]$/i,++s;else{if("b"!==this.expression.charAt(s))return!1;t=2,e=/^[01]$/i,++s}for(var r=!1,n=s;s<this.expression.length;){var i=this.expression.charAt(s);if(!e.test(i))break;s++,r=!0}return r&&(this.current=this.newToken("TNUMBER",parseInt(this.expression.substring(n,s),t)),this.pos=s),r},g.prototype.isNumber=function(){for(var t,e=!1,s=this.pos,r=s,n=s,i=!1,o=!1;s<this.expression.length&&((t=this.expression.charAt(s))>="0"&&t<="9"||!i&&"."===t);)"."===t?i=!0:o=!0,s++,e=o;if(e&&(n=s),"e"===t||"E"===t){s++;for(var p=!0,a=!1;s<this.expression.length;){if(t=this.expression.charAt(s),!p||"+"!==t&&"-"!==t){if(!(t>="0"&&t<="9"))break;a=!0,p=!1}else p=!1;s++}a||(s=n)}return e?(this.current=this.newToken("TNUMBER",parseFloat(this.expression.substring(r,s))),this.pos=s):this.pos=n,e},g.prototype.isOperator=function(){var t=this.pos,e=this.expression.charAt(this.pos);if("+"===e||"-"===e||"*"===e||"/"===e||"%"===e||"^"===e||"?"===e||":"===e||"."===e)this.current=this.newToken(d,e);else if("∙"===e||"•"===e)this.current=this.newToken(d,"*");else if(">"===e)"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(d,">="),this.pos++):this.current=this.newToken(d,">");else if("<"===e)"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(d,"<="),this.pos++):this.current=this.newToken(d,"<");else if("|"===e){if("|"!==this.expression.charAt(this.pos+1))return!1;this.current=this.newToken(d,"||"),this.pos++}else if("="===e){if("="!==this.expression.charAt(this.pos+1))return!1;this.current=this.newToken(d,"=="),this.pos++}else{if("!"!==e)return!1;"="===this.expression.charAt(this.pos+1)?(this.current=this.newToken(d,"!="),this.pos++):this.current=this.newToken(d,e)}return this.pos++,!!this.isOperatorEnabled(this.current.value)||(this.pos=t,!1)};var k={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"remainder","^":"power","!":"factorial","<":"comparison",">":"comparison","<=":"comparison",">=":"comparison","==":"comparison","!=":"comparison","||":"concatenate",and:"logical",or:"logical",not:"logical","?":"conditional",":":"conditional"};function b(t,e,s){this.parser=t,this.tokens=e,this.current=null,this.nextToken=null,this.next(),this.savedCurrent=null,this.savedNextToken=null,this.allowMemberAccess=!1!==s.allowMemberAccess}g.prototype.isOperatorEnabled=function(t){var e=function(t){return k.hasOwnProperty(t)?k[t]:t}(t),s=this.options.operators||{};return"in"===e?!!s.in:!(e in s&&!s[e])},g.prototype.getCoordinates=function(){var t,e=0,s=-1;do{e++,t=this.pos-s,s=this.expression.indexOf("\n",s+1)}while(s>=0&&s<this.pos);return{line:e,column:t}},g.prototype.parseError=function(t){var e=this.getCoordinates();throw new Error("parse error ["+e.line+":"+e.column+"]: "+t)},b.prototype.next=function(){return this.current=this.nextToken,this.nextToken=this.tokens.next()},b.prototype.tokenMatches=function(t,e){return void 0===e||(Array.isArray(e)?x(e,t.value):"function"==typeof e?e(t):t.value===e)},b.prototype.save=function(){this.savedCurrent=this.current,this.savedNextToken=this.nextToken,this.tokens.save()},b.prototype.restore=function(){this.tokens.restore(),this.current=this.savedCurrent,this.nextToken=this.savedNextToken},b.prototype.accept=function(t,e){return!(this.nextToken.type!==t||!this.tokenMatches(this.nextToken,e))&&(this.next(),!0)},b.prototype.expect=function(t,e){if(!this.accept(t,e)){var s=this.tokens.getCoordinates();throw new Error("parse error ["+s.line+":"+s.column+"]: Expected "+(e||t))}},b.prototype.parseAtom=function(e){if(this.accept("TNAME"))e.push(new h(n,this.current.value));else if(this.accept("TNUMBER"))e.push(new h(t,this.current.value));else if(this.accept("TSTRING"))e.push(new h(t,this.current.value));else{if(!this.accept("TPAREN","("))throw new Error("unexpected "+this.nextToken);this.parseExpression(e),this.expect("TPAREN",")")}},b.prototype.parseExpression=function(t){this.parseConditionalExpression(t)},b.prototype.parseConditionalExpression=function(t){for(this.parseOrExpression(t);this.accept(d,"?");){var e=[],s=[];this.parseConditionalExpression(e),this.expect(d,":"),this.parseConditionalExpression(s),t.push(new h(p,e)),t.push(new h(p,s)),t.push(l("?"))}},b.prototype.parseOrExpression=function(t){for(this.parseAndExpression(t);this.accept(d,"or");){var e=[];this.parseAndExpression(e),t.push(new h(p,e)),t.push(c("or"))}},b.prototype.parseAndExpression=function(t){for(this.parseComparison(t);this.accept(d,"and");){var e=[];this.parseComparison(e),t.push(new h(p,e)),t.push(c("and"))}};var m=["==","!=","<","<=",">=",">","in"];b.prototype.parseComparison=function(t){for(this.parseAddSub(t);this.accept(d,m);){var e=this.current;this.parseAddSub(t),t.push(c(e.value))}};var O=["+","-","||"];b.prototype.parseAddSub=function(t){for(this.parseTerm(t);this.accept(d,O);){var e=this.current;this.parseTerm(t),t.push(c(e.value))}};var T=["*","/","%"];function A(t,e){return Number(t)+Number(e)}function C(t,e){return t-e}function N(t,e){return t*e}function P(t,e){return t/e}function F(t,e){return t%e}function I(t,e){return""+t+e}function S(t,e){return t===e}function R(t,e){return t!==e}function U(t,e){return t>e}function L(t,e){return t<e}function q(t,e){return t>=e}function B(t,e){return t<=e}function _(t,e){return Boolean(t&&e)}function $(t,e){return Boolean(t||e)}function G(t,e){return x(e,t)}function j(t){return(Math.exp(t)-Math.exp(-t))/2}function J(t){return(Math.exp(t)+Math.exp(-t))/2}function W(t){return t===1/0?1:t===-1/0?-1:(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))}function V(t){return t===-1/0?t:Math.log(t+Math.sqrt(t*t+1))}function X(t){return Math.log(t+Math.sqrt(t*t-1))}function z(t){return Math.log((1+t)/(1-t))/2}function D(t){return Math.log(t)*Math.LOG10E}function H(t){return-t}function K(t){return!t}function Q(t){return t<0?Math.ceil(t):Math.floor(t)}function Y(t){return Math.random()*(t||1)}function Z(t){return st(t+1)}b.prototype.parseTerm=function(t){for(this.parseFactor(t);this.accept(d,T);){var e=this.current;this.parseFactor(t),t.push(c(e.value))}},b.prototype.parseFactor=function(t){var e=this.tokens.unaryOps;if(this.save(),this.accept(d,function(t){return t.value in e}))if("-"!==this.current.value&&"+"!==this.current.value&&"TPAREN"===this.nextToken.type&&"("===this.nextToken.value)this.restore(),this.parseExponential(t);else{var s=this.current;this.parseFactor(t),t.push(u(s.value))}else this.parseExponential(t)},b.prototype.parseExponential=function(t){for(this.parsePostfixExpression(t);this.accept(d,"^");)this.parseFactor(t),t.push(c("^"))},b.prototype.parsePostfixExpression=function(t){for(this.parseFunctionOperator(t);this.accept(d,"!");)t.push(u("!"))},b.prototype.parseFunctionOperator=function(t){var e,s=this.tokens.functions;function r(t){return t.value in s}for(this.parseFunctionCall(t);this.accept("TFUNCOP",r);)e=this.current,this.parseFactor(t),t.push(new h(i,e.value))},b.prototype.parseFunctionCall=function(t){var e=this.tokens.unaryOps;if(this.accept(d,function(t){return t.value in e})){var s=this.current;this.parseAtom(t),t.push(u(s.value))}else for(this.parseMemberExpression(t);this.accept("TPAREN","(");)if(this.accept("TPAREN",")"))t.push(new h(o,0));else{var r=this.parseArgumentList(t);t.push(new h(o,r))}},b.prototype.parseArgumentList=function(t){for(var e=0;!this.accept("TPAREN",")");)for(this.parseExpression(t),++e;this.accept("TCOMMA");)this.parseExpression(t),++e;return e},b.prototype.parseMemberExpression=function(t){for(this.parseAtom(t);this.accept(d,".");){if(!this.allowMemberAccess)throw new Error('unexpected ".", member access is not permitted');this.expect("TNAME"),t.push(new h(a,this.current.value))}};var tt=4.7421875,et=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function st(t){var e,s;if(function(t){return isFinite(t)&&t===Math.round(t)}(t)){if(t<=0)return isFinite(t)?1/0:NaN;if(t>171)return 1/0;for(var r=t-2,n=t-1;r>1;)n*=r,r--;return 0===n&&(n=1),n}if(t<.5)return Math.PI/(Math.sin(Math.PI*t)*st(1-t));if(t>=171.35)return 1/0;if(t>85){var i=t*t,o=i*t,p=o*t,a=p*t;return Math.sqrt(2*Math.PI/t)*Math.pow(t/Math.E,t)*(1+1/(12*t)+1/(288*i)-139/(51840*o)-571/(2488320*p)+163879/(209018880*a)+5246819/(75246796800*a*t))}--t,s=et[0];for(var h=1;h<et.length;++h)s+=et[h]/(t+h);return e=t+tt+.5,Math.sqrt(2*Math.PI)*Math.pow(e,t+.5)*Math.exp(-e)*s}function rt(t){return String(t).length}function nt(){for(var t=0,e=0,s=0;s<arguments.length;s++){var r,n=Math.abs(arguments[s]);e<n?(t=t*(r=e/n)*r+1,e=n):t+=n>0?(r=n/e)*r:n}return e===1/0?1/0:e*Math.sqrt(t)}function it(t,e,s){return t?e:s}function ot(t,e){return void 0===e||0==+e?Math.round(t):(t=+t,e=-+e,isNaN(t)||"number"!=typeof e||e%1!=0?NaN:(t=t.toString().split("e"),+((t=(t=Math.round(+(t[0]+"e"+(t[1]?+t[1]-e:-e)))).toString().split("e"))[0]+"e"+(t[1]?+t[1]+e:e))))}function pt(t){this.options=t||{},this.unaryOps={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh||j,cosh:Math.cosh||J,tanh:Math.tanh||W,asinh:Math.asinh||V,acosh:Math.acosh||X,atanh:Math.atanh||z,sqrt:Math.sqrt,log:Math.log,ln:Math.log,lg:Math.log10||D,log10:Math.log10||D,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc||Q,"-":H,"+":Number,exp:Math.exp,not:K,length:rt,"!":Z},this.binaryOps={"+":A,"-":C,"*":N,"/":P,"%":F,"^":Math.pow,"||":I,"==":S,"!=":R,">":U,"<":L,">=":q,"<=":B,and:_,or:$,in:G},this.ternaryOps={"?":it},this.functions={random:Y,fac:Z,min:Math.min,max:Math.max,hypot:Math.hypot||nt,pyt:Math.hypot||nt,pow:Math.pow,atan2:Math.atan2,if:it,gamma:st,roundTo:ot},this.consts={E:Math.E,PI:Math.PI,true:!0,false:!1}}pt.prototype.parse=function(t){var e=[],s=new b(this,new g(this,t),{allowMemberAccess:this.options.allowMemberAccess});return s.parseExpression(e),s.expect("TEOF","EOF"),new w(e,this)},pt.prototype.evaluate=function(t,e){return this.parse(t).evaluate(e)};var at=new pt;return pt.parse=function(t){return at.parse(t)},pt.evaluate=function(t,e){return at.parse(t).evaluate(e)},{Parser:pt,Expression:w}});
{
"name": "@oat-sa/expr-eval",
"version": "1.3.0",
"version": "1.3.1",
"description": "Mathematical expression evaluator",

@@ -12,12 +12,12 @@ "main": "dist/bundle.js",

"devDependencies": {
"eslint": "^5.12.1",
"eslint": "^5.16.0",
"eslint-config-semistandard": "^13.0.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.15.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^4.1.0",
"istanbul": "^0.4.5",
"mocha": "^5.0.0",
"rollup": "^0.63.0",
"mocha": "^10.0.0",
"rollup": "^0.63.5",
"rollup-plugin-uglify": "^3.0.0"

@@ -24,0 +24,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc