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

Function getAllModulePathsWorker

test/fixtures/snapshot/typescript.js:122286–122335  ·  view source on GitHub ↗
(importingFileName, importedFileName, host)

Source from the content-addressed store, hash-verified

122284 return modulePaths;
122285 }
122286 function getAllModulePathsWorker(importingFileName, importedFileName, host) {
122287 var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
122288 var allFileNames = new ts.Map();
122289 var importedFileFromNodeModules = false;
122290 forEachFileNameOfModule(importingFileName, importedFileName, host,
122291 /*preferSymlinks*/ true, function (path, isRedirect) {
122292 var isInNodeModules = ts.pathContainsNodeModules(path);
122293 allFileNames.set(path, { path: getCanonicalFileName(path), isRedirect: isRedirect, isInNodeModules: isInNodeModules });
122294 importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules;
122295 // don't return value, so we collect everything
122296 });
122297 // Sort by paths closest to importing file Name directory
122298 var sortedPaths = [];
122299 var _loop_32 = function (directory) {
122300 var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
122301 var pathsInDirectory;
122302 allFileNames.forEach(function (_a, fileName) {
122303 var path = _a.path, isRedirect = _a.isRedirect, isInNodeModules = _a.isInNodeModules;
122304 if (ts.startsWith(path, directoryStart)) {
122305 (pathsInDirectory || (pathsInDirectory = [])).push({ path: fileName, isRedirect: isRedirect, isInNodeModules: isInNodeModules });
122306 allFileNames.delete(fileName);
122307 }
122308 });
122309 if (pathsInDirectory) {
122310 if (pathsInDirectory.length > 1) {
122311 pathsInDirectory.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
122312 }
122313 sortedPaths.push.apply(sortedPaths, pathsInDirectory);
122314 }
122315 var newDirectory = ts.getDirectoryPath(directory);
122316 if (newDirectory === directory)
122317 return out_directory_1 = directory, "break";
122318 directory = newDirectory;
122319 out_directory_1 = directory;
122320 };
122321 var out_directory_1;
122322 for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
122323 var state_10 = _loop_32(directory);
122324 directory = out_directory_1;
122325 if (state_10 === "break")
122326 break;
122327 }
122328 if (allFileNames.size) {
122329 var remainingPaths = ts.arrayFrom(allFileNames.values());
122330 if (remainingPaths.length > 1)
122331 remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
122332 sortedPaths.push.apply(sortedPaths, remainingPaths);
122333 }
122334 return sortedPaths;
122335 }
122336 function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) {
122337 var _a;
122338 var decl = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); });

Callers 2

getAllModulePathsFunction · 0.85

Calls 7

forEachFileNameOfModuleFunction · 0.85
getCanonicalFileNameFunction · 0.85
_loop_32Function · 0.85
sortMethod · 0.80
setMethod · 0.45
valuesMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…