@pathmaker-digital/pmd-utilities - v2.2.6
    Preparing search index...

    Function throttle

    • Creates a throttled function that only invokes the provided function at most once every wait milliseconds. If the function is invoked multiple times in quick succession, only the first call in the given wait period will be executed.

      Parameters

      • fn: Function

        The function to throttle.

      • wait: number

        The number of milliseconds to wait between invocations.

      Returns (...args: any[]) => void

      A throttled function.

      const throttledLog = throttle((message: string) => console.log(message), 1000);
      throttledLog("Hello"); // Will log "Hello"
      throttledLog("World"); // Will be ignored because it's within the 1000ms window.