Created
November 7, 2020 16:08
-
-
Save bunnyhawk/b226b19f1702163cd44678689fbbfc0c to your computer and use it in GitHub Desktop.
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
const getUser = (email) => fetch(`/api/${email}`).then(res => res.json()); | |
const promiseQueue = (values, func) => { | |
const reducer = (promises, value) => | |
promises.then((promise) => func(value).then(res => promise.push(res) && res)); | |
return values.reduce(reducer, Promise.result([])); | |
}; | |
promiseQueue(["test@example.com", "another@example.com", "thirdOne@example.com"], getUser); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment