Skip to content

Instantly share code, notes, and snippets.

@VitorLuizC
Last active November 1, 2018 22:27
Show Gist options
  • Save VitorLuizC/719997680210bfaffa8dd3130e730116 to your computer and use it in GitHub Desktop.
Save VitorLuizC/719997680210bfaffa8dd3130e730116 to your computer and use it in GitHub Desktop.
const then = Function.call.bind(Promise.prototype.then);
export default (...λs) => (value) => λs.reduce(then, Promise.resolve(value));
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