froebel
Version:
TypeScript utility library
16 lines (15 loc) • 406 B
JavaScript
/**
* Take a list of functions that accept the same parameters and call them all
* with the provided arguments.
*
* @example
* ```
* const mult = (a: number, b: number) => a * b
* const div = (a: number, b: number) => a / b
*
* // prints: [8, 2]
* console.log( callAll([mult, div], 4, 2) )
* ```
*/
const callAll = (funs, ...args) => funs.map(cb => cb(...args)) ?? [];
export default callAll;