diff --git a/source/exponential-backoff.ts b/source/exponential-backoff.ts index 3ae558f..79c672c 100644 --- a/source/exponential-backoff.ts +++ b/source/exponential-backoff.ts @@ -41,11 +41,23 @@ export class ExponentialBackoff { private readonly options: ExponentialBackoffOptions; - constructor(options?: Partial) { + /** + * Creates a new exponential-backoff instance. + * + * Unspecified options use the defaults listed below. + * + * @param options - Exponential-backoff configuration overrides. + * @param options.maxDelay - Maximum delay between retries. Default: `10_000` ms. + * @param options.maxAttempts - Maximum number of attempts; `0` retries indefinitely. Default: `10`. + * @param options.baseDelay - Delay used as the basis for the first retry. Default: `1_000` ms. + * @param options.growthRate - Multiplier applied to the delay after each attempt. Default: `2`. + * @param options.jitter - Random proportional variation applied to each delay. Default: `0.1`. + */ + constructor(options: Partial = {}) { this.options = { - maxDelay: 10000, + maxDelay: 10_000, maxAttempts: 10, - baseDelay: 1000, + baseDelay: 1_000, growthRate: 2, jitter: 0.1, ...options,