(
funcs: Array<((this: This, ...args: Args) => any) | undefined>,
snackbarId?: SnackbarKey
)
| 12 | * otherwise will pass back existing functions or null. |
| 13 | */ |
| 14 | export 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…