我有一个由对象组成的数组,名为recipesArray。
recipesArray = [ [{name = "the recipe name", url = "http://recipeurl.com"},
{name = "the other neame", url = "http://adifferenturl.com"},
{name = "another recipe", url = "http://anotherurl.com"}],
[{name = "the recipe name", url = "http://recipeurl.com"},
{name = "the other neame", url = "http://adifferenturl.com"},
{name = "another recipe", url = "http://anotherurl.com"}],
[{name = "the recipe name", url = "http://recipeurl.com"},
{name = "the other neame", url = "http://adifferenturl.com"},
{name = "another recipe", url = "http://anotherurl.com"}] ]
我希望能够跳出这个嵌套的async.each循环,但是继续主要的async.each循环。
// main async.each
async.each(recipes, function(subArray, callback1) {
// nested async.each
async.each(subArray, function(theCurrentRecipe, callback2) {
checkHREFS(theCurrentRecipe, function(thisRecipe) {
if ('i have a conditional here') {
// break out of this nested async.each,
// but continue the main async.each.
} else {
// continue
}
callback2();
});
}, callback1);
}, function(err) {
if (err) {
return console.error(err);
// success, all recipes iterated
});
async
模块,实际上我在需要提前中断async
模块方法时会使用这种模式。 - mscdex