You need to only pass the doThisEveryTime
function, not call it - no parenthesis, no next
:
var i = 0;
var continueWhilst = true;
async.whilst(
function test() { return continueWhilst; },
doThisEveryTime2,
function (err) {
// Done
}
);
Also notice that you rather should use the timesSeries
function for what you are doing - with the additional benefit that i
is a functional argument to the doThisEveryTime
function, not a global variable.