Debounce in TypeScript, no library needed
Debouncing waits until calls stop for a moment, then runs once. Useful for search-as-you-type, resize handlers and autosave. This version keeps the argument types of the wrapped function. Note: the wrapped function's return value is discarded, and the last call wins.
```typescript
export function debounce<A extends unknown[]>(fn: (...args: A) => void, wait = 250) {
let timer: ReturnType<typeof setTimeout> | undefined;
return (...args: A) => {
clearTimeout(timer);
timer = setTimeout(() => fn(...args), wait);