HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/web/matomo.vdk/plugins/CoreHome/vue/src/debounce.ts
const DEFAULT_DEBOUNCE_DELAY = 300;

export default function debounce<This, Args extends unknown[]>(
  fn: (this: This, ...args: Args) => void,
  delayInMs = DEFAULT_DEBOUNCE_DELAY,
): (this: This, ...args: Args) => void {
  let timeout: ReturnType<typeof setTimeout>;

  return function wrapper(this: This, ...args: Args): void {
    if (timeout) {
      clearTimeout(timeout);
    }

    timeout = setTimeout(() => {
      fn.call(this, ...args);
    }, delayInMs);
  };
}