In Caolan's Async library, the documentation says that the each function:
Applies the function iteratee to each item in arr, in parallel. The iteratee is called with an item from the list, and a callback for when it has finished.
This example is given:
async.each(arr, iteraree, function(err){
//Do stuff
});
My question is how is the "callback", in this case iteraree, defined? How do you declare which callback function you would like called when it has finished?
If you were able to define functions as a parameter I could see it working but you can't (i.e):
async.each(openFiles, function (item, function () {console.log("done")}), function(err){
//Do stuff
});
But how could I define that callback not inline?
If I do something like
var iteraree = function (item, callback) {};
And passed in iteraree I still do not see where I would be able to define the behavior of callback.