async
async copied to clipboard
async.map runs through without any callback()
async.map([1,2,3],_runTest2, function(err, results)
{
console.log(results);
});
function _runTest2(item,callback)
{
console.log(item);
}
is returning
1
2
3
And i really thought map() is waiting for any callback to proceed. What can i use to achieve a behaviour like this, that the next item is processed after a callback(null,res)
async.mapSeries() is the way to go.
You are not calling the callback in _runTest2. Since async.map is parallel, it will call _runTest2 for all the items, but then wait forever for them to call-back, meaning the main map callback will never be called.
async.mapSeries() seems nice but it is so slow in my implementation. @cruiser12 did you figure out how to resolve this with async.map() ?