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

Function createSystemWatchFunctions

test/fixtures/snapshot/typescript.js:6764–6899  ·  view source on GitHub ↗
(_a)

Source from the content-addressed store, hash-verified

6762 }
6763 /*@internal*/
6764 function createSystemWatchFunctions(_a) {
6765 var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind;
6766 var dynamicPollingWatchFile;
6767 var fixedChunkSizePollingWatchFile;
6768 var nonPollingWatchFile;
6769 var hostRecursiveDirectoryWatcher;
6770 return {
6771 watchFile: watchFile,
6772 watchDirectory: watchDirectory
6773 };
6774 function watchFile(fileName, callback, pollingInterval, options) {
6775 options = updateOptionsForWatchFile(options, useNonPollingWatchers);
6776 var watchFileKind = ts.Debug.checkDefined(options.watchFile);
6777 switch (watchFileKind) {
6778 case ts.WatchFileKind.FixedPollingInterval:
6779 return pollingWatchFile(fileName, callback, PollingInterval.Low, /*options*/ undefined);
6780 case ts.WatchFileKind.PriorityPollingInterval:
6781 return pollingWatchFile(fileName, callback, pollingInterval, /*options*/ undefined);
6782 case ts.WatchFileKind.DynamicPriorityPolling:
6783 return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, /*options*/ undefined);
6784 case ts.WatchFileKind.FixedChunkSizePolling:
6785 return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined);
6786 case ts.WatchFileKind.UseFsEvents:
6787 return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists),
6788 /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options));
6789 case ts.WatchFileKind.UseFsEventsOnParentDirectory:
6790 if (!nonPollingWatchFile) {
6791 nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames);
6792 }
6793 return nonPollingWatchFile(fileName, callback, pollingInterval, ts.getFallbackOptions(options));
6794 default:
6795 ts.Debug.assertNever(watchFileKind);
6796 }
6797 }
6798 function ensureDynamicPollingWatchFile() {
6799 return dynamicPollingWatchFile || (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout }));
6800 }
6801 function ensureFixedChunkSizePollingWatchFile() {
6802 return fixedChunkSizePollingWatchFile || (fixedChunkSizePollingWatchFile = createFixedChunkSizePollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout }));
6803 }
6804 function updateOptionsForWatchFile(options, useNonPollingWatchers) {
6805 if (options && options.watchFile !== undefined)
6806 return options;
6807 switch (tscWatchFile) {
6808 case "PriorityPollingInterval":
6809 // Use polling interval based on priority when create watch using host.watchFile
6810 return { watchFile: ts.WatchFileKind.PriorityPollingInterval };
6811 case "DynamicPriorityPolling":
6812 // Use polling interval but change the interval depending on file changes and their default polling interval
6813 return { watchFile: ts.WatchFileKind.DynamicPriorityPolling };
6814 case "UseFsEvents":
6815 // Use notifications from FS to watch with falling back to fs.watchFile
6816 return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.PriorityInterval, options);
6817 case "UseFsEventsWithFallbackDynamicPolling":
6818 // Use notifications from FS to watch with falling back to dynamic watch file
6819 return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.DynamicPriority, options);
6820 case "UseFsEventsOnParentDirectory":
6821 useNonPollingWatchers = true;

Callers 1

getNodeSystemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…