Skip to content

Instantly share code, notes, and snippets.

@jpblancoder
Created March 4, 2024 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpblancoder/53c7e8e6fb66372342d8085d009b4e16 to your computer and use it in GitHub Desktop.
Save jpblancoder/53c7e8e6fb66372342d8085d009b4e16 to your computer and use it in GitHub Desktop.
Create a function that calls all the functions passed to it, with the same arguments.
/**
* Create a function that calls all the functions passed to it, with the same arguments.
* @example <div onClick={callAll(f, g, h)} />
* @param {...any} fns - Functions to call (left-to-right execution)
* @returns {Function}
*/
export const callAll =
(...fns) =>
(...args) =>
fns.forEach(fn => isFunctionThenInvoke(fn, args, undefined));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment