(watchFile, useCaseSensitiveFileNames)
| 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 |
no test coverage detected
searching dependent graphs…