Skip to content

Commit

Permalink
Added comment clarifying some of the logic in when.map
Browse files Browse the repository at this point in the history
  • Loading branch information
briancavalier committed Jan 3, 2012
1 parent 0d9f283 commit 50d57d1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions when.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ define(function() {
i = promisesOrValues.length;
results = allocateArray(i);

// Since mapFunc may be async, get all invocations of it into flight
// asap, and then use reduce() to collect all the results
for(;i >= 0; --i) {
if(i in promisesOrValues)
results[i] = when(promisesOrValues[i], mapFunc);
Expand Down

0 comments on commit 50d57d1

Please sign in to comment.