Last active
June 21, 2023 13:32
-
-
Save emkis/bb56314682300d620e3b5185105aa6ba to your computer and use it in GitHub Desktop.
A TypeScript version of the callAll function
This file contains 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
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
type CallBack<Params extends any[]> = { | |
(...args: Params): void; | |
}; | |
export function callAll<Params extends any[]>(...fns: Array<CallBack<Params> | undefined>) { | |
return (...args: Params) => fns.forEach((fn) => typeof fn === 'function' && fn(...args)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment