type alias Executor

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

Returning a promise settles the Task as well (whichever lands first wins), which is what lets (_, __, signal) => fetch(url, { signal }) skip the resolver entirely. Any other return value is ignored, exactly as new Promise ignores it — otherwise the commonest executor idiom of all, (resolve) => setTimeout(resolve, 100), would settle the Task instantly with a timer handle. To settle with something that might not be a promise, hand it to the resolver: (resolve) => resolve(maybeAPromise).

Honouring the promise also closes a hole the platform leaves open: new Promise(async () => { throw x }) discards the executor's promise, so the throw escapes as an unhandled rejection and the promise never settles. Here it simply becomes the Task's failure.

Type Parameters

Definition

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

Usage

import { type Executor } from "lib/task/task.ts";