Function backoff

  • Repeatedly retry calling an async function with exponential backoff until the returned Promise resolves or a time limit expires.

    Returns

    A Promise that resolves, or rejects if the time limit expired, with the same value as callback.

    Type Parameters

    • T

    Parameters

    • callback: ((base: number, factor: number, iteration: number) => Promise<T>)

      The async function to call.

        • (base: number, factor: number, iteration: number): Promise<T>
        • Parameters

          • base: number
          • factor: number
          • iteration: number

          Returns Promise<T>

    • settings: Partial<BackoffSettings> = {}

      An object with the following properties:

      • timeout: The maximum time to continue to retry.
      • base: The delay in milliseconds before the first retry.
      • factor: base is multiplied by this after each retry.

    Returns Promise<T>

Generated using TypeDoc