@eroyeroy/utils - v0.1.0
    Preparing search index...

    Function throttle

    • Returns a throttled version of fn that can be called at most once per limit ms.

      Type Parameters

      • Args extends unknown[]

      Parameters

      • fn: (...args: Args) => void

        The function to throttle.

      • limit: number

        Minimum interval in milliseconds between calls.

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

      const handleScroll = throttle(() => updatePosition(), 100)
      // updatePosition is called at most once every 100ms