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

Function createSingleFileWatcherPerName

test/fixtures/snapshot/typescript.js:6440–6469  ·  view source on GitHub ↗
(watchFile, useCaseSensitiveFileNames)

Source from the content-addressed store, hash-verified

6438 }
6439 /* @internal */
6440 function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) {
6441 var cache = new ts.Map();
6442 var callbacksCache = ts.createMultiMap();
6443 var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
6444 return function (fileName, callback, pollingInterval, options) {
6445 var path = toCanonicalFileName(fileName);
6446 var existing = cache.get(path);
6447 if (existing) {
6448 existing.refCount++;
6449 }
6450 else {
6451 cache.set(path, {
6452 watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
6453 refCount: 1
6454 });
6455 }
6456 callbacksCache.add(path, callback);
6457 return {
6458 close: function () {
6459 var watcher = ts.Debug.checkDefined(cache.get(path));
6460 callbacksCache.remove(path, callback);
6461 watcher.refCount--;
6462 if (watcher.refCount)
6463 return;
6464 cache.delete(path);
6465 ts.closeFileWatcherOf(watcher);
6466 }
6467 };
6468 };
6469 }
6470 ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName;
6471 /**
6472 * Returns true if file status changed

Callers 1

getNodeSystemFunction · 0.85

Calls 8

watchFileFunction · 0.70
getMethod · 0.65
forEachMethod · 0.65
addMethod · 0.65
deleteMethod · 0.65
cbFunction · 0.50
setMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…