expression-eval
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -86,2 +86,7 @@ var jsep = require('jsep'); | ||
case 'LogicalExpression': | ||
if (node.operator === '||') { | ||
return evaluate( node.left, context ) || evaluate( node.right, context ); | ||
} else if (node.operator === '&&') { | ||
return evaluate( node.left, context ) && evaluate( node.right, context ); | ||
} | ||
return binops[ node.operator ]( evaluate( node.left, context ), evaluate( node.right, context ) ); | ||
@@ -88,0 +93,0 @@ |
{ | ||
"name": "expression-eval", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "JavaScript expression parsing and evaluation.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# expression-eval | ||
[![Latest NPM release](https://img.shields.io/npm/v/expression-eval.svg)](https://www.npmjs.com/package/expression-eval) | ||
[![License](https://img.shields.io/npm/l/expression-eval.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) | ||
JavaScript expression parsing and evaluation. | ||
@@ -4,0 +8,0 @@ |
15
test.js
@@ -63,2 +63,8 @@ const expr = require('./'); | ||
// logical expression lazy evaluation | ||
{expr: 'true || throw()', expected: true }, | ||
{expr: 'false || true', expected: true }, | ||
{expr: 'false && throw()', expected: false }, | ||
{expr: 'true && false', expected: false }, | ||
// member expression | ||
@@ -96,3 +102,3 @@ {expr: 'foo.bar', expected: 'baz' }, | ||
isArray: Array.isArray, | ||
throw: () => { throw new Error('Should not be called.'); } | ||
}; | ||
@@ -105,3 +111,8 @@ | ||
tests++; | ||
var val = expr.compile(o.expr)(context); | ||
try { | ||
var val = expr.compile(o.expr)(context); | ||
} catch (e) { | ||
console.error(`Error: ${o.expr}, expected ${o.expected}`); | ||
throw e; | ||
} | ||
assert.equal(val, o.expected, `Failed: ${o.expr} (${val}) === ${o.expected}`); | ||
@@ -108,0 +119,0 @@ passed++; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11596
8
201
81