Skip to content

Instantly share code, notes, and snippets.

Created November 25, 2015 23:06
Show Gist options
  • Save anonymous/1b685c9be8e8164f6b23 to your computer and use it in GitHub Desktop.
Save anonymous/1b685c9be8e8164f6b23 to your computer and use it in GitHub Desktop.
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;
});
});
}
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