diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2023-11-22 22:11:20 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 12:11:20 +0100 |
commit | 616354e76cba0be8af20a0ffefeacfcf6101bafc (patch) | |
tree | c832c81dd93498e196840c8d59c0a4ab76396d07 /ext/node/polyfills/http.ts | |
parent | 0ffcb46e0f60110c07e21151db6066f5a1b5f710 (diff) |
refactor: replace `deferred()` from `std/async` with `Promise.withResolvers()` (#21234)
Closes #21041
---------
Signed-off-by: Asher Gomez <ashersaupingomez@gmail.com>
Diffstat (limited to 'ext/node/polyfills/http.ts')
-rw-r--r-- | ext/node/polyfills/http.ts | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 4ad502760..475d691cc 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -7,7 +7,6 @@ const core = globalThis.__bootstrap.core; import { TextEncoder } from "ext:deno_web/08_text_encoding.js"; -import { type Deferred, deferred } from "ext:deno_node/_util/async.ts"; import { setTimeout } from "ext:deno_web/02_timers.js"; import { _normalizeArgs, @@ -1556,7 +1555,7 @@ export class ServerImpl extends EventEmitter { #server: Deno.Server; #unref = false; #ac?: AbortController; - #servePromise: Deferred<void>; + #serveDeferred: ReturnType<typeof Promise.withResolvers<void>>; listening = false; constructor(opts, requestListener?: ServerHandler) { @@ -1573,8 +1572,8 @@ export class ServerImpl extends EventEmitter { this._opts = opts; - this.#servePromise = deferred(); - this.#servePromise.then(() => this.emit("close")); + this.#serveDeferred = Promise.withResolvers<void>(); + this.#serveDeferred.promise.then(() => this.emit("close")); if (requestListener !== undefined) { this.on("request", requestListener); } @@ -1660,7 +1659,7 @@ export class ServerImpl extends EventEmitter { if (this.#unref) { this.#server.unref(); } - this.#server.finished.then(() => this.#servePromise!.resolve()); + this.#server.finished.then(() => this.#serveDeferred!.resolve()); } setTimeout() { @@ -1700,7 +1699,7 @@ export class ServerImpl extends EventEmitter { this.#ac.abort(); this.#ac = undefined; } else { - this.#servePromise!.resolve(); + this.#serveDeferred!.resolve(); } this.#server = undefined; |