method TaskClass.prototype.await
Private
TaskClass.prototype.await(timeoutMs?: number): Promise<T>

Awaits the task with a deadline — Elixir's Task.await/2 (default 5000ms). Starts the run if needed; rejects with a declared Failure('AwaitTimeout') when the deadline fires first. The deadline does NOT cancel the work (TaskClass#shutdown does) — a later await task can still join the run, exactly like Elixir's yield-after-timeout.

await Task(() => 42).await(1000); // 42
const slow = Task(() => new Promise<never>(() => {}));
const failed = await slow.await(10).catch((e) => e);
(failed as { code: string }).code; // 'AwaitTimeout'

Parameters

optional
timeoutMs: number = 5000

Return Type

Promise<T>

Usage

import { TaskClass } from "lib/task/task.ts";