MCPcopy Index your code
hub / github.com/deepops-ai/deepops / getPath

Method getPath

ui/src/utils/treeNode.ts:64–85  ·  view source on GitHub ↗
(search)

Source from the content-addressed store, hash-verified

62 }
63
64 getPath(search) {
65 const searchFn = TreeNode.iterFunction(TreeNode.searchFunction(search));
66
67 const findPath = (currentNode, currentPath) => {
68 // skip if we already found the result
69 const attempt = currentPath.concat([currentNode]);
70 // base case: return the array when there is a match
71 if (searchFn(currentNode)) {
72 return attempt;
73 }
74 for (let i = 0; i < currentNode.children.length; i++) {
75 const child = currentNode.children[i];
76 const match = findPath(child, attempt);
77 if (match) {
78 return match;
79 }
80 }
81 return null;
82 };
83
84 return findPath(this, []);
85 }
86
87 walk(fn, depth = 0) {
88 const nodeStack = [];

Callers 4

measureTextFunction · 0.80
getTextFunction · 0.80
measureTextFunction · 0.80
getTextFunction · 0.80

Calls 2

iterFunctionMethod · 0.80
searchFunctionMethod · 0.80

Tested by

no test coverage detected