Say I have a function as follows:
var randomFn = function(){
var response = '';
async.whilst(
// Test
function(){
return i < 5;
},
// Iteratee
function(callback){
// Random code that sets response to '5' after some attempts;
},
// Callback
function(err, n){
// Runs if error is encountered or iteratee stopped
}
);
return response;
}
The async module while allow the iteratee function to run repeatedly, until the first test function no longer returns true. My question is, can I be guaranteed the return for my randomFn() will only be executed once the everything inside the async function has completed?
So what exactly is the order of execution, or the rule for execution...?