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

std/async/deferred.ts>deferred

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function deferred
Deprecated
Deprecated

(will be removed in 0.209.0) Use Promise.withResolvers instead.

Creates a Promise with the reject and resolve functions placed as methods on the promise object itself.

import { deferred } from "https://deno.land/std@0.206.0/async/deferred.ts";

Examples

Example 1

import { deferred } from "https://deno.land/std@0.206.0/async/deferred.ts";

const p = deferred<number>();
// ...
p.resolve(42);