/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/core/context/scheduler.js
26 строк
757 B
Jake Fried
small type cleanup: remove exclamation points (#37349)
12 янв 2022, 22:16
Не верифицирован
12 янв 2022, 22:16
cb17f8a
Код
Авторство
О чём код?
/** @typedef {function(function():*):void} SchedulerDef */ /** * Creates a scheduling function that executes the callback based on the * scheduler, but only one task at a time. * * @param {function():*} handler * @param {SchedulerDef} defaultScheduler * @return {function(SchedulerDef=):void} */ export function throttleTail(handler, defaultScheduler) { let scheduled = false; const handleAndUnschedule = () => { scheduled = false; handler(); }; /** @param {SchedulerDef=} opt_scheduler */ const scheduleIfNotScheduled = (opt_scheduler) => { if (!scheduled) { scheduled = true; const scheduler = opt_scheduler || defaultScheduler; scheduler(handleAndUnschedule); } }; return scheduleIfNotScheduled; }