add util.object that we'll use to construct objects to avoid prototype collisions

This commit is contained in:
Sebastian McKenzie
2015-01-22 18:39:31 +11:00
parent 115509653f
commit 8678917e2a
3 changed files with 9 additions and 5 deletions

View File

@@ -28,7 +28,7 @@ var exportsVisitor = {
};
DefaultFormatter.prototype.getLocalExports = function () {
var localExports = {};
var localExports = util.object();
traverse(this.file.ast, exportsVisitor, this.file.scope, localExports);
return localExports;
};
@@ -42,7 +42,7 @@ var importsVisitor = {
};
DefaultFormatter.prototype.getLocalImports = function () {
var localImports = {};
var localImports = util.object();
traverse(this.file.ast, importsVisitor, this.file.scope, localImports);
return localImports;
};

View File

@@ -82,9 +82,9 @@ function LetScoping(loopParent, block, parent, scope, file) {
this.block = block;
this.file = file;
this.outsideLetReferences = {};
this.outsideLetReferences = util.object();
this.hasLetReferences = false;
this.letReferences = block._letReferences = {};
this.letReferences = block._letReferences = util.object();
this.body = [];
}
@@ -150,7 +150,7 @@ LetScoping.prototype.remap = function () {
// we have to check if any of our let variables collide with
// those in upper scopes and then if they do, generate a uid
// for them and replace all references with it
var remaps = {};
var remaps = util.object();
for (var key in letRefs) {
// just an Identifier node we collected in `getLetReferences`

View File

@@ -25,6 +25,10 @@ exports.isInteger = function (i) {
return _.isNumber(i) && i % 1 === 0;
};
exports.object = function () {
return Object.create(null);
};
exports.resolve = function (loc) {
try {
return require.resolve(loc);