MCPcopy Index your code
hub / github.com/nodejs/node / #poll

Method #poll

lib/internal/vfs/watcher.js:130–149  ·  view source on GitHub ↗

* Polls for changes.

()

Source from the content-addressed store, hash-verified

128 * Polls for changes.
129 */
130 #poll() {
131 if (this.#closed) return;
132
133 // For directory watching, poll tracked children
134 if (this.#lastStats?.isDirectory()) {
135 this.#pollDirectory();
136 return;
137 }
138
139 // For single file watching
140 const newStats = this.#getStats();
141
142 if (this.#statsChanged(this.#lastStats, newStats)) {
143 const eventType = this.#determineEventType(this.#lastStats, newStats);
144 const filename = this.#encodeFilename(basename(this.#path));
145 this.emit('change', eventType, filename);
146 }
147
148 this.#lastStats = newStats;
149 }
150
151 /**
152 * Polls directory children for changes, detecting new and deleted files.

Callers 1

#startPollingMethod · 0.95

Calls 8

#pollDirectoryMethod · 0.95
#getStatsMethod · 0.95
#statsChangedMethod · 0.95
#determineEventTypeMethod · 0.95
#encodeFilenameMethod · 0.95
basenameFunction · 0.85
isDirectoryMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected