Skip to content

Instantly share code, notes, and snippets.

@wuct
Created December 23, 2015 16:03
Show Gist options
  • Save wuct/277933d8a1b02ae1a973 to your computer and use it in GitHub Desktop.
Save wuct/277933d8a1b02ae1a973 to your computer and use it in GitHub Desktop.
merge two functions into one
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