Skip to content

Instantly share code, notes, and snippets.

@teebot
Created January 27, 2016 11:25
Show Gist options
  • Save teebot/03bda6fada586fa5fa90 to your computer and use it in GitHub Desktop.
Save teebot/03bda6fada586fa5fa90 to your computer and use it in GitHub Desktop.
Wrap multiple functions in one
const fnWrapper = (...args) => () => args.forEach(f => f());
const method1 = document.write.bind(document, ['hello']);
const method2 = document.write.bind(document, ['world']);
const wrapped = fnWrapper(method1, method2);
wrapped();
@teebot
Copy link
Author

teebot commented Jan 27, 2016

and in coffeescript:
fnWrapper = (args...) -> -> (args).forEach((f) -> f())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment