An array of functions, [fn1,fn2,...], each "returns" through a callback, passing an optional error. If an error is returned through the callback, then subsequent functions in the array should not be called.
// one example function
function fn1( callback ) {
<process>
if( error ) callback( errMsg );
else callback();
return;
}
// go through each function until fn returns error through callback
[fn1,fn2,fn3,...].forEach( function(fn){
<how to do this?>
} );
This can be solved other ways, but nonetheless would love the syntactic dexterity to use approach.
Can this be done?
as per correct answer:
[fn1,fn2,fn3,...].every( function(fn) {
var err;
fn.call( this, function(ferr) { err = ferr; } );
if( err ) {
nonblockAlert( err );
return false;
}
return true;
} );
seems this has room for simplification.
for me, much better approach to solve this type of problem - it's flatter, the logic more accessible.