mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-09-22 02:47:29 +02:00
8 lines
244 B
TypeScript
8 lines
244 B
TypeScript
export function debounce<T extends (...args: any[]) => any>(fn: T, ms: number): T {
|
|
let timeout: ReturnType<typeof setTimeout>;
|
|
return ((...args: any[]) => {
|
|
clearTimeout(timeout);
|
|
timeout = setTimeout(() => fn(...args), ms);
|
|
}) as T;
|
|
}
|