summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal/child_process.ts
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2023-11-22 22:11:20 +1100
committerGitHub <noreply@github.com>2023-11-22 12:11:20 +0100
commit616354e76cba0be8af20a0ffefeacfcf6101bafc (patch)
treec832c81dd93498e196840c8d59c0a4ab76396d07 /ext/node/polyfills/internal/child_process.ts
parent0ffcb46e0f60110c07e21151db6066f5a1b5f710 (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/internal/child_process.ts')
-rw-r--r--ext/node/polyfills/internal/child_process.ts13
1 files changed, 6 insertions, 7 deletions
diff --git a/ext/node/polyfills/internal/child_process.ts b/ext/node/polyfills/internal/child_process.ts
index 7d707758e..1c9aced19 100644
--- a/ext/node/polyfills/internal/child_process.ts
+++ b/ext/node/polyfills/internal/child_process.ts
@@ -11,7 +11,6 @@ import { EventEmitter } from "node:events";
import { os } from "ext:deno_node/internal_binding/constants.ts";
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
import { Readable, Stream, Writable } from "node:stream";
-import { deferred } from "ext:deno_node/_util/async.ts";
import { isWindows } from "ext:deno_node/_util/os.ts";
import { nextTick } from "ext:deno_node/_next_tick.ts";
import {
@@ -151,7 +150,7 @@ export class ChildProcess extends EventEmitter {
];
#process!: Deno.ChildProcess;
- #spawned = deferred<void>();
+ #spawned = Promise.withResolvers<void>();
constructor(
command: string,
@@ -253,7 +252,7 @@ export class ChildProcess extends EventEmitter {
(async () => {
const status = await this.#process.status;
this.exitCode = status.code;
- this.#spawned.then(async () => {
+ this.#spawned.promise.then(async () => {
const exitCode = this.signalCode == null ? this.exitCode : null;
const signalCode = this.signalCode == null ? null : this.signalCode;
// The 'exit' and 'close' events must be emitted after the 'spawn' event.
@@ -688,22 +687,22 @@ function waitForReadableToClose(readable: Readable) {
}
function waitForStreamToClose(stream: Stream) {
- const promise = deferred<void>();
+ const deferred = Promise.withResolvers<void>();
const cleanup = () => {
stream.removeListener("close", onClose);
stream.removeListener("error", onError);
};
const onClose = () => {
cleanup();
- promise.resolve();
+ deferred.resolve();
};
const onError = (err: Error) => {
cleanup();
- promise.reject(err);
+ deferred.reject(err);
};
stream.once("close", onClose);
stream.once("error", onError);
- return promise;
+ return deferred.promise;
}
/**