support nested arrow functions - fixes #60
This commit is contained in:
@@ -29,6 +29,12 @@ var go = function (getBody, node, file) {
|
||||
|
||||
// traverse all child nodes of this function and find arguments and this
|
||||
traverse(node, function (node, parent) {
|
||||
if (_aliasFunction === "arrows") {
|
||||
if (traverse.isFunction(node) && node._aliasFunction !== "arrows") {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var getId;
|
||||
|
||||
if (node.type === "Identifier" && node.name === "arguments") {
|
||||
@@ -40,7 +46,7 @@ var go = function (getBody, node, file) {
|
||||
}
|
||||
|
||||
if (util.isReferenced(node, parent)) return getId();
|
||||
}, _aliasFunction === "arrows" && ["FunctionExpression", "FunctionDeclaration"]);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
13
test/fixtures/syntax/arrow-functions/nested/actual.js
vendored
Normal file
13
test/fixtures/syntax/arrow-functions/nested/actual.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
init() {
|
||||
return new Promise((resolve, reject) => {
|
||||
MongoClient.connect(config.mongodb, (err, db) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
this.db = db;
|
||||
resolve(this);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
14
test/fixtures/syntax/arrow-functions/nested/expected.js
vendored
Normal file
14
test/fixtures/syntax/arrow-functions/nested/expected.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
module.exports = {
|
||||
init: function() {
|
||||
var _this = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
MongoClient.connect(config.mongodb, function(err, db) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
_this.db = db;
|
||||
resolve(_this);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user