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

x/ayonli_jsext/esm/promise/index.js>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/esm/promise/index.js";

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