/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/mui-utils/src/createChainedFunction/createChainedFunction.ts
23 строки
555 B
Marija Najdova
[utils] Convert all exports to modules (#39882)
26 янв 2024, 05:57
Не верифицирован
26 янв 2024, 05:57
c361a6e
Код
Авторство
О чём код?
/** * Safe chained function. * * Will only create a new function if needed, * otherwise will pass back existing functions or null. */ export default function createChainedFunction<Args extends any[], This>( ...funcs: Array<(this: This, ...args: Args) => any> ): (this: This, ...args: Args) => void { return funcs.reduce( (acc, func) => { if (func == null) { return acc; } return function chainedFunction(...args) { acc.apply(this, args); func.apply(this, args); }; }, () => {}, ); }