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:
Asher Gomez 2023-11-22 22:11:20 +11:00 committed by GitHub
parent 0ffcb46e0f
commit 616354e76c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 952 additions and 1020 deletions

View file

@ -13,7 +13,6 @@ import {
assertThrows,
} from "../../../test_util/std/testing/asserts.ts";
import { stripColor } from "../../../test_util/std/fmt/colors.ts";
import { deferred } from "../../../test_util/std/async/deferred.ts";
import * as path from "../../../test_util/std/path/mod.ts";
import { delay } from "../../../test_util/std/async/delay.ts";
@ -368,7 +367,7 @@ Deno.test({
// stdin resource is present before the test starts.
sanitizeResources: false,
async fn() {
const promise = deferred();
const { promise, resolve } = Promise.withResolvers<void>();
const expected = ["foo", "bar", null, "end"];
const data: (string | null)[] = [];
@ -385,7 +384,7 @@ Deno.test({
process.stdin.push("bar");
process.nextTick(() => {
process.stdin.push(null);
promise.resolve();
resolve();
});
});