Initial Commit

This commit is contained in:
2026-05-27 23:47:53 +01:00
parent fbc70f96e6
commit 9b28db724f
18103 changed files with 1600554 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import type {
LinearBackoffOptions,
RetryStrategy,
} from "../../types/retry.types.js";
/**
* Creates a retry strategy with linearly increasing delay.
*
* `delay(attempt) = initial + (attempt - 1) * increment`, capped at `max`
* if provided.
*
* @param opts - Linear backoff options.
* @returns A `RetryStrategy` function.
*/
export function createLinearBackoff(opts: LinearBackoffOptions): RetryStrategy {
const { initial, increment, max } = opts;
return (attempt: number): number => {
const delay = initial + (attempt - 1) * increment;
return max !== undefined ? Math.min(delay, max) : delay;
};
}