Socket
Socket
Sign inDemoInstall

expression-eval

Package Overview
Dependencies
1
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.2 to 4.0.0

dist/expression-eval.modern.js

2

dist/expression-eval.js

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

var e,r=(e=require("jsep"))&&"object"==typeof e&&"default"in e?e.default:e,n=function(e,r){try{var s=!1;function c(){if("function"==typeof l){var n=l,t=n.apply,u=a;return Promise.resolve(o(e.arguments,r)).then(function(e){return Promise.resolve(t.call(n,u,e))})}}switch(e.type){case"ArrayExpression":return Promise.resolve(o(e.elements,r));case"BinaryExpression":return Promise.resolve(Promise.all([n(e.left,r),n(e.right,r)])).then(function(r){return u[e.operator](r[0],r[1])});case"CallExpression":var a,l,f,p="MemberExpression"===e.callee.type?Promise.resolve(t(e.callee,r)).then(function(e){a=(f=e)[0],l=f[1]}):Promise.resolve(n(e.callee,r)).then(function(e){l=e});return Promise.resolve(p&&p.then?p.then(c):c());case"ConditionalExpression":return Promise.resolve(n(e.test,r)).then(function(t){return Promise.resolve(n(t?e.consequent:e.alternate,r))});case"Identifier":return Promise.resolve(r[e.name]);case"Literal":return Promise.resolve(e.value);case"LogicalExpression":{function m(t){return s?t:Promise.resolve(Promise.all([n(e.left,r),n(e.right,r)])).then(function(r){return u[e.operator](r[0],r[1])})}var v="||"===e.operator?(s=!0,Promise.resolve(n(e.left,r)).then(function(t){return t||Promise.resolve(n(e.right,r))})):function(){if("&&"===e.operator)return s=!0,Promise.resolve(n(e.left,r)).then(function(t){return t?Promise.resolve(n(e.right,r)):t})}();return Promise.resolve(v&&v.then?v.then(m):m(v))}case"MemberExpression":return Promise.resolve(t(e,r)).then(function(e){return e[1]});case"ThisExpression":return Promise.resolve(r);case"UnaryExpression":var h=i[e.operator];return Promise.resolve(n(e.argument,r)).then(function(e){return h.call(i,e)});default:return Promise.resolve(void 0)}}catch(e){return Promise.reject(e)}},t=function(e,r){try{return Promise.resolve(n(e.object,r)).then(function(t){return e.computed?Promise.resolve(n(e.property,r)).then(function(e){return[t,t[e]]}):[t,t[e.property.name]]})}catch(e){return Promise.reject(e)}},o=function(e,r){try{return Promise.resolve(Promise.all(e.map(function(e){return n(e,r)})))}catch(e){return Promise.reject(e)}},u={"||":function(e,r){return e||r},"&&":function(e,r){return e&&r},"|":function(e,r){return e|r},"^":function(e,r){return e^r},"&":function(e,r){return e&r},"==":function(e,r){return e==r},"!=":function(e,r){return e!=r},"===":function(e,r){return e===r},"!==":function(e,r){return e!==r},"<":function(e,r){return e<r},">":function(e,r){return e>r},"<=":function(e,r){return e<=r},">=":function(e,r){return e>=r},"<<":function(e,r){return e<<r},">>":function(e,r){return e>>r},">>>":function(e,r){return e>>>r},"+":function(e,r){return e+r},"-":function(e,r){return e-r},"*":function(e,r){return e*r},"/":function(e,r){return e/r},"%":function(e,r){return e%r}},i={"-":function(e){return-e},"+":function(e){return+e},"~":function(e){return~e},"!":function(e){return!e}};function s(e,r){return e.map(function(e){return a(e,r)})}function c(e,r){var n=a(e.object,r);return e.computed?[n,n[a(e.property,r)]]:[n,n[e.property.name]]}function a(e,r){switch(e.type){case"ArrayExpression":return s(e.elements,r);case"BinaryExpression":return u[e.operator](a(e.left,r),a(e.right,r));case"CallExpression":var n,t,o;if("MemberExpression"===e.callee.type?(n=(o=c(e.callee,r))[0],t=o[1]):t=a(e.callee,r),"function"!=typeof t)return;return t.apply(n,s(e.arguments,r));case"ConditionalExpression":return a(e.test,r)?a(e.consequent,r):a(e.alternate,r);case"Identifier":return r[e.name];case"Literal":return e.value;case"LogicalExpression":return"||"===e.operator?a(e.left,r)||a(e.right,r):"&&"===e.operator?a(e.left,r)&&a(e.right,r):u[e.operator](a(e.left,r),a(e.right,r));case"MemberExpression":return c(e,r)[1];case"ThisExpression":return r;case"UnaryExpression":return i[e.operator](a(e.argument,r));default:return}}exports.parse=r,exports.eval=a,exports.evalAsync=n,exports.compile=function(e){return a.bind(null,r(e))},exports.compileAsync=function(e){return n.bind(null,r(e))},exports.addUnaryOp=function(e,n){r.addUnaryOp(e),i[e]=n},exports.addBinaryOp=function(e,n){r.addBinaryOp(e),u[e]=n};
function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=e(require("jsep")),n=function e(r,n){try{var u,a=r;switch(a.type){case"ArrayExpression":return Promise.resolve(o(a.elements,n));case"BinaryExpression":return Promise.resolve(Promise.all([e(a.left,n),e(a.right,n)])).then(function(e){return i[a.operator](e[0],e[1])});case"CallExpression":var c,l,f,p=function(){if("function"==typeof l){var e=l,r=e.apply,t=c;return Promise.resolve(o(a.arguments,n)).then(function(n){return Promise.resolve(r.call(e,t,n))})}},m="MemberExpression"===a.callee.type?Promise.resolve(t(a.callee,n)).then(function(e){c=(f=e)[0],l=f[1]}):Promise.resolve(e(a.callee,n)).then(function(e){l=e});return Promise.resolve(m&&m.then?m.then(p):p());case"ConditionalExpression":return Promise.resolve(e(a.test,n)).then(function(r){return Promise.resolve(e(r?a.consequent:a.alternate,n))});case"Identifier":return Promise.resolve(n[a.name]);case"Literal":return Promise.resolve(a.value);case"LogicalExpression":var v=function(r){return u?r:Promise.resolve(Promise.all([e(a.left,n),e(a.right,n)])).then(function(e){return i[a.operator](e[0],e[1])})},h="||"===a.operator?(u=1,Promise.resolve(e(a.left,n)).then(function(r){return r||Promise.resolve(e(a.right,n))})):function(){if("&&"===a.operator)return u=1,Promise.resolve(e(a.left,n)).then(function(r){return r?Promise.resolve(e(a.right,n)):r})}();return Promise.resolve(h&&h.then?h.then(v):v(h));case"MemberExpression":return Promise.resolve(t(a,n)).then(function(e){return e[1]});case"ThisExpression":return Promise.resolve(n);case"UnaryExpression":var P=s[a.operator];return Promise.resolve(e(a.argument,n)).then(function(e){return P.call(s,e)});default:return Promise.resolve(void 0)}}catch(e){return Promise.reject(e)}},t=function(e,r){try{return Promise.resolve(n(e.object,r)).then(function(t){return e.computed?Promise.resolve(n(e.property,r)).then(function(e){return[t,t[e]]}):[t,t[e.property.name]]})}catch(e){return Promise.reject(e)}},o=function(e,r){try{return Promise.resolve(Promise.all(e.map(function(e){return n(e,r)})))}catch(e){return Promise.reject(e)}},u={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},i={"||":function(e,r){return e||r},"&&":function(e,r){return e&&r},"|":function(e,r){return e|r},"^":function(e,r){return e^r},"&":function(e,r){return e&r},"==":function(e,r){return e==r},"!=":function(e,r){return e!=r},"===":function(e,r){return e===r},"!==":function(e,r){return e!==r},"<":function(e,r){return e<r},">":function(e,r){return e>r},"<=":function(e,r){return e<=r},">=":function(e,r){return e>=r},"<<":function(e,r){return e<<r},">>":function(e,r){return e>>r},">>>":function(e,r){return e>>>r},"+":function(e,r){return e+r},"-":function(e,r){return e-r},"*":function(e,r){return e*r},"/":function(e,r){return e/r},"%":function(e,r){return e%r}},s={"-":function(e){return-e},"+":function(e){return+e},"~":function(e){return~e},"!":function(e){return!e}};function a(e,r){return e.map(function(e){return l(e,r)})}function c(e,r){var n=l(e.object,r);return e.computed?[n,n[l(e.property,r)]]:[n,n[e.property.name]]}function l(e,r){var n=e;switch(n.type){case"ArrayExpression":return a(n.elements,r);case"BinaryExpression":return i[n.operator](l(n.left,r),l(n.right,r));case"CallExpression":var t,o,u;if("MemberExpression"===n.callee.type?(t=(u=c(n.callee,r))[0],o=u[1]):o=l(n.callee,r),"function"!=typeof o)return;return o.apply(t,a(n.arguments,r));case"ConditionalExpression":return l(n.test,r)?l(n.consequent,r):l(n.alternate,r);case"Identifier":return r[n.name];case"Literal":return n.value;case"LogicalExpression":return"||"===n.operator?l(n.left,r)||l(n.right,r):"&&"===n.operator?l(n.left,r)&&l(n.right,r):i[n.operator](l(n.left,r),l(n.right,r));case"MemberExpression":return c(n,r)[1];case"ThisExpression":return r;case"UnaryExpression":return s[n.operator](l(n.argument,r));default:return}}Object.defineProperty(exports,"parse",{enumerable:!0,get:function(){return r.default}}),exports.addBinaryOp=function(e,n,t){t?(r.default.addBinaryOp(e,n),i[e]=t):(r.default.addBinaryOp(e,u[e]||1),i[e]=n)},exports.addUnaryOp=function(e,n){r.default.addUnaryOp(e),s[e]=n},exports.compile=function(e){return l.bind(null,r.default(e))},exports.compileAsync=function(e){return n.bind(null,r.default(e))},exports.eval=l,exports.evalAsync=n;
//# sourceMappingURL=expression-eval.js.map

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

import e from"jsep";export{default as parse}from"jsep";var r=function(e,i){try{var s=!1;function c(){if("function"==typeof l){var r=l,n=r.apply,o=a;return Promise.resolve(t(e.arguments,i)).then(function(e){return Promise.resolve(n.call(r,o,e))})}}switch(e.type){case"ArrayExpression":return Promise.resolve(t(e.elements,i));case"BinaryExpression":return Promise.resolve(Promise.all([r(e.left,i),r(e.right,i)])).then(function(r){return o[e.operator](r[0],r[1])});case"CallExpression":var a,l,f,p="MemberExpression"===e.callee.type?Promise.resolve(n(e.callee,i)).then(function(e){a=(f=e)[0],l=f[1]}):Promise.resolve(r(e.callee,i)).then(function(e){l=e});return Promise.resolve(p&&p.then?p.then(c):c());case"ConditionalExpression":return Promise.resolve(r(e.test,i)).then(function(n){return Promise.resolve(r(n?e.consequent:e.alternate,i))});case"Identifier":return Promise.resolve(i[e.name]);case"Literal":return Promise.resolve(e.value);case"LogicalExpression":{function m(n){return s?n:Promise.resolve(Promise.all([r(e.left,i),r(e.right,i)])).then(function(r){return o[e.operator](r[0],r[1])})}var v="||"===e.operator?(s=!0,Promise.resolve(r(e.left,i)).then(function(n){return n||Promise.resolve(r(e.right,i))})):function(){if("&&"===e.operator)return s=!0,Promise.resolve(r(e.left,i)).then(function(n){return n?Promise.resolve(r(e.right,i)):n})}();return Promise.resolve(v&&v.then?v.then(m):m(v))}case"MemberExpression":return Promise.resolve(n(e,i)).then(function(e){return e[1]});case"ThisExpression":return Promise.resolve(i);case"UnaryExpression":var h=u[e.operator];return Promise.resolve(r(e.argument,i)).then(function(e){return h.call(u,e)});default:return Promise.resolve(void 0)}}catch(e){return Promise.reject(e)}},n=function(e,n){try{return Promise.resolve(r(e.object,n)).then(function(t){return e.computed?Promise.resolve(r(e.property,n)).then(function(e){return[t,t[e]]}):[t,t[e.property.name]]})}catch(e){return Promise.reject(e)}},t=function(e,n){try{return Promise.resolve(Promise.all(e.map(function(e){return r(e,n)})))}catch(e){return Promise.reject(e)}},o={"||":function(e,r){return e||r},"&&":function(e,r){return e&&r},"|":function(e,r){return e|r},"^":function(e,r){return e^r},"&":function(e,r){return e&r},"==":function(e,r){return e==r},"!=":function(e,r){return e!=r},"===":function(e,r){return e===r},"!==":function(e,r){return e!==r},"<":function(e,r){return e<r},">":function(e,r){return e>r},"<=":function(e,r){return e<=r},">=":function(e,r){return e>=r},"<<":function(e,r){return e<<r},">>":function(e,r){return e>>r},">>>":function(e,r){return e>>>r},"+":function(e,r){return e+r},"-":function(e,r){return e-r},"*":function(e,r){return e*r},"/":function(e,r){return e/r},"%":function(e,r){return e%r}},u={"-":function(e){return-e},"+":function(e){return+e},"~":function(e){return~e},"!":function(e){return!e}};function i(e,r){return e.map(function(e){return c(e,r)})}function s(e,r){var n=c(e.object,r);return e.computed?[n,n[c(e.property,r)]]:[n,n[e.property.name]]}function c(e,r){switch(e.type){case"ArrayExpression":return i(e.elements,r);case"BinaryExpression":return o[e.operator](c(e.left,r),c(e.right,r));case"CallExpression":var n,t,a;if("MemberExpression"===e.callee.type?(n=(a=s(e.callee,r))[0],t=a[1]):t=c(e.callee,r),"function"!=typeof t)return;return t.apply(n,i(e.arguments,r));case"ConditionalExpression":return c(e.test,r)?c(e.consequent,r):c(e.alternate,r);case"Identifier":return r[e.name];case"Literal":return e.value;case"LogicalExpression":return"||"===e.operator?c(e.left,r)||c(e.right,r):"&&"===e.operator?c(e.left,r)&&c(e.right,r):o[e.operator](c(e.left,r),c(e.right,r));case"MemberExpression":return s(e,r)[1];case"ThisExpression":return r;case"UnaryExpression":return u[e.operator](c(e.argument,r));default:return}}function a(r){return c.bind(null,e(r))}function l(n){return r.bind(null,e(n))}function f(r,n){e.addUnaryOp(r),u[r]=n}function p(r,n){e.addBinaryOp(r),o[r]=n}export{c as eval,r as evalAsync,a as compile,l as compileAsync,f as addUnaryOp,p as addBinaryOp};
import e from"jsep";export{default as parse}from"jsep";var r=function e(r,o){try{var s,c=r;switch(c.type){case"ArrayExpression":return Promise.resolve(t(c.elements,o));case"BinaryExpression":return Promise.resolve(Promise.all([e(c.left,o),e(c.right,o)])).then(function(e){return u[c.operator](e[0],e[1])});case"CallExpression":var a,l,f,p=function(){if("function"==typeof l){var e=l,r=e.apply,n=a;return Promise.resolve(t(c.arguments,o)).then(function(t){return Promise.resolve(r.call(e,n,t))})}},m="MemberExpression"===c.callee.type?Promise.resolve(n(c.callee,o)).then(function(e){a=(f=e)[0],l=f[1]}):Promise.resolve(e(c.callee,o)).then(function(e){l=e});return Promise.resolve(m&&m.then?m.then(p):p());case"ConditionalExpression":return Promise.resolve(e(c.test,o)).then(function(r){return Promise.resolve(e(r?c.consequent:c.alternate,o))});case"Identifier":return Promise.resolve(o[c.name]);case"Literal":return Promise.resolve(c.value);case"LogicalExpression":var v=function(r){return s?r:Promise.resolve(Promise.all([e(c.left,o),e(c.right,o)])).then(function(e){return u[c.operator](e[0],e[1])})},h="||"===c.operator?(s=1,Promise.resolve(e(c.left,o)).then(function(r){return r||Promise.resolve(e(c.right,o))})):function(){if("&&"===c.operator)return s=1,Promise.resolve(e(c.left,o)).then(function(r){return r?Promise.resolve(e(c.right,o)):r})}();return Promise.resolve(h&&h.then?h.then(v):v(h));case"MemberExpression":return Promise.resolve(n(c,o)).then(function(e){return e[1]});case"ThisExpression":return Promise.resolve(o);case"UnaryExpression":var P=i[c.operator];return Promise.resolve(e(c.argument,o)).then(function(e){return P.call(i,e)});default:return Promise.resolve(void 0)}}catch(e){return Promise.reject(e)}},n=function(e,n){try{return Promise.resolve(r(e.object,n)).then(function(t){return e.computed?Promise.resolve(r(e.property,n)).then(function(e){return[t,t[e]]}):[t,t[e.property.name]]})}catch(e){return Promise.reject(e)}},t=function(e,n){try{return Promise.resolve(Promise.all(e.map(function(e){return r(e,n)})))}catch(e){return Promise.reject(e)}},o={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},u={"||":function(e,r){return e||r},"&&":function(e,r){return e&&r},"|":function(e,r){return e|r},"^":function(e,r){return e^r},"&":function(e,r){return e&r},"==":function(e,r){return e==r},"!=":function(e,r){return e!=r},"===":function(e,r){return e===r},"!==":function(e,r){return e!==r},"<":function(e,r){return e<r},">":function(e,r){return e>r},"<=":function(e,r){return e<=r},">=":function(e,r){return e>=r},"<<":function(e,r){return e<<r},">>":function(e,r){return e>>r},">>>":function(e,r){return e>>>r},"+":function(e,r){return e+r},"-":function(e,r){return e-r},"*":function(e,r){return e*r},"/":function(e,r){return e/r},"%":function(e,r){return e%r}},i={"-":function(e){return-e},"+":function(e){return+e},"~":function(e){return~e},"!":function(e){return!e}};function s(e,r){return e.map(function(e){return a(e,r)})}function c(e,r){var n=a(e.object,r);return e.computed?[n,n[a(e.property,r)]]:[n,n[e.property.name]]}function a(e,r){var n=e;switch(n.type){case"ArrayExpression":return s(n.elements,r);case"BinaryExpression":return u[n.operator](a(n.left,r),a(n.right,r));case"CallExpression":var t,o,l;if("MemberExpression"===n.callee.type?(t=(l=c(n.callee,r))[0],o=l[1]):o=a(n.callee,r),"function"!=typeof o)return;return o.apply(t,s(n.arguments,r));case"ConditionalExpression":return a(n.test,r)?a(n.consequent,r):a(n.alternate,r);case"Identifier":return r[n.name];case"Literal":return n.value;case"LogicalExpression":return"||"===n.operator?a(n.left,r)||a(n.right,r):"&&"===n.operator?a(n.left,r)&&a(n.right,r):u[n.operator](a(n.left,r),a(n.right,r));case"MemberExpression":return c(n,r)[1];case"ThisExpression":return r;case"UnaryExpression":return i[n.operator](a(n.argument,r));default:return}}function l(r){return a.bind(null,e(r))}function f(n){return r.bind(null,e(n))}function p(r,n){e.addUnaryOp(r),i[r]=n}function m(r,n,t){t?(e.addBinaryOp(r,n),u[r]=t):(e.addBinaryOp(r,o[r]||1),u[r]=n)}export{m as addBinaryOp,p as addUnaryOp,l as compile,f as compileAsync,a as eval,r as evalAsync};
//# sourceMappingURL=expression-eval.module.js.map

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("jsep")):"function"==typeof define&&define.amd?define(["exports","jsep"],r):r(e.expressionEval={},e.jsep)}(this,function(e,r){r=r&&r.hasOwnProperty("default")?r.default:r;var n=function(e,r){try{var s=!1;function c(){if("function"==typeof l){var n=l,t=n.apply,i=a;return Promise.resolve(o(e.arguments,r)).then(function(e){return Promise.resolve(t.call(n,i,e))})}}switch(e.type){case"ArrayExpression":return Promise.resolve(o(e.elements,r));case"BinaryExpression":return Promise.resolve(Promise.all([n(e.left,r),n(e.right,r)])).then(function(r){return i[e.operator](r[0],r[1])});case"CallExpression":var a,l,f,p="MemberExpression"===e.callee.type?Promise.resolve(t(e.callee,r)).then(function(e){a=(f=e)[0],l=f[1]}):Promise.resolve(n(e.callee,r)).then(function(e){l=e});return Promise.resolve(p&&p.then?p.then(c):c());case"ConditionalExpression":return Promise.resolve(n(e.test,r)).then(function(t){return Promise.resolve(n(t?e.consequent:e.alternate,r))});case"Identifier":return Promise.resolve(r[e.name]);case"Literal":return Promise.resolve(e.value);case"LogicalExpression":{function m(t){return s?t:Promise.resolve(Promise.all([n(e.left,r),n(e.right,r)])).then(function(r){return i[e.operator](r[0],r[1])})}var v="||"===e.operator?(s=!0,Promise.resolve(n(e.left,r)).then(function(t){return t||Promise.resolve(n(e.right,r))})):function(){if("&&"===e.operator)return s=!0,Promise.resolve(n(e.left,r)).then(function(t){return t?Promise.resolve(n(e.right,r)):t})}();return Promise.resolve(v&&v.then?v.then(m):m(v))}case"MemberExpression":return Promise.resolve(t(e,r)).then(function(e){return e[1]});case"ThisExpression":return Promise.resolve(r);case"UnaryExpression":var h=u[e.operator];return Promise.resolve(n(e.argument,r)).then(function(e){return h.call(u,e)});default:return Promise.resolve(void 0)}}catch(e){return Promise.reject(e)}},t=function(e,r){try{return Promise.resolve(n(e.object,r)).then(function(t){return e.computed?Promise.resolve(n(e.property,r)).then(function(e){return[t,t[e]]}):[t,t[e.property.name]]})}catch(e){return Promise.reject(e)}},o=function(e,r){try{return Promise.resolve(Promise.all(e.map(function(e){return n(e,r)})))}catch(e){return Promise.reject(e)}},i={"||":function(e,r){return e||r},"&&":function(e,r){return e&&r},"|":function(e,r){return e|r},"^":function(e,r){return e^r},"&":function(e,r){return e&r},"==":function(e,r){return e==r},"!=":function(e,r){return e!=r},"===":function(e,r){return e===r},"!==":function(e,r){return e!==r},"<":function(e,r){return e<r},">":function(e,r){return e>r},"<=":function(e,r){return e<=r},">=":function(e,r){return e>=r},"<<":function(e,r){return e<<r},">>":function(e,r){return e>>r},">>>":function(e,r){return e>>>r},"+":function(e,r){return e+r},"-":function(e,r){return e-r},"*":function(e,r){return e*r},"/":function(e,r){return e/r},"%":function(e,r){return e%r}},u={"-":function(e){return-e},"+":function(e){return+e},"~":function(e){return~e},"!":function(e){return!e}};function s(e,r){return e.map(function(e){return a(e,r)})}function c(e,r){var n=a(e.object,r);return e.computed?[n,n[a(e.property,r)]]:[n,n[e.property.name]]}function a(e,r){switch(e.type){case"ArrayExpression":return s(e.elements,r);case"BinaryExpression":return i[e.operator](a(e.left,r),a(e.right,r));case"CallExpression":var n,t,o;if("MemberExpression"===e.callee.type?(n=(o=c(e.callee,r))[0],t=o[1]):t=a(e.callee,r),"function"!=typeof t)return;return t.apply(n,s(e.arguments,r));case"ConditionalExpression":return a(e.test,r)?a(e.consequent,r):a(e.alternate,r);case"Identifier":return r[e.name];case"Literal":return e.value;case"LogicalExpression":return"||"===e.operator?a(e.left,r)||a(e.right,r):"&&"===e.operator?a(e.left,r)&&a(e.right,r):i[e.operator](a(e.left,r),a(e.right,r));case"MemberExpression":return c(e,r)[1];case"ThisExpression":return r;case"UnaryExpression":return u[e.operator](a(e.argument,r));default:return}}e.parse=r,e.eval=a,e.evalAsync=n,e.compile=function(e){return a.bind(null,r(e))},e.compileAsync=function(e){return n.bind(null,r(e))},e.addUnaryOp=function(e,n){r.addUnaryOp(e),u[e]=n},e.addBinaryOp=function(e,n){r.addBinaryOp(e),i[e]=n}});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("jsep")):"function"==typeof define&&define.amd?define(["exports","jsep"],r):r((e||self).expressionEval={},e.jsep)}(this,function(e,r){function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=n(r),o=function e(r,n){try{var t,o=r;switch(o.type){case"ArrayExpression":return Promise.resolve(i(o.elements,n));case"BinaryExpression":return Promise.resolve(Promise.all([e(o.left,n),e(o.right,n)])).then(function(e){return a[o.operator](e[0],e[1])});case"CallExpression":var s,l,f,p=function(){if("function"==typeof l){var e=l,r=e.apply,t=s;return Promise.resolve(i(o.arguments,n)).then(function(n){return Promise.resolve(r.call(e,t,n))})}},m="MemberExpression"===o.callee.type?Promise.resolve(u(o.callee,n)).then(function(e){s=(f=e)[0],l=f[1]}):Promise.resolve(e(o.callee,n)).then(function(e){l=e});return Promise.resolve(m&&m.then?m.then(p):p());case"ConditionalExpression":return Promise.resolve(e(o.test,n)).then(function(r){return Promise.resolve(e(r?o.consequent:o.alternate,n))});case"Identifier":return Promise.resolve(n[o.name]);case"Literal":return Promise.resolve(o.value);case"LogicalExpression":var d=function(r){return t?r:Promise.resolve(Promise.all([e(o.left,n),e(o.right,n)])).then(function(e){return a[o.operator](e[0],e[1])})},v="||"===o.operator?(t=1,Promise.resolve(e(o.left,n)).then(function(r){return r||Promise.resolve(e(o.right,n))})):function(){if("&&"===o.operator)return t=1,Promise.resolve(e(o.left,n)).then(function(r){return r?Promise.resolve(e(o.right,n)):r})}();return Promise.resolve(v&&v.then?v.then(d):d(v));case"MemberExpression":return Promise.resolve(u(o,n)).then(function(e){return e[1]});case"ThisExpression":return Promise.resolve(n);case"UnaryExpression":var h=c[o.operator];return Promise.resolve(e(o.argument,n)).then(function(e){return h.call(c,e)});default:return Promise.resolve(void 0)}}catch(e){return Promise.reject(e)}},u=function(e,r){try{return Promise.resolve(o(e.object,r)).then(function(n){return e.computed?Promise.resolve(o(e.property,r)).then(function(e){return[n,n[e]]}):[n,n[e.property.name]]})}catch(e){return Promise.reject(e)}},i=function(e,r){try{return Promise.resolve(Promise.all(e.map(function(e){return o(e,r)})))}catch(e){return Promise.reject(e)}},s={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},a={"||":function(e,r){return e||r},"&&":function(e,r){return e&&r},"|":function(e,r){return e|r},"^":function(e,r){return e^r},"&":function(e,r){return e&r},"==":function(e,r){return e==r},"!=":function(e,r){return e!=r},"===":function(e,r){return e===r},"!==":function(e,r){return e!==r},"<":function(e,r){return e<r},">":function(e,r){return e>r},"<=":function(e,r){return e<=r},">=":function(e,r){return e>=r},"<<":function(e,r){return e<<r},">>":function(e,r){return e>>r},">>>":function(e,r){return e>>>r},"+":function(e,r){return e+r},"-":function(e,r){return e-r},"*":function(e,r){return e*r},"/":function(e,r){return e/r},"%":function(e,r){return e%r}},c={"-":function(e){return-e},"+":function(e){return+e},"~":function(e){return~e},"!":function(e){return!e}};function l(e,r){return e.map(function(e){return p(e,r)})}function f(e,r){var n=p(e.object,r);return e.computed?[n,n[p(e.property,r)]]:[n,n[e.property.name]]}function p(e,r){var n=e;switch(n.type){case"ArrayExpression":return l(n.elements,r);case"BinaryExpression":return a[n.operator](p(n.left,r),p(n.right,r));case"CallExpression":var t,o,u;if("MemberExpression"===n.callee.type?(t=(u=f(n.callee,r))[0],o=u[1]):o=p(n.callee,r),"function"!=typeof o)return;return o.apply(t,l(n.arguments,r));case"ConditionalExpression":return p(n.test,r)?p(n.consequent,r):p(n.alternate,r);case"Identifier":return r[n.name];case"Literal":return n.value;case"LogicalExpression":return"||"===n.operator?p(n.left,r)||p(n.right,r):"&&"===n.operator?p(n.left,r)&&p(n.right,r):a[n.operator](p(n.left,r),p(n.right,r));case"MemberExpression":return f(n,r)[1];case"ThisExpression":return r;case"UnaryExpression":return c[n.operator](p(n.argument,r));default:return}}Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return t.default}}),e.addBinaryOp=function(e,r,n){n?(t.default.addBinaryOp(e,r),a[e]=n):(t.default.addBinaryOp(e,s[e]||1),a[e]=r)},e.addUnaryOp=function(e,r){t.default.addUnaryOp(e),c[e]=r},e.compile=function(e){return p.bind(null,t.default(e))},e.compileAsync=function(e){return o.bind(null,t.default(e))},e.eval=p,e.evalAsync=o});
//# sourceMappingURL=expression-eval.umd.js.map
{
"name": "expression-eval",
"version": "3.1.2",
"version": "4.0.0",
"description": "JavaScript expression parsing and evaluation.",
"source": "index.js",
"source": "index.ts",
"main": "dist/expression-eval.js",
"module": "dist/expression-eval.module.js",
"unpkg": "dist/expression-eval.umd.js",
"types": "index.d.ts",
"types": "dist/index.d.ts",
"repository": {

@@ -17,6 +17,4 @@ "type": "git",

"build": "microbundle",
"test": "node test.js",
"lint": "cp test.js index.test-d.ts && npx tsd; rm index.test-d.ts",
"clean": "git checkout -- dist",
"preversion": "npm run build && npm run lint && npm run test && git add -A dist",
"test": "node test.js | tap-spec",
"preversion": "npm run build && npm test",
"postversion": "git push && git push --tags && npm publish"

@@ -41,4 +39,19 @@ },

"devDependencies": {
"microbundle": "^0.11.0"
}
"@types/tape": "^4.13.0",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"eslint": "^7.17.0",
"microbundle": "^0.13.0",
"source-map-support": "^0.5.19",
"tap-spec": "^5.0.0",
"tape": "^5.1.1",
"typescript": "^4.1.3"
},
"files": [
"dist/",
"index.js",
"README.md",
"LICENSE",
"package.json",
"package-lock.json"
]
}

@@ -6,3 +6,3 @@ # expression-eval

[![License](https://img.shields.io/badge/license-MIT-007ec6.svg)](https://github.com/donmccurdy/expression-eval/blob/master/LICENSE)
[![Build Status](https://travis-ci.com/donmccurdy/expression-eval.svg?branch=master)](https://travis-ci.com/donmccurdy/expression-eval)
[![CI](https://github.com/donmccurdy/expression-eval/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/donmccurdy/expression-eval/actions?query=workflow%3ACI)

@@ -9,0 +9,0 @@ JavaScript expression parsing and evaluation.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc