-
-
Save reem/7736404f5eedfd88902a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function all(promises) { | |
return promises.reduce(function (previous, next) { | |
return join(previous, next, function ([previous_results, next_val]) { | |
previous_results.push(next_val); | |
return previous_results; | |
}); | |
}, Promise.resolve([])); | |
} | |
function join(x, y) { | |
return x.then(function (x_val) { | |
y.then(function (y_val) { | |
return [x, y]; | |
}) | |
}) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment