Created
December 23, 2015 16:03
-
-
Save wuct/277933d8a1b02ae1a973 to your computer and use it in GitHub Desktop.
merge two functions into one
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 mergeFuncs = (...funcs) => (...args) => { | |
for (const func of funcs) { | |
if (typeof func === 'function') func(...args); | |
} | |
} | |
const foo = e => console.log('foo', e) | |
const bar = (e, val) => console.log('bar', e, val) | |
const foobar = mergeFuncs(foo, bar) | |
foobar('yo', 'lo'); | |
// foo yo | |
// bar yo lo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment