MCPcopy Create free account
hub / github.com/nodejs/node / unwatchFile

Method unwatchFile

lib/internal/vfs/providers/memory.js:998–1018  ·  view source on GitHub ↗

* Stops watching a file for changes. * @param {string} path The path to stop watching * @param {Function} [listener] Optional listener to remove

(path, listener)

Source from the content-addressed store, hash-verified

996 * @param {Function} [listener] Optional listener to remove
997 */
998 unwatchFile(path, listener) {
999 const normalized = this.#normalizePath(path);
1000 const watcher = this[kStatWatchers].get(normalized);
1001
1002 if (!watcher) {
1003 return;
1004 }
1005
1006 if (listener) {
1007 watcher.removeListener('change', listener);
1008 } else {
1009 // Remove all listeners
1010 watcher.removeAllListeners('change');
1011 }
1012
1013 // If no more listeners, stop and remove the watcher
1014 if (watcher.hasNoListeners()) {
1015 watcher.stop();
1016 this[kStatWatchers].delete(normalized);
1017 }
1018 }
1019}
1020
1021module.exports = {

Callers

nothing calls this directly

Calls 7

#normalizePathMethod · 0.95
hasNoListenersMethod · 0.80
getMethod · 0.65
stopMethod · 0.65
deleteMethod · 0.65
removeListenerMethod · 0.45
removeAllListenersMethod · 0.45

Tested by

no test coverage detected