import { makePromise } from "https://deno.land/x/enzastdlib@v0.0.4/async/promise.ts";
Returns a Promise
instance along with its resolve and reject functions.
Examples
Example 1
Example 1
import {
assertEquals,
assertInstanceOf,
} from 'https://deno.land/std/testing/asserts.ts';
import { makePromise } from 'https://deno.land/x/enzastdlib/async/mod.ts';
import { assertTypeOf } from 'https://deno.land/x/enzastdlib/testing/mod.ts';
const { promise, resolve, reject } = makePromise<number>();
assertInstanceOf(promise, Promise);
assertTypeOf(resolve, 'function');
assertTypeOf(reject, 'function');
resolve(42);
assertEquals(await promise, 42);