froebel
Version:
TypeScript utility library
20 lines (19 loc) • 592 B
TypeScript
import type { λ } from "./types";
/**
* 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) )
* ```
*/
declare const callAll: <P extends any[], F extends λ<P, any>[]>(funs: [...F], ...args: P) => ReturnTypes<F>;
declare type ReturnTypes<T extends λ[]> = {
[K in keyof T]: T[K] extends λ<any, infer I> ? I : never;
};
export default callAll;