mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-06 16:03:52 +00:00
6bbf8ce795
* refactor: event editor color picker * refactor: throttle and debounce function signature
13 lines
295 B
TypeScript
13 lines
295 B
TypeScript
export function throttle<T extends any[]>(callback: (...args: T) => void, wait: number) {
|
|
let timeout: NodeJS.Timeout | null;
|
|
return (...args: T) => {
|
|
if (timeout) {
|
|
return;
|
|
}
|
|
timeout = setTimeout(() => {
|
|
timeout = null;
|
|
callback(...args);
|
|
}, wait);
|
|
};
|
|
}
|