Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

static-eval

Package Overview
Dependencies
Maintainers
40
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

static-eval - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

CHANGELOG.md

22

index.js

@@ -43,2 +43,21 @@ var unparse = require('escodegen').generate;

node.type === 'LogicalExpression') {
var op = node.operator;
if (op === '&&') {
var l = walk(node.left);
if (l === FAIL) return FAIL;
if (!l) return l;
var r = walk(node.right);
if (r === FAIL) return FAIL;
return r;
}
else if (op === '||') {
var l = walk(node.left);
if (l === FAIL) return FAIL;
if (l) return l;
var r = walk(node.right);
if (r === FAIL) return FAIL;
return r;
}
var l = walk(node.left);

@@ -49,3 +68,2 @@ if (l === FAIL) return FAIL;

var op = node.operator;
if (op === '==') return l == r;

@@ -67,4 +85,2 @@ if (op === '===') return l === r;

if (op === '^') return l ^ r;
if (op === '&&') return l && r;
if (op === '||') return l || r;

@@ -71,0 +87,0 @@ return FAIL;

92

package.json
{
"name": "static-eval",
"version": "2.0.3",
"description": "evaluate statically-analyzable expressions",
"main": "index.js",
"dependencies": {
"escodegen": "^1.11.1"
},
"devDependencies": {
"esprima": "^3.1.3",
"tape": "^4.10.1"
},
"scripts": {
"test": "tape test/*.js"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/8..latest",
"ff/latest",
"chrome/latest",
"opera/latest",
"safari/latest"
]
},
"repository": {
"type": "git",
"url": "git://github.com/substack/static-eval.git"
},
"homepage": "https://github.com/substack/static-eval",
"keywords": [
"static",
"eval",
"expression",
"esprima",
"ast",
"abstract",
"syntax",
"tree",
"analysis"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"license": "MIT"
"name": "static-eval",
"version": "2.0.4",
"description": "evaluate statically-analyzable expressions",
"main": "index.js",
"dependencies": {
"escodegen": "^1.11.1"
},
"devDependencies": {
"esprima": "^3.1.3",
"tape": "^4.10.1"
},
"scripts": {
"test": "tape test/*.js"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/8..latest",
"ff/latest",
"chrome/latest",
"opera/latest",
"safari/latest"
]
},
"repository": {
"type": "git",
"url": "git://github.com/substack/static-eval.git"
},
"homepage": "https://github.com/substack/static-eval",
"keywords": [
"static",
"eval",
"expression",
"esprima",
"ast",
"abstract",
"syntax",
"tree",
"analysis"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"license": "MIT"
}

@@ -124,1 +124,27 @@ var test = require('tape');

});
test('short circuit evaluation AND', function(t) {
t.plan(1);
var variables = {
value: null
};
var src = 'value && value.func()';
var ast = parse(src).body[0].expression;
var res = evaluate(ast, variables);
t.equals(res, null);
})
test('short circuit evaluation OR', function(t) {
t.plan(1);
var fnInvoked = false;
var variables = {
value: true,
fn: function() { fnInvoked = true}
};
var src = 'value || fn()';
var ast = parse(src).body[0].expression;
evaluate(ast, variables);
t.equals(fnInvoked, false);
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc