Last active
November 1, 2018 22:27
-
-
Save VitorLuizC/719997680210bfaffa8dd3130e730116 to your computer and use it in GitHub Desktop.
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 then = Function.call.bind(Promise.prototype.then); | |
export default (...λs) => (value) => λs.reduce(then, Promise.resolve(value)); |
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
import compose from './compose'; | |
const request = compose( | |
(route) => window.fetch('https://api.service.io' + route), | |
(response) => response.json() | |
); | |
const getUserNames = compose( | |
() => request('/users'), | |
(users) => users.filter(user => user.active), | |
(users) => users.map(user => user.name) | |
); | |
(async () => { | |
const users = await getUserNames() | |
console.log(users); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment