Created
January 30, 2019 08:44
-
-
Save lastday154/a02b78801f57b1e7d024288688ed18b1 to your computer and use it in GitHub Desktop.
Sequential execution of Promises using reduce()
This file contains 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 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