Created
October 19, 2020 20:55
-
-
Save leolanese/4189484cc16b13e5d34bbec3f4868a04 to your computer and use it in GitHub Desktop.
compose
This file contains hidden or 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 = (...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