MCPcopy
hub / github.com/iamhosseindhv/notistack / createChainedFunction

Function createChainedFunction

src/utils/createChainedFunction.ts:14–34  ·  view source on GitHub ↗
(
    funcs: Array<((this: This, ...args: Args) => any) | undefined>,
    snackbarId?: SnackbarKey
)

Source from the content-addressed store, hash-verified

12 * otherwise will pass back existing functions or null.
13 */
14export default function createChainedFunction<Args extends any[], This>(
15 funcs: Array<((this: This, ...args: Args) => any) | undefined>,
16 snackbarId?: SnackbarKey
17): (this: This, ...args: Args) => void {
18 // @ts-ignore
19 return funcs.reduce((acc, func) => {
20 if (func === null || func === undefined) {
21 return acc;
22 }
23
24 return function chainedFunction(...args) {
25 const argums = [...args] as any;
26 if (snackbarId && argums.indexOf(snackbarId) === -1) {
27 argums.push(snackbarId);
28 }
29 // @ts-ignore
30 acc.apply(this, argums);
31 func.apply(this, argums);
32 };
33 }, noOp);
34}

Callers 2

renderMethod · 0.85
SnackbarItemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…