I'm using async with Node.js. It runs fine when I have a fixed number of functions to execute:
async.series([
function(cb) { ...one ... },
function(cb) { .. two ... },
], function(err, res) {
...done
});
But now I need to execute an arbitrary number of functions, depending on values in one array, and cannot figure how to pass the array elements:
var values = [1, 2, 3, ... ];
var calls = [];
for (var i = 0; i < values.length; i++) {
calls.push(function(cb) {
HOW TO PASS values[i] HERE?
});
}
async.series(calls, function(err, res) {
...done
});