@yesstudio/yes-utils
    Preparing search index...

    Function debounce

    • Creates a debounced function that delays invoking func until after wait milliseconds have elapsed since the last time the debounced function was invoked. The func will be invoked with the context and arguments of the debounced function.

      Type Parameters

      • T extends (...args: unknown[]) => unknown

      Parameters

      • func: T

        The function to debounce.

      • wait: number = 0

        The number of milliseconds to delay.

      • options: DebounceOptions = {}

        The function options.

      Returns (...args: Parameters<T>) => void

      Returns the new debounced function.

      // Avoid costly calculations while the window size is in flux.
      window.addEventListener.on('resize', debounce(calculateLayout, 100))