@cnamts/vue-dot
Version:
Implementation of our Design System for the French Health Insurance
17 lines (13 loc) • 305 B
text/typescript
/** Debounce a callback function */
export function debounce(callback: () => void, time = 500): () => void {
let interval: number | null;
return (): void => {
if (interval) {
clearTimeout(interval);
}
interval = window.setTimeout(() => {
interval = null;
callback();
}, time);
};
}