summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_fs/_fs_watch.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-03-20 11:19:53 +0530
committerGitHub <noreply@github.com>2024-03-20 11:19:53 +0530
commit5b2f689f085fea8ff52f296c94072a1fb29dd054 (patch)
treed62a9b77c76055f68e96392f16ddb84820f198ac /ext/node/polyfills/_fs/_fs_watch.ts
parent737adbe1b076cda299131704520e9fe2d41b7611 (diff)
fix(ext/node): FsWatcher ref and unref (#22987)
Fixes https://github.com/denoland/deno/issues/22973 --------- Co-authored-by: Satya Rohith <me@satyarohith.com>
Diffstat (limited to 'ext/node/polyfills/_fs/_fs_watch.ts')
-rw-r--r--ext/node/polyfills/_fs/_fs_watch.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/ext/node/polyfills/_fs/_fs_watch.ts b/ext/node/polyfills/_fs/_fs_watch.ts
index e94818da9..9e02ea0f1 100644
--- a/ext/node/polyfills/_fs/_fs_watch.ts
+++ b/ext/node/polyfills/_fs/_fs_watch.ts
@@ -146,7 +146,7 @@ export function watch(
}
throw e;
}
- });
+ }, () => iterator);
if (listener) {
fsWatcher.on("change", listener.bind({ _handle: fsWatcher }));
@@ -252,6 +252,7 @@ class StatWatcher extends EventEmitter {
#bigint: boolean;
#refCount = 0;
#abortController = new AbortController();
+
constructor(bigint: boolean) {
super();
this.#bigint = bigint;
@@ -306,19 +307,22 @@ class StatWatcher extends EventEmitter {
this.emit("stop");
}
ref() {
- notImplemented("FSWatcher.ref() is not implemented");
+ notImplemented("StatWatcher.ref() is not implemented");
}
unref() {
- notImplemented("FSWatcher.unref() is not implemented");
+ notImplemented("StatWatcher.unref() is not implemented");
}
}
class FSWatcher extends EventEmitter {
#closer: () => void;
#closed = false;
- constructor(closer: () => void) {
+ #watcher: () => Deno.FsWatcher;
+
+ constructor(closer: () => void, getter: () => Deno.FsWatcher) {
super();
this.#closer = closer;
+ this.#watcher = getter;
}
close() {
if (this.#closed) {
@@ -329,10 +333,10 @@ class FSWatcher extends EventEmitter {
this.#closer();
}
ref() {
- notImplemented("FSWatcher.ref() is not implemented");
+ this.#watcher().ref();
}
unref() {
- notImplemented("FSWatcher.unref() is not implemented");
+ this.#watcher().unref();
}
}