• Debounces a function, ensuring it is called after a specified timeout has passed since the last invocation.

    Parameters

    • context: any

      The context (this value) to be used when calling the debounced function.

    • func: Function

      The function to debounce.

    • timeout: number = 300

      The duration (in milliseconds) to wait after the last invocation before calling the function. Defaults to 300 milliseconds.

    Returns ((...args) => void)

    A debounced version of the provided function.

      • (...args): void
      • Parameters

        • Rest ...args: any

        Returns void

    Example

    const debouncedFn = debounce(this, myFunction, 500);
    debouncedFn(arg1, arg2);