MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / findNodeInTreeById

Function findNodeInTreeById

app/hooks/useVirtualTree.ts:724–743  ·  view source on GitHub ↗
(
  nodes: T[],
  id: string
)

Source from the content-addressed store, hash-verified

722
723// Finds the node in the list of nodes or recursively in the children
724function findNodeInTreeById<T extends { id: string; children?: T[] }>(
725 nodes: T[],
726 id: string
727): T | undefined {
728 const node = nodes.find((node) => node.id === id);
729
730 if (node) {
731 return node;
732 }
733
734 for (const node of nodes) {
735 const foundNode = findNodeInTreeById(node.children || [], id);
736
737 if (foundNode) {
738 return foundNode;
739 }
740 }
741
742 return;
743}
744
745function calculatePathToNode<T extends { id: string; children?: T[] }>(
746 nodes: T[],

Callers 1

useVirtualTreeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected