📄 debounce.ts
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 1 |
📊 Variables & Constants | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/website/src/components/lib/debounce.ts
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
timeout |
any |
let/var | *not shown* |
✗ |
Functions¶
debounce(func: (...args: X) => void, wait: number): (...args: X) => void
¶
Code
export function debounce<X extends unknown[]>(
func: (...args: X) => void,
wait: number,
): (...args: X) => void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let timeout: any;
return function (...args: X): void {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
clearTimeout(timeout);
timeout = setTimeout(() => {
timeout = undefined;
func(...args);
}, wait);
};
}
- Parameters:
func: (...args: X) => void
wait: number
- Return Type:
(...args: X) => void
- Calls:
clearTimeout
setTimeout
func
- Internal Comments: