Created
March 4, 2024 21:12
-
-
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.
This file contains hidden or 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
/** | |
* 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