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

escope

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

escope - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

Gruntfile.js

56

escope.js

@@ -106,3 +106,3 @@ /*

function Reference(ident, scope, flag, writeExpr) {
function Reference(ident, scope, flag, writeExpr, maybeImplicitGlobal) {
this.identifier = ident;

@@ -116,2 +116,3 @@ this.from = scope;

}
this.__maybeImplicitGlobal = maybeImplicitGlobal;
}

@@ -259,2 +260,8 @@

this.childScopes = [];
if (currentScope) {
currentScope.childScopes.push(this);
}
// RAII

@@ -269,3 +276,3 @@ currentScope = this;

Scope.prototype.__close = function __close() {
var i, iz, ref, current;
var i, iz, ref, current, node;

@@ -282,3 +289,3 @@ // Because if this is global environment, upper is null

} else {
// this is global / with / function with eval environment
// this is "global" / "with" / "function with eval" environment
if (this.type === 'with') {

@@ -299,5 +306,17 @@ for (i = 0, iz = this.left.length; i < iz; ++i) {

} while (current);
// create an implicit global variable from assignment expression
// TODO(Constellation): This is too conservative, "optimistic" option is needed.
if (this.type === 'global' && ref.__maybeImplicitGlobal) {
node = ref.__maybeImplicitGlobal;
this.__define(node.left, {
type: Variable.ImplicitGlobalVariable,
name: node.left,
node: node
});
}
}
}
}
this.left = null;

@@ -348,7 +367,7 @@ currentScope = this.upper;

Scope.prototype.__referencing = function __referencing(node, assign, writeExpr) {
Scope.prototype.__referencing = function __referencing(node, assign, writeExpr, maybeImplicitGlobal) {
var ref;
// because Array element may be null
if (node && node.type === Syntax.Identifier) {
ref = new Reference(node, this, assign || Reference.READ, writeExpr);
ref = new Reference(node, this, assign || Reference.READ, writeExpr, maybeImplicitGlobal);
this.references.push(ref);

@@ -533,6 +552,7 @@ this.left.push(ref);

options = options || {};
resultScopes = scopes = [];
currentScope = null,
currentScope = null;
globalScope = null;
directive = options && options.directive;
directive = options.directive;

@@ -549,13 +569,4 @@ // attach scope and collect / resolve names

case Syntax.AssignmentExpression:
//check for implicit global variable declaration
if (!currentScope.isStrict && node.left.name && !currentScope.isUsedName(node.left.name) && node.operator === '=') {
//create an implicit global variable from assignment expression
globalScope.__define(node.left, {
type: Variable.ImplicitGlobalVariable,
name: node.left,
node: node
});
}
if (node.operator === '=') {
currentScope.__referencing(node.left, Reference.WRITE, node.right);
currentScope.__referencing(node.left, Reference.WRITE, node.right, (!currentScope.isStrict && node.left.name != null) && node);
} else {

@@ -591,3 +602,3 @@ currentScope.__referencing(node.left, Reference.RW, node.right);

// check this is direct call to eval
if (node.callee.type === Syntax.Identifier && node.callee.name === 'eval') {
if (!options.ignoreEval && node.callee.type === Syntax.Identifier && node.callee.name === 'eval') {
currentScope.variableScope.__detectEval();

@@ -639,5 +650,5 @@ }

if (node.left.type === Syntax.VariableDeclaration) {
currentScope.__referencing(node.left.declarations[0].id, Reference.WRITE, null);
currentScope.__referencing(node.left.declarations[0].id, Reference.WRITE, null, false);
} else {
currentScope.__referencing(node.left, Reference.WRITE, null);
currentScope.__referencing(node.left, Reference.WRITE, null, (!currentScope.isStrict && node.left.name != null) && node);
}

@@ -767,3 +778,3 @@ currentScope.__referencing(node.right);

// initializer is found
currentScope.__referencing(decl.id, Reference.WRITE, decl.init);
currentScope.__referencing(decl.id, Reference.WRITE, decl.init, false);
currentScope.__referencing(decl.init);

@@ -794,2 +805,3 @@ }

});
assert(currentScope === null);

@@ -802,3 +814,3 @@ globalScope = null;

exports.version = '0.0.14';
exports.version = '0.0.15';
exports.Reference = Reference;

@@ -805,0 +817,0 @@ exports.Variable = Variable;

@@ -6,3 +6,3 @@ {

"main": "escope.js",
"version": "0.0.14",
"version": "0.0.15",
"engines": {

@@ -26,5 +26,10 @@ "node": ">=0.4.0"

"devDependencies": {
"mocha": "*",
"chai": "*",
"jshint": "~1.1.0"
"jshint": "~1.1.0",
"grunt-mocha-test": "~0.6.3",
"grunt-cli": "~0.1.9",
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.3",
"coffee-script": "~1.6.3",
"chai": "~1.7.2",
"esprima": "~1.0.3"
},

@@ -38,4 +43,6 @@ "licenses": [

"scripts": {
"test": "./node_modules/.bin/jshint escope.js && ./node_modules/.bin/mocha"
"test": "grunt travis",
"unit-test": "grunt test",
"lint": "grunt lint"
}
}

@@ -5,5 +5,21 @@ Escope ([escope](http://github.com/Constellation/escope)) is

[![Build Status](https://travis-ci.org/Constellation/escope.png?branch=master)](https://travis-ci.org/Constellation/escope)
### Demos and Tools
Demonstration is [here](http://mazurov.github.io/escope-demo/) by [Sasha Mazurov](https://github.com/mazurov) (twitter: [@mazurov](http://twitter.com/mazurov)). [issue](https://github.com/Constellation/escope/issues/14)
![Demo](https://f.cloud.github.com/assets/75759/462920/7aa6dd40-b4f5-11e2-9f07-9f4e8d0415f9.gif)
And there are tools constructed on Escope.
- [Esmangle](https://github.com/Constellation/esmangle) is a minifier / mangler / optimizer.
- [Eslevels](https://github.com/mazurov/eslevels) is a scope levels analyzer and [SublimeText plugin for scope context coloring](https://github.com/mazurov/sublime-levels) is constructed on it.
- [Estoggles](https://github.com/keeyipchan/esgoggles) is JavaScript code browser.
### License
Copyright (C) 2012 [Yusuke Suzuki](http://github.com/Constellation)
Copyright (C) 2012-2013 [Yusuke Suzuki](http://github.com/Constellation)
(twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.

@@ -10,0 +26,0 @@

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