blob: d85e93568ca1d4992ce3dfc71470f2d510620d59 (
plain)
1
2
3
4
5
6
7
8
|
export function debounce<A extends any[]>(f: (...args: A) => void, timeout: number): (...args: A) => void {
let interval: number | undefined = undefined
return (...args: A) => {
clearTimeout(interval)
interval = setTimeout(() => f.apply(this, args), timeout)
}
}
|