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.15 to 0.0.16

75

escope.js

@@ -64,3 +64,3 @@ /*

scopes,
directive;
options;

@@ -107,2 +107,33 @@ Syntax = estraverse.Syntax;

function defaultOptions() {
return {
optimistic: false,
directive: false
};
};
function updateDeeply(target, override) {
var key, val;
function isHashObject(target) {
return typeof target === 'object' && target instanceof Object && !(target instanceof RegExp);
}
for (key in override) {
if (override.hasOwnProperty(key)) {
val = override[key];
if (isHashObject(val)) {
if (isHashObject(target[key])) {
updateDeeply(target[key], val);
} else {
target[key] = updateDeeply({}, val);
}
} else {
target[key] = val;
}
}
}
return target;
}
function Reference(ident, scope, flag, writeExpr, maybeImplicitGlobal) {

@@ -182,3 +213,3 @@ this.identifier = ident;

if (directive) {
if (options.directive) {
for (i = 0, iz = body.body.length; i < iz; ++i) {

@@ -279,3 +310,3 @@ stmt = body.body[i];

// Because if this is global environment, upper is null
if (!this.dynamic) {
if (!this.dynamic || options.optimistic) {
// static resolve

@@ -305,13 +336,18 @@ 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
});
}
if (this.type === 'global') {
for (i = 0, iz = this.left.length; i < iz; ++i) {
// create an implicit global variable from assignment expression
ref = this.left[i];
if (ref.__maybeImplicitGlobal) {
node = ref.__maybeImplicitGlobal;
this.__define(node.left, {
type: Variable.ImplicitGlobalVariable,
name: node.left,
node: node
});
}

@@ -343,4 +379,5 @@ }

Scope.prototype.__delegateToUpperScope = function __delegateToUpperScope(ref) {
assert(this.upper, 'upper should be here');
this.upper.left.push(ref);
if (this.upper) {
this.upper.left.push(ref);
}
this.through.push(ref);

@@ -548,10 +585,9 @@ };

function analyze(tree, options) {
function analyze(tree, providedOptions) {
var resultScopes;
options = options || {};
options = updateDeeply(defaultOptions(), providedOptions);
resultScopes = scopes = [];
currentScope = null;
globalScope = null;
directive = options.directive;

@@ -804,2 +840,3 @@ // attach scope and collect / resolve names

scopes = null;
options = null;

@@ -809,3 +846,3 @@ return new ScopeManager(resultScopes);

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

@@ -812,0 +849,0 @@ exports.Variable = Variable;

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

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

@@ -9,0 +9,0 @@ "node": ">=0.4.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