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

Function cleanupPaths

test/fixtures/snapshot/typescript.js:7124–7144  ·  view source on GitHub ↗

* Strips non-TS paths from the profile, so users with private projects shouldn't * need to worry about leaking paths by submitting a cpu profile to us

(profile)

Source from the content-addressed store, hash-verified

7122 * need to worry about leaking paths by submitting a cpu profile to us
7123 */
7124 function cleanupPaths(profile) {
7125 var externalFileCounter = 0;
7126 var remappedPaths = new ts.Map();
7127 var normalizedDir = ts.normalizeSlashes(__dirname);
7128 // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls
7129 var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir);
7130 for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) {
7131 var node = _a[_i];
7132 if (node.callFrame.url) {
7133 var url = ts.normalizeSlashes(node.callFrame.url);
7134 if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) {
7135 node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true);
7136 }
7137 else if (!nativePattern.test(url)) {
7138 node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url);
7139 externalFileCounter++;
7140 }
7141 }
7142 }
7143 return profile;
7144 }
7145 function disableCPUProfiler(cb) {
7146 if (activeSession && activeSession !== "stopping") {
7147 var s_1 = activeSession;

Callers 1

disableCPUProfilerFunction · 0.85

Calls 5

concatMethod · 0.80
getMethod · 0.65
hasMethod · 0.65
testMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…