From 586b956349e97b5e48fc01e7e5a2acec102c6233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Sieroci=C5=84ski?= Date: Wed, 25 Mar 2020 08:11:14 +0100 Subject: [PATCH] Custom logical and/or --- dist/meval.js | 18 +++++++++++++++--- dist/meval.min.js | 4 ++-- package-lock.json | 2 +- package.json | 2 +- src/operators/LogicalAnd.js | 7 ++++++- src/operators/LogicalOr.js | 7 ++++++- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/dist/meval.js b/dist/meval.js index 913b36d..c362466 100644 --- a/dist/meval.js +++ b/dist/meval.js @@ -1,4 +1,4 @@ -/* meval v1.0.2 | Copyright 2020 (c) Marek Sierociński| https://github.com/marverix/meval/blob/master/LICENSE */ +/* meval v1.0.3 | Copyright 2020 (c) Marek Sierociński| https://github.com/marverix/meval/blob/master/LICENSE */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : @@ -1325,7 +1325,13 @@ _createClass(LogicalAndOperator, [{ key: "_execute", value: function _execute(leftSide, rightSide, context) { - return this.resolveSide(leftSide, context) && this.resolveSide(rightSide, context); + var leftSideResolved = this.resolveSide(leftSide, context); + + if (!leftSideResolved) { + return false; + } else { + return this.resolveSide(rightSide, context); + } } }]); @@ -1349,7 +1355,13 @@ _createClass(LogicalOrOperator, [{ key: "_execute", value: function _execute(leftSide, rightSide, context) { - return this.resolveSide(leftSide, context) || this.resolveSide(rightSide, context); + var leftSideResolved = this.resolveSide(leftSide, context); + + if (leftSideResolved) { + return true; + } else { + return this.resolveSide(rightSide, context); + } } }]); diff --git a/dist/meval.min.js b/dist/meval.min.js index 86f0e12..1e5c2ef 100644 --- a/dist/meval.min.js +++ b/dist/meval.min.js @@ -1,2 +1,2 @@ -/* meval v1.0.2 | Copyright 2020 (c) Marek Sierociński| https://github.com/marverix/meval/blob/master/LICENSE */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).meval=e()}(this,function(){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n=this.resolveSide(e,n)}}]),t}();st.$pattern=/^>=/;var ot=st,at=function(){function t(){return u(this,t),c(this,a(t).call(this))}return o(t,z),s(t,[{key:"_execute",value:function(t,e,n){return this.resolveSide(t,n)<=this.resolveSide(e,n)}}]),t}();at.$pattern=/^<=/;var ct=at,lt=function(){function t(){return u(this,t),c(this,a(t).call(this))}return o(t,z),s(t,[{key:"_execute",value:function(t,e,n){return this.resolveSide(t,n)>this.resolveSide(e,n)}}]),t}();lt.$pattern=/^>/;var ht=lt,ft=function(){function t(){return u(this,t),c(this,a(t).call(this))}return o(t,z),s(t,[{key:"_execute",value:function(t,e,n){return this.resolveSide(t,n)=this.resolveSide(e,n)}}]),t}();st.$pattern=/^>=/;var ot=st,at=function(){function t(){return u(this,t),c(this,a(t).call(this))}return o(t,z),s(t,[{key:"_execute",value:function(t,e,n){return this.resolveSide(t,n)<=this.resolveSide(e,n)}}]),t}();at.$pattern=/^<=/;var ct=at,lt=function(){function t(){return u(this,t),c(this,a(t).call(this))}return o(t,z),s(t,[{key:"_execute",value:function(t,e,n){return this.resolveSide(t,n)>this.resolveSide(e,n)}}]),t}();lt.$pattern=/^>/;var ht=lt,ft=function(){function t(){return u(this,t),c(this,a(t).call(this))}return o(t,z),s(t,[{key:"_execute",value:function(t,e,n){return this.resolveSide(t,n)