enqueue.js 407 B

1234567891011121314
  1. /**
  2. returns a function which executes promises one after another
  3. @param promiseGenerators an array of functions which return a promise
  4. @return function which executes the promises
  5. */
  6. const enqueue = (promiseGenerators) => {
  7. return promiseGenerators.reduce((f, promiseGenerator) => {
  8. return () => {
  9. return f().then(promiseGenerator);
  10. };
  11. });
  12. };
  13. export default enqueue;