pinterval
    Preparing search index...

    Function retry

    • Retries a given predicate function or asynchronous predicate function until a condition is met or a maximum number of attempts is reached.

      Type Parameters

      • T

      Parameters

      • predicate: RetryPredicate<T> | RetryPredicateAsync<T>

        The predicate function or async function to be invoked for each retry attempt. The function should return a defined result to be considered successful.

      • attempts: number

        The maximum number of retry attempts before failing.

      • timeout: Duration

        The duration between each retry attempt.

      • Optionalstart: StartMode = 'immediate'

        Determines whether the retry process starts immediately ('immediate') or after the first timeout period ('delayed').

      Returns Promise<T>

      A promise that resolves with the result of the predicate when it succeeds or rejects if the maximum number of attempts is exceeded or an error occurs.