deferred_promise
Don't use this unless you know what you're doing.
Prefer the Promise
constructor.
Rough port of p-defer for Deno.
Usage
import { DeferredPromise } from "https://deno.land/x/deferred_promise@v1.0.0/mod.ts";
function delay(milliseconds: number) {
const deferred = new DeferredPromise<string>();
setTimeout(() => {
deferred.resolve("🦄");
}, milliseconds);
return deferred.promise;
}
console.log(await delay(100));
//=> '🦄'
The above is just an example. Use
std/async's delay
if you need
to delay a promise.