async.map(list, function(object, callback) {
async.series([
function(callback) {
console.log(\"1\");
var booltest = false;
// assumi
To make it logical, you could just rename error
to something like errorOrStop
:
var test = [1,2,3];
test.forEach( function(value) {
async.series([
function(callback){ something1(i, callback) },
function(callback){ something2(i, callback) }
],
function(errorOrStop) {
if (errorOrStop) {
if (errorOrStop instanceof Error) throw errorOrStop;
else return; // stops async for this index of `test`
}
console.log("done!");
});
});
function something1(i, callback) {
var stop = i<2;
callback(stop);
}
function something2(i, callback) {
var error = (i>2) ? new Error("poof") : null;
callback(error);
}