static-eval
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -107,3 +107,7 @@ var unparse = require('escodegen').generate; | ||
else if (node.type === 'FunctionExpression') { | ||
return Function('return ' + unparse(node))(); | ||
var keys = Object.keys(vars); | ||
var vals = keys.map(function(key) { | ||
return vars[key]; | ||
}); | ||
return Function(keys.join(', '), 'return ' + unparse(node)).apply(null, vals); | ||
} | ||
@@ -110,0 +114,0 @@ else return FAIL; |
{ | ||
"name": "static-eval", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "evaluate statically-analyzable expressions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,2 +45,10 @@ var test = require('tape'); | ||
t.deepEqual(evaluate(ast), [2, 4, 6]); | ||
}) | ||
}); | ||
test('array methods with vars', function(t) { | ||
t.plan(1); | ||
var src = '[1, 2, 3].map(function(n) { return n * x })'; | ||
var ast = parse(src).body[0].expression; | ||
t.deepEqual(evaluate(ast, {x: 2}), [2, 4, 6]); | ||
}); |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
10383
181