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

expression-eval

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expression-eval - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

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}}module.exports={parse:r,eval:a,evalAsync:n,compile:function(e){return a.bind(null,r(e))},compileAsync:function(e){return n.bind(null,r(e))}};
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))};
//# sourceMappingURL=expression-eval.js.map

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

import e 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}}module.exports={parse:e,eval:c,evalAsync:r,compile:function(r){return c.bind(null,e(r))},compileAsync:function(n){return r.bind(null,e(n))}};
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))}export{c as eval,r as evalAsync,a as compile,l as compileAsync};
//# sourceMappingURL=expression-eval.module.js.map

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("jsep")):"function"==typeof define&&define.amd?define(["jsep"],r):r(e.jsep)}(this,function(e){e=e&&e.hasOwnProperty("default")?e.default:e;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}}module.exports={parse:e,eval:c,evalAsync:r,compile:function(r){return c.bind(null,e(r))},compileAsync:function(n){return r.bind(null,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.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,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}}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))}});
//# sourceMappingURL=expression-eval.umd.js.map

@@ -44,3 +44,3 @@ import jsep from 'jsep';

async function evaluateArrayAsync( list, context ) {
const res = await Promise.all(list.map((v) => evaluateAsync(v, context)));
const res = await Promise.all(list.map((v) => evalAsync(v, context)));
return res;

@@ -59,5 +59,5 @@ }

async function evaluateMemberAsync( node, context ) {
const object = await evaluateAsync(node.object, context);
const object = await evalAsync(node.object, context);
if ( node.computed) {
return [object, object[await evaluateAsync(node.property, context)]];
return [object, object[await evalAsync(node.property, context)]];
} else {

@@ -124,3 +124,3 @@ return [object, object[node.property.name]];

async function evaluateAsync( node, context ) {
async function evalAsync( node, context ) {

@@ -134,4 +134,4 @@ switch ( node.type ) {

const [left, right] = await Promise.all([
evaluateAsync( node.left, context ),
evaluateAsync( node.right, context )
evalAsync( node.left, context ),
evalAsync( node.right, context )
]);

@@ -148,3 +148,3 @@ return binops[ node.operator ]( left, right );

} else {
fn = await evaluateAsync( node.callee, context );
fn = await evalAsync( node.callee, context );
}

@@ -160,5 +160,5 @@ if (typeof fn !== 'function') {

case 'ConditionalExpression':
return (await evaluateAsync( node.test, context ))
? await evaluateAsync( node.consequent, context )
: await evaluateAsync( node.alternate, context );
return (await evalAsync( node.test, context ))
? await evalAsync( node.consequent, context )
: await evalAsync( node.alternate, context );

@@ -174,9 +174,9 @@ case 'Identifier':

return (
(await evaluateAsync( node.left, context )) ||
(await evaluateAsync( node.right, context ))
(await evalAsync( node.left, context )) ||
(await evalAsync( node.right, context ))
);
} else if (node.operator === '&&') {
return (
(await evaluateAsync( node.left, context )) &&
(await evaluateAsync( node.right, context ))
(await evalAsync( node.left, context )) &&
(await evalAsync( node.right, context ))
);

@@ -186,4 +186,4 @@ }

const [left, right] = await Promise.all([
evaluateAsync( node.left, context ),
evaluateAsync( node.right, context )
evalAsync( node.left, context ),
evalAsync( node.right, context )
]);

@@ -201,3 +201,3 @@

case 'UnaryExpression':
return unops[ node.operator ](await evaluateAsync( node.argument, context ));
return unops[ node.operator ](await evalAsync( node.argument, context ));

@@ -214,11 +214,11 @@ default:

function compileAsync(expression) {
return evaluateAsync.bind(null, jsep(expression));
return evalAsync.bind(null, jsep(expression));
}
module.exports = {
parse: jsep,
eval: evaluate,
evalAsync: evaluateAsync,
compile: compile,
compileAsync: compileAsync
export {
jsep as parse,
evaluate as eval,
evalAsync,
compile,
compileAsync
};
{
"name": "expression-eval",
"version": "3.0.3",
"version": "3.0.4",
"description": "JavaScript expression parsing and evaluation.",

@@ -5,0 +5,0 @@ "source": "index.js",

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc