add-variable-declarations
Advanced tools
Comparing version
@@ -49,7 +49,5 @@ import MagicString from 'magic-string'; | ||
this.names = new Set(); | ||
this.globals = new Map(); | ||
this.scope = scope; | ||
this.parentState = parentState; | ||
this.collectGlobals(scope); | ||
} | ||
@@ -63,8 +61,2 @@ | ||
} | ||
var global = this.getGlobal(node.name); | ||
if (global && global.start < node.start) { | ||
// Anything that is referenced before being assigned is really, truly, a | ||
// global and should not be converted to a local variable. | ||
return; | ||
} | ||
this.bindingIdentifiers.add(node); | ||
@@ -90,28 +82,2 @@ this.names.add(node.name); | ||
} | ||
}, { | ||
key: 'getGlobal', | ||
value: function getGlobal(name) { | ||
var state = this; | ||
do { | ||
var global = state.globals.get(name); | ||
if (global) { | ||
return global; | ||
} | ||
} while (state = state.parentState); | ||
return null; | ||
} | ||
/** | ||
* @private | ||
*/ | ||
}, { | ||
key: 'collectGlobals', | ||
value: function collectGlobals(scope) { | ||
var _this = this; | ||
Object.keys(scope.globals).forEach(function (name) { | ||
return _this.globals.set(name, scope.globals[name]); | ||
}); | ||
} | ||
}]); | ||
@@ -118,0 +84,0 @@ return TraverseState; |
@@ -54,7 +54,5 @@ (function (global, factory) { | ||
this.names = new Set(); | ||
this.globals = new Map(); | ||
this.scope = scope; | ||
this.parentState = parentState; | ||
this.collectGlobals(scope); | ||
} | ||
@@ -68,8 +66,2 @@ | ||
} | ||
var global = this.getGlobal(node.name); | ||
if (global && global.start < node.start) { | ||
// Anything that is referenced before being assigned is really, truly, a | ||
// global and should not be converted to a local variable. | ||
return; | ||
} | ||
this.bindingIdentifiers.add(node); | ||
@@ -95,28 +87,2 @@ this.names.add(node.name); | ||
} | ||
}, { | ||
key: 'getGlobal', | ||
value: function getGlobal(name) { | ||
var state = this; | ||
do { | ||
var global = state.globals.get(name); | ||
if (global) { | ||
return global; | ||
} | ||
} while (state = state.parentState); | ||
return null; | ||
} | ||
/** | ||
* @private | ||
*/ | ||
}, { | ||
key: 'collectGlobals', | ||
value: function collectGlobals(scope) { | ||
var _this = this; | ||
Object.keys(scope.globals).forEach(function (name) { | ||
return _this.globals.set(name, scope.globals[name]); | ||
}); | ||
} | ||
}]); | ||
@@ -123,0 +89,0 @@ return TraverseState; |
{ | ||
"name": "add-variable-declarations", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Add variable declarations for global assignments.", | ||
@@ -50,3 +50,6 @@ "main": "dist/add-variable-declarations.umd.js", | ||
"magic-string": "^0.10.2" | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
} |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
24700
-11.01%4
-20%649
-8.72%1
Infinity%0
-100%