Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
compose
const compose = (...functions) => args => functions.reduceRight((arg, fn) => fn(arg), args);
// Example:
// const league = [
// { heroe: "superman", power: 'fly' },
// { heroe: "batman", power: 'millionare'},
// { heroe: "flash", power: 'speed' },
//]
//const filter = f => arr => arr.filter(f);
//const map = m => arr => arr.map(m);
//let res = compose(
// map(h => h.heroe),
// filter(h => h.power === 'fly')
//)(league); // ["superman"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment