Creates a wrapped function that only executes the provided function after the initial call has completed. The wrapped function can be cleared to allow subsequent calls to execute the provided function again.

  • Type Parameters

    • T extends unknown = any

      The type of the promise resolved by the provided function.

    • P extends any[] = any[]

      The type of the arguments passed to the provided function.

    Parameters

    • run: (...args: P) => Promise<T>

      The function to be wrapped.

    Returns IWrappedFn<T, P>

    The wrapped function.