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

Function explainFrom

deps/npm/lib/utils/explain-dep.js:96–114  ·  view source on GitHub ↗
(from, depth, chalk, seen)

Source from the content-addressed store, hash-verified

94}
95
96const explainFrom = (from, depth, chalk, seen) => {
97 if (!from.name && !from.version) {
98 return 'the root project'
99 }
100
101 // Prevent infinite recursion from cycles in the dependency graph (e.g. linked strategy store nodes). Use stack-based tracking so diamond dependencies (same node reached via different paths) are still explained, but recursive cycles are broken.
102 const nodeId = `${from.name}@${from.version}:${from.location}`
103 if (seen.has(nodeId)) {
104 return printNode(from, chalk)
105 }
106 seen.add(nodeId)
107
108 const result = printNode(from, chalk) +
109 explainDependents(from, depth - 1, chalk, seen) +
110 explainLinksIn(from, depth - 1, chalk, seen)
111
112 seen.delete(nodeId)
113 return result
114}
115
116module.exports = { explainNode, printNode, explainEdge }

Callers 1

explainEdgeFunction · 0.85

Calls 6

explainDependentsFunction · 0.85
explainLinksInFunction · 0.85
printNodeFunction · 0.70
hasMethod · 0.65
addMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected