I have a set of functions that are run through the async.series() function which take as parameters the values that I happen to have stored in an array.
params = [ {id: 1, name: "Two tires fly. Two wail."},
{id: 2, name: "Snow-Balls have flown their Arcs"},
{id: 3, name: "A beginning is the time for taking the most delicate care"}
];
async.series(
[ function(callback) {
myFunction(callback, params[0]);
},
function(callback) {
myFunction(callback, params[1]);
},
function(callback) {
myFunction(callback, params[2]);
},
]);
Obviously the array is much larger and it would be convenient to wrap them into a loop:
var functionsArray = [];
for (var i = 0; i < params.length; ++i) {
functionsArray.push(
function(callback) {
myFunction(callback, params[i]);
}
);
}
async.series(functionsArray);
Alas, this technique makes jshint freak out about defining a function in an array and I understand why it won't work. i will be a fixed value at call time and is not trapped as a value.
How do I create a set of functions whose parameters are in an array so that I don't have to explicitly define each one.
I am willing to use other facilities in async. Also, the functions are highly async, thus the reason for using the async.series()