Module

x/proc/legacy/deps.ts>deadline

A better way to work with processes in Deno.
Latest
function deadline
import { deadline } from "https://dotland.deno.dev/x/proc@0.21.9/legacy/deps.ts";

Create a promise which will be rejected with DeadlineError when a given delay is exceeded.

Note: Prefer to use {@link AbortSignal.timeout} instead for the APIs that accept {@link AbortSignal}.

Examples

Example 1

import { deadline } from "https://deno.land/std@$STD_VERSION/async/deadline.ts";
import { delay } from "https://deno.land/std@$STD_VERSION/async/delay.ts";

const delayedPromise = delay(1000);
// Below throws `DeadlineError` after 10 ms
const result = await deadline(delayedPromise, 10);

Parameters

p: Promise<T>
ms: number
optional
options: DeadlineOptions = [UNSUPPORTED]

Returns

Promise<T>