10 lines
202 B
TypeScript
10 lines
202 B
TypeScript
export function debounce(fn: Function, n = 100) {
|
|
let handle: any
|
|
return (...args: any[]) => {
|
|
if (handle) clearTimeout(handle)
|
|
handle = setTimeout(() => {
|
|
fn(...args)
|
|
}, n)
|
|
}
|
|
}
|