Skip to content

Instantly share code, notes, and snippets.

@lastday154
Created January 30, 2019 08:44
Show Gist options
  • Save lastday154/a02b78801f57b1e7d024288688ed18b1 to your computer and use it in GitHub Desktop.
Save lastday154/a02b78801f57b1e7d024288688ed18b1 to your computer and use it in GitHub Desktop.
Sequential execution of Promises using reduce()
const compose = function(...tasks) {
return function(acc) {
return tasks.reduce(
(promise, task) => promise.then(task),
Promise.resolve(acc)
);
};
};
return compose(
getMessageByPage,
filterByLanguage(language),
filterByPeriod({ from_date, to_date }),
withUpdatedIntents(language)
)({ from_date, to_date, language, page_id });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment