MCPcopy Create free account
hub / github.com/arctic-cli/interface / getPath

Function getPath

packages/arctic/src/file/ripgrep.ts:266–282  ·  view source on GitHub ↗
(node: Node, parts: string[], create: boolean)

Source from the content-addressed store, hash-verified

264 }
265
266 function getPath(node: Node, parts: string[], create: boolean) {
267 if (parts.length === 0) return node
268 let current = node
269 for (const part of parts) {
270 let existing = current.children.find((x) => x.path.at(-1) === part)
271 if (!existing) {
272 if (!create) return
273 existing = {
274 path: current.path.concat(part),
275 children: [],
276 }
277 current.children.push(existing)
278 }
279 current = existing
280 }
281 return current
282 }
283
284 const root: Node = {
285 path: [],

Callers 1

treeFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected