static-eval
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -76,2 +76,8 @@ var unparse = require('escodegen').generate; | ||
} | ||
else if (node.type === 'ThisExpression') { | ||
if ({}.hasOwnProperty.call(vars, 'this')) { | ||
return vars['this']; | ||
} | ||
else return FAIL; | ||
} | ||
else if (node.type === 'CallExpression') { | ||
@@ -78,0 +84,0 @@ var callee = walk(node.callee); |
{ | ||
"name": "static-eval", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "evaluate statically-analyzable expressions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -54,1 +54,12 @@ var test = require('tape'); | ||
}); | ||
test('evaluate this', function(t) { | ||
t.plan(1); | ||
var src = 'this.x + this.y.z'; | ||
var ast = parse(src).body[0].expression; | ||
var res = evaluate(ast, { | ||
'this': { x: 1, y: { z: 100 } } | ||
}); | ||
t.equal(res, 101); | ||
}); |
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
12391
242