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

@ -5,7 +5,6 @@ import {
assertInstanceOf,
} from "../../../test_util/std/testing/asserts.ts";
import { delay } from "../../../test_util/std/async/delay.ts";
import { deferred } from "../../../test_util/std/async/deferred.ts";
import { fromFileUrl, join } from "../../../test_util/std/path/mod.ts";
import { serveTls } from "../../../test_util/std/http/server.ts";
import * as tls from "node:tls";
@ -89,7 +88,7 @@ Deno.test("tls.connect mid-read tcp->tls upgrade", async () => {
});
Deno.test("tls.createServer creates a TLS server", async () => {
const p = deferred();
const deferred = Promise.withResolvers<void>();
const server = tls.createServer(
// deno-lint-ignore no-explicit-any
{ host: "0.0.0.0", key, cert } as any,
@ -131,9 +130,9 @@ Deno.test("tls.createServer creates a TLS server", async () => {
conn.close();
server.close();
p.resolve();
deferred.resolve();
});
await p;
await deferred.promise;
});
Deno.test("TLSSocket can construct without options", () => {