import { promise } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { deferred } = promise;
Create a Deferred from a type.
Examples
Example 1
Example 1
import { deferred } from "./promise.ts";
const promise = deferred<number>();
// Logs 1 after a second
promise.then(console.log);
setTimeout(() => promise.resolve(1), 1000);