Last active
August 17, 2018 01:10
-
-
Save bwinant/539ec817f153e6f8843802a13fcf5146 to your computer and use it in GitHub Desktop.
Execute promises sequentially
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
const resolveSequential = (funcs) => { | |
return funcs.reduce( | |
(promise, f) => { | |
return promise.then(all => { | |
return f().then(r => { | |
all.push(r); | |
return all; | |
}) | |
}) | |
}, | |
Promise.resolve([]) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment