design-react-kit
Version:
Componenti React per Bootstrap 5
16 lines (14 loc) • 424 B
text/typescript
/*
* This work derives from the React Use Navscroll library
* Released under the MIT license by Marco Liberati
* Code: https://github.com/dej611/react-use-navscroll
*/
export const debounce = (callback: CallableFunction, wait: number) => {
let timeoutId: NodeJS.Timeout;
return (...args: unknown[]) => {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
callback(...args);
}, wait);
};
};