move util.getIds to types.getIds
This commit is contained in:
@@ -7,7 +7,7 @@ var fs = require("fs");
|
||||
var t = require("./types");
|
||||
var _ = require("lodash");
|
||||
|
||||
_.extend(estraverse.VisitorKeys, traverse.VISITOR_KEYS);
|
||||
_.extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
|
||||
|
||||
exports.inherits = util.inherits;
|
||||
|
||||
@@ -46,31 +46,6 @@ exports.isAbsolute = function (loc) {
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.getIds = function (node) {
|
||||
var search = [node];
|
||||
var ids = [];
|
||||
|
||||
while (search.length) {
|
||||
var id = search.shift();
|
||||
|
||||
if (t.isIdentifier(id)) {
|
||||
ids.push(id.name);
|
||||
} else if (t.isArrayPattern(id)) {
|
||||
_.each(id.elements, function (elem) {
|
||||
search.push(elem);
|
||||
});
|
||||
} else if (t.isObjectPattern(id)) {
|
||||
_.each(id.properties, function (prop) {
|
||||
search.push(prop.value);
|
||||
});
|
||||
} else {
|
||||
throw new Error("unknown node " + id.type);
|
||||
}
|
||||
}
|
||||
|
||||
return ids;
|
||||
};
|
||||
|
||||
exports.canCompile = function (filename) {
|
||||
var ext = path.extname(filename);
|
||||
return _.contains([".js", ".es6"], ext);
|
||||
|
||||
Reference in New Issue
Block a user