Created
July 5, 2016 04:24
-
-
Save marty-wang/c4b0b76bd3b9e228bc3cb79c5cfb65a1 to your computer and use it in GitHub Desktop.
Very small compose function
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 compose = (...fns) => (...args) => fns.reduceRight((input, fn) => fn.apply(null, [].concat(input)), args) | |
const combine = (...args) => args.join(" ") | |
const shout = (x) => x.toUpperCase() | |
const emphasize = (x) => `${x}!` | |
const yell = compose(emphasize, shout, combine) | |
console.log(yell("hello", "world")); // "HELLO WORLD!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment