Created
March 24, 2017 21:17
-
-
Save jeremy-brenner/4e09021870bf6cca8b765ca3162565ce to your computer and use it in GitHub Desktop.
callback accumulator using reduce
This file contains 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
list_of_things.reduce(function(accumulator, link) { | |
return accumulator.then(function(results) { | |
return doSomething(link).then(function(result) { | |
results.push(result); | |
return results; | |
}); | |
}), Promise.resolve([])).then(function(results){ | |
console.log('all results', results ); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment