MCPcopy Index your code
hub / github.com/angular/angular / findPath

Function findPath

packages/router/src/utils/tree.ts:77–89  ·  view source on GitHub ↗
(value: T, node: TreeNode<T>)

Source from the content-addressed store, hash-verified

75
76// Return the path to the node with the given value using DFS
77function findPath<T>(value: T, node: TreeNode<T>): TreeNode<T>[] {
78 if (value === node.value) return [node];
79
80 for (const child of node.children) {
81 const path = findPath(value, child);
82 if (path.length) {
83 path.unshift(node);
84 return path;
85 }
86 }
87
88 return [];
89}
90
91export class TreeNode<T> {
92 constructor(

Callers 2

siblingsMethod · 0.85
pathFromRootMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…