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

Function pollWatchedFileQueue

test/fixtures/snapshot/typescript.js:6206–6250  ·  view source on GitHub ↗
(host, queue, pollIndex, chunkSize, callbackOnWatchFileStat)

Source from the content-addressed store, hash-verified

6204 }
6205 ts.setCustomPollingValues = setCustomPollingValues;
6206 function pollWatchedFileQueue(host, queue, pollIndex, chunkSize, callbackOnWatchFileStat) {
6207 var definedValueCopyToIndex = pollIndex;
6208 // Max visit would be all elements of the queue
6209 for (var canVisit = queue.length; chunkSize && canVisit; nextPollIndex(), canVisit--) {
6210 var watchedFile = queue[pollIndex];
6211 if (!watchedFile) {
6212 continue;
6213 }
6214 else if (watchedFile.isClosed) {
6215 queue[pollIndex] = undefined;
6216 continue;
6217 }
6218 // Only files polled count towards chunkSize
6219 chunkSize--;
6220 var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(host, watchedFile.fileName));
6221 if (watchedFile.isClosed) {
6222 // Closed watcher as part of callback
6223 queue[pollIndex] = undefined;
6224 continue;
6225 }
6226 callbackOnWatchFileStat === null || callbackOnWatchFileStat === void 0 ? void 0 : callbackOnWatchFileStat(watchedFile, pollIndex, fileChanged);
6227 // Defragment the queue while we are at it
6228 if (queue[pollIndex]) {
6229 // Copy this file to the non hole location
6230 if (definedValueCopyToIndex < pollIndex) {
6231 queue[definedValueCopyToIndex] = watchedFile;
6232 queue[pollIndex] = undefined;
6233 }
6234 definedValueCopyToIndex++;
6235 }
6236 }
6237 // Return next poll index
6238 return pollIndex;
6239 function nextPollIndex() {
6240 pollIndex++;
6241 if (pollIndex === queue.length) {
6242 if (definedValueCopyToIndex < pollIndex) {
6243 // There are holes from definedValueCopyToIndex to end of queue, change queue size
6244 queue.length = definedValueCopyToIndex;
6245 }
6246 pollIndex = 0;
6247 definedValueCopyToIndex = 0;
6248 }
6249 }
6250 }
6251 /* @internal */
6252 function createDynamicPriorityPollingWatchFile(host) {
6253 var watchedFiles = [];

Callers 1

pollQueueFunction · 0.85

Calls 3

nextPollIndexFunction · 0.85
onWatchedFileStatFunction · 0.85
getModifiedTimeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…