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

x/ayonli_jsext/promise/index.ts>asyncTask

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

Creates a promise that can be resolved or rejected manually.

This function is like Promise.withResolvers but less verbose.

Examples

Example 1

import { asyncTask } from "@ayonli/jsext/async";

const task = asyncTask<number>();

setTimeout(() => task.resolve(42), 1000);

const result = await task;
console.log(result); // 42