mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
refactor: replace deferred()
from std/async
with Promise.withResolvers()
(#21234)
Closes #21041 --------- Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
parent
0ffcb46e0f
commit
616354e76c
35 changed files with 952 additions and 1020 deletions
|
@ -4,7 +4,6 @@ import {
|
|||
assert,
|
||||
assertEquals,
|
||||
} from "../../../test_util/std/testing/asserts.ts";
|
||||
import { deferred } from "../../../test_util/std/async/deferred.ts";
|
||||
|
||||
Deno.test(async function foo() {
|
||||
const asyncLocalStorage = new AsyncLocalStorage();
|
||||
|
@ -68,16 +67,16 @@ Deno.test(async function bar() {
|
|||
|
||||
Deno.test(async function nested() {
|
||||
const als = new AsyncLocalStorage();
|
||||
const promise = deferred();
|
||||
const promise1 = deferred();
|
||||
const deferred = Promise.withResolvers();
|
||||
const deferred1 = Promise.withResolvers();
|
||||
|
||||
als.run(null, () => {
|
||||
als.run({ x: 1 }, () => {
|
||||
promise.resolve(als.getStore());
|
||||
deferred.resolve(als.getStore());
|
||||
});
|
||||
promise1.resolve(als.getStore());
|
||||
deferred1.resolve(als.getStore());
|
||||
});
|
||||
|
||||
assertEquals(await promise, { x: 1 });
|
||||
assertEquals(await promise1, null);
|
||||
assertEquals(await deferred.promise, { x: 1 });
|
||||
assertEquals(await deferred1.promise, null);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue