I understand that the async.parallel
method run its task functions in parallel. However I am unsure about the order of the results.
Is the order of the results array dependant on:
When the parallel tasks callback. The first task to callback will have its results first in the final results array.
or
The order of the tasks were supplied in the async.parrallel
method. The first task method will have its result first in the final results array.
Nevermind.
I can personally conclude that the 2nd instance is the correct one.
As clarified at the bottom of this example found in the README:
async.parallel([
function(callback){
setTimeout(function(){
callback(null, 'one');
}, 200);
},
function(callback){
setTimeout(function(){
callback(null, 'two');
}, 100);
},
],
// optional callback
function(err, results){
// the results array will equal ['one','two'] even though
// the second function had a shorter timeout.
});
This should be explicitly stated in the async docs.
Another help would be possibility for a way to pass a key to use in the array lookup in the final results array.
Most helpful comment
This should be explicitly stated in the async docs.