Skip to content

Instantly share code, notes, and snippets.

View jpblancoder's full-sized avatar

JP Blanchette jpblancoder

View GitHub Profile
@jpblancoder
jpblancoder / callAll.js
Created March 4, 2024 21:12
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));