common-stuff
    Preparing search index...

    Function debounce

    • Creates and returns a new debounced version of the passed function that will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked.

      The returned function exposes .cancel() to discard a pending trailing call.

      Type Parameters

      • A extends unknown[]

      Parameters

      • func: (...args: A) => void

        The function to be debounced.

      • timeInMs: number

        The number of milliseconds to delay.

      Returns Cancellable<(this: unknown, ...args: A) => void>

      const debounced = debounce(() => console.log('debounced'), 100)
      debounced() // will be called after 100ms
      debounced.cancel() // discard the pending call