Function retry

  • Retry a function with exponential backoff

    Type Parameters

    • T

    Parameters

    • fn: (() => Promise<T>)

      Function to retry

        • (): Promise<T>
        • Returns Promise<T>

    • maxAttempts: number = 3

      Maximum number of attempts

    • baseDelay: number = 1000

      Base delay in milliseconds

    Returns Promise<T>

    Result of the function