Files
clash-verge-rev/src/utils/debounce.ts
T
Slinetrac c672a6fef3 refactor: lint (#6511)
* refactor: lint

* chore: remove eslint-plugin/config-prettier
2026-03-15 07:40:11 +00:00

13 lines
353 B
TypeScript

export default function debounce<T extends (...args: any[]) => void>(
func: T,
wait: number,
): T {
let timeout: ReturnType<typeof setTimeout> | null = null
return function (this: any, ...args: Parameters<T>) {
if (timeout !== null) {
clearTimeout(timeout)
}
timeout = setTimeout(() => func.apply(this, args), wait)
} as T
}