UNPKG

askui

Version:

Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on

26 lines (25 loc) 957 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExponentialRetryStrategy = void 0; /** * ExponentialRetryStrategy implements a retry strategy that uses an exponential backoff algorithm. */ class ExponentialRetryStrategy { /** * @param baseDelayMs - The initial delay before the first retry (default is 1000ms) * @param retryCount - The maximum number of retries (default is 3) */ constructor(baseDelayMs = 1000, retryCount = 3) { this.baseDelayMs = baseDelayMs; this.retryCount = retryCount; } /** * Calculates the delay for a given retry attempt using exponential backoff. * @param attempt - The current retry attempt number (0-based) * @returns The delay in milliseconds for the current attempt */ getDelay(attempt) { return this.baseDelayMs * (Math.pow(2, attempt)); } } exports.ExponentialRetryStrategy = ExponentialRetryStrategy;