MCPcopy Create free account
hub / github.com/npm/cli / getChildren

Method getChildren

lib/commands/ls.js:123–149  ·  view source on GitHub ↗
(node, nodeResult)

Source from the content-addressed store, hash-verified

121 tree,
122 // recursive method, `node` is going to be the current elem (starting from the `tree` obj) that was just visited in the `visit` method below `nodeResult` is going to be the returned `item` from `visit`
123 getChildren (node, nodeResult) {
124 const seenPaths = new Set()
125 const workspace = node.isWorkspace
126 const currentDepth = workspace ? 0 : node[_depth]
127 const shouldSkipChildren =
128 !(node instanceof Arborist.Node) || (currentDepth > depthToPrint)
129 return (shouldSkipChildren)
130 ? []
131 : [...(node.target).edgesOut.values()]
132 .filter(filterBySelectedWorkspaces)
133 .filter(currentDepth === 0 ? filterByEdgesTypes({
134 link,
135 omit,
136 }) : () => true)
137 .filter(installStrategy === 'linked'
138 ? filterLinkedStrategyEdges({ currentDepth })
139 : () => true)
140 .map(mapEdgesToNodes({ seenPaths }))
141 .concat(appendExtraneousChildren({ node, seenPaths }))
142 .sort(sortAlphabetically)
143 .map(augmentNodesWithMetadata({
144 args,
145 currentDepth,
146 nodeResult,
147 seenNodes,
148 }))
149 },
150 // visit each `node` of the `tree`, returning an `item` - these are the elements that will be used to build the final output
151 visit (node) {
152 node[_problems] = getProblems(node, { global })

Callers

nothing calls this directly

Calls 6

filterByEdgesTypesFunction · 0.85
mapEdgesToNodesFunction · 0.85
appendExtraneousChildrenFunction · 0.85
augmentNodesWithMetadataFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected