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
0retries 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: () => booleanerror: unknown,attempt: number
Which failures are worth another attempt. Returning
falserethrows immediately, spending no further attempts and no delay.
The new Promise shape, made lazy: settle imperatively through resolve/reject, with the
Task's AbortSignal third.
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.
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.
& ((
A TaskClass#retry attempt nothing will await again — the reason its signal fires.
The deadline in TaskClass#await elapsed before the work settled.
& ((
TaskClass#shutdown settled the Task because the caller asked it to stop.
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.
Usage
import * as mod from "lib/task/task.ts";