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

Function parseNodeModuleFromPath

test/fixtures/snapshot/typescript.js:43492–43504  ·  view source on GitHub ↗
(resolved)

Source from the content-addressed store, hash-verified

43490 */
43491 /* @internal */
43492 function parseNodeModuleFromPath(resolved) {
43493 var path = ts.normalizePath(resolved);
43494 var idx = path.lastIndexOf(ts.nodeModulesPathPart);
43495 if (idx === -1) {
43496 return undefined;
43497 }
43498 var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length;
43499 var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
43500 if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) {
43501 indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
43502 }
43503 return path.slice(0, indexAfterPackageName);
43504 }
43505 ts.parseNodeModuleFromPath = parseNodeModuleFromPath;
43506 function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
43507 var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);

Callers 1

Calls 2

sliceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…