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

    Function debounce

    • Returns a debounced version of fn that delays invocation until wait ms have elapsed since the last call.

      Type Parameters

      • Args extends unknown[]

      Parameters

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

        The function to debounce.

      • wait: number

        Delay in milliseconds.

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

      const handleInput = debounce((value: string) => search(value), 300)
      // search is called only after the user stops typing for 300ms