Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function pipe
const pipe = (...functions) => args => functions.reduce((arg, fn) => fn(arg), args);
// 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 = pipe(
// filter(h => h.power === 'fly'),
// map(h => h.heroe)
// )(league); // ["superman"]
// pipe(mapWords, reduceWords)(['foo', 'bar', 'baz']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment