Classes

Interfaces

I
RetryOptions

The full option bag for Task#retry; pass a RetryDelay directly when the delay is all you need.

  • delayMs: RetryDelay

    Wait between attempts. Omitted or 0 retries immediately, as it always has.

  • timeoutMs: number

    Deadline for each individual attempt. The attempt is abandoned when it fires — its signal goes off so cancellation-aware work stops — and counts as a failure like any other.

  • when: (
    error: unknown,
    attempt: number
    ) => boolean

    Which failures are worth another attempt. Returning false rethrows immediately, spending no further attempts and no delay.

Type Aliases

T
Executor<T> = (
resolve: (value: T | PromiseLike<T>) => void,
reject: (reason?: unknown) => void,
signal: AbortSignal
) => unknown

The new Promise shape, made lazy: settle imperatively through resolve/reject, with the Task's AbortSignal third.

T
Recipe<T> = () => T | PromiseLike<T>

The zero-parameter shape: return the value (or a promise of it) and that settles the Task. Declared with no parameters both because that is what it receives and because it is what lets TypeScript tell a recipe from an Executor — a lambda naming even one parameter can then only be the executor, so resolve gets contextually typed instead of any. A recipe that needs the AbortSignal takes the executor shape.

T
RetryDelay = number | ((attempt: number) => number)

Milliseconds to wait before the next attempt, or a function of the attempt just finished — the shape lib/job converged on for Oban-style backoff, with a constant as its degenerate case. (n) => Math.min(100 * 2 ** n, 30_000) is exponential; () => 100 is fixed.

Variables

v
AwaitTimeout: FailureFactory<"AwaitTimeout", { ms: number; }>

The deadline in TaskClass#await elapsed before the work settled.

v
T
Task: TaskConstructor

Call-or-construct, like Boolean/Date: Task(recipe) and new Task(recipe) build the same lazy Task. ES classes reject the call form, so the export is a Proxy whose apply forwards to construction — statics, instanceof, and the prototype all pass through.