mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-11 00:08:37 +01:00
10 lines
318 B
TypeScript
10 lines
318 B
TypeScript
|
|
|
|
export const debounce = <F extends (...args: any) => any>(func: F, waitFor: number,) => {
|
|
let timeout: any;
|
|
const debounced = (...args: any) => {
|
|
clearTimeout(timeout)
|
|
timeout = setTimeout(() => func(...args), waitFor)
|
|
}
|
|
return debounced as (...args: Parameters<F>) => ReturnType<F>
|
|
} |