MCPcopy Index your code
hub / github.com/nodejs/node / nonPollingWatchFile

Function nonPollingWatchFile

test/fixtures/snapshot/typescript.js:6367–6386  ·  view source on GitHub ↗
(fileName, callback, _pollingInterval, fallbackOptions)

Source from the content-addressed store, hash-verified

6365 var toCanonicalName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
6366 return nonPollingWatchFile;
6367 function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
6368 var filePath = toCanonicalName(fileName);
6369 fileWatcherCallbacks.add(filePath, callback);
6370 var dirPath = ts.getDirectoryPath(filePath) || ".";
6371 var watcher = dirWatchers.get(dirPath) ||
6372 createDirectoryWatcher(ts.getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
6373 watcher.referenceCount++;
6374 return {
6375 close: function () {
6376 if (watcher.referenceCount === 1) {
6377 watcher.close();
6378 dirWatchers.delete(dirPath);
6379 }
6380 else {
6381 watcher.referenceCount--;
6382 }
6383 fileWatcherCallbacks.remove(filePath, callback);
6384 }
6385 };
6386 }
6387 function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
6388 var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName) {
6389 // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"

Callers 1

watchFileFunction · 0.85

Calls 6

createDirectoryWatcherFunction · 0.85
addMethod · 0.65
getMethod · 0.65
closeMethod · 0.65
deleteMethod · 0.65
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…