Created
June 17, 2020 13:18
-
-
Save olecksamdr/ac5d33ecaf05d1cef6f3a8e8fef6a742 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
/** | |
* runPromisesSync :: (array, function) -> Promise | |
* | |
* Runs a list of functions that return a Promise one by one | |
* promisesFactoryMap - a list of functions that return a promise | |
*/ | |
const runPromisesSync = (promisesFactoryMap, onError = defaultOnError) => | |
promisesFactoryMap.reduce( | |
(prevPromise, nextPromise) => prevPromise.then(nextPromise).catch(onError), | |
Promise.resolve() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment