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

Function containsPath

test/fixtures/snapshot/typescript.js:8112–8137  ·  view source on GitHub ↗
(parent, child, currentDirectory, ignoreCase)

Source from the content-addressed store, hash-verified

8110 }
8111 ts.comparePaths = comparePaths;
8112 function containsPath(parent, child, currentDirectory, ignoreCase) {
8113 if (typeof currentDirectory === "string") {
8114 parent = combinePaths(currentDirectory, parent);
8115 child = combinePaths(currentDirectory, child);
8116 }
8117 else if (typeof currentDirectory === "boolean") {
8118 ignoreCase = currentDirectory;
8119 }
8120 if (parent === undefined || child === undefined)
8121 return false;
8122 if (parent === child)
8123 return true;
8124 var parentComponents = reducePathComponents(getPathComponents(parent));
8125 var childComponents = reducePathComponents(getPathComponents(child));
8126 if (childComponents.length < parentComponents.length) {
8127 return false;
8128 }
8129 var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
8130 for (var i = 0; i < parentComponents.length; i++) {
8131 var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
8132 if (!equalityComparer(parentComponents[i], childComponents[i])) {
8133 return false;
8134 }
8135 }
8136 return true;
8137 }
8138 ts.containsPath = containsPath;
8139 /**
8140 * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.

Callers

nothing calls this directly

Calls 3

combinePathsFunction · 0.85
reducePathComponentsFunction · 0.85
getPathComponentsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…