Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/async.ts>timeout

A JavaScript extension package for building strong and modern applications.
Latest
function timeout
import { timeout } from "https://deno.land/x/ayonli_jsext@v0.9.72/async.ts";

Try to resolve a promise with a timeout limit.

Examples

Example 1

import { timeout, sleep } from "@ayonli/jsext/async";

const task = sleep(1000);

await timeout(task, 500); // throws TimeoutError after 500ms

Parameters

task: PromiseLike<T>
ms: number

Returns

Promise<T>