// Source: https://decipher.dev/30-seconds-of-typescript/docs/debounce/ export const debounce = any>(fn: TFunction, ms = 300) => { let timeoutId: ReturnType; return function (this: any, ...args: any[]) { clearTimeout(timeoutId); // @ts-ignore timeoutId = setTimeout(() => fn.apply(this, args), ms); }; };