Rompa el ciclo de async.each nested de javascript pero continúe con el ciclo principal

Tengo una matriz de matrices de objetos llamados 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"}] ] 

Quiero salir de este bucle async.each nested, pero continuar el bucle async.each principal.

 // 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 }); 

Una forma podría ser modificar la callback final para el interior de each () para buscar un objeto Error con una propiedad especial que indique que está saliendo antes y que no es un error real. Luego, dentro de su condicional, pase un objeto Error, con esa propiedad establecida, a la callback.

Ejemplo:

 // 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. var fakeErr = new Error(); fakeErr.break = true; return callback2(fakeErr); } // continue callback2(); }); }, function(err) { if (err && err.break) callback1(); else callback1(err); }); }, function(err) { if (err) return console.error(err); // success, all recipes iterated }); 
 // inner async.each (simplificated) async.each(subArray, function(theCurrentRecipe, callback2) { checkHREFS(theCurrentRecipe, function(thisRecipe) { if ('i have a conditional here') { // going to break out of this nested async.each return callback2({flag:true}); // It doesn't have to be an "new Error()" ;-) } // continue callback2(); }); }, function(msg) { if (msg && msg.flag) // Here CHECK THE FLAG callback1(); // all good!... we brake out of the loop! else callback1(msg); // process possible ERROR. });