@marterrez/eval-expression
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -33,3 +33,2 @@ "use strict"; | ||
eval(exp, params = {}) { | ||
if (!exp || !exp.length || typeof exp !== 'string') return null; | ||
const ctx = { ...this.context, | ||
@@ -39,7 +38,8 @@ ...params | ||
if (this.opts.debgger) { | ||
console.log(`* ExpressionParser: eval ${exp}`); | ||
if (this.opts.debugger) { | ||
console.log(`* ExpressionParser: eval '${exp}'`); | ||
console.log(`* context = ${JSON.stringify(ctx, null, 2)}`); | ||
} | ||
if (!exp || !exp.length || typeof exp !== 'string') return null; | ||
const returnValue = exp.indexOf('return') > -1 ? exp : `return ${exp}`; // eslint-disable-next-line no-new-func | ||
@@ -46,0 +46,0 @@ |
{ | ||
"name": "@marterrez/eval-expression", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Small lib that allows to eval a string containing javascript code. It allows you do inject helper functions when evaluating the expression", | ||
@@ -13,3 +13,3 @@ "main": "dist/index.js", | ||
"test:unit": "jest", | ||
"test:watch": "jest --watch", | ||
"test:watch": "jest --watchAll", | ||
"coverage": "./node_modules/.bin/codecov" | ||
@@ -16,0 +16,0 @@ }, |
@@ -18,4 +18,2 @@ import * as lodash from 'lodash' | ||
eval (exp, params = {}) { | ||
if (!exp || !exp.length || typeof exp !== 'string') return null | ||
const ctx = { | ||
@@ -25,6 +23,7 @@ ...this.context, | ||
} | ||
if (this.opts.debgger) { | ||
console.log(`* ExpressionParser: eval ${exp}`) | ||
if (this.opts.debugger) { | ||
console.log(`* ExpressionParser: eval '${exp}'`) | ||
console.log(`* context = ${JSON.stringify(ctx, null, 2)}`) | ||
} | ||
if (!exp || !exp.length || typeof exp !== 'string') return null | ||
@@ -31,0 +30,0 @@ const returnValue = exp.indexOf('return') > -1 ? exp : `return ${exp}` |
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
5075