Skip to content

Instantly share code, notes, and snippets.

@olecksamdr
Created June 17, 2020 13:18
Show Gist options
  • Save olecksamdr/ac5d33ecaf05d1cef6f3a8e8fef6a742 to your computer and use it in GitHub Desktop.
Save olecksamdr/ac5d33ecaf05d1cef6f3a8e8fef6a742 to your computer and use it in GitHub Desktop.
/**
* 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