(entry: EngramEntry)
| 80 | } |
| 81 | |
| 82 | function buildNode(entry: EngramEntry): MemoryTreeNode { |
| 83 | visited.add(entry.slug); |
| 84 | const children: MemoryTreeNode[] = []; |
| 85 | for (const refSlug of entry.outgoingRefs) { |
| 86 | const target = bySlug.get(refSlug); |
| 87 | if (!target) { |
| 88 | recordDangling(refSlug, entry.slug); |
| 89 | continue; |
| 90 | } |
| 91 | // Skip self-refs and already-visited nodes; the visited guard makes |
| 92 | // the recursion finite even on cyclic graphs. |
| 93 | if (visited.has(target.slug)) continue; |
| 94 | children.push(buildNode(target)); |
| 95 | } |
| 96 | return { entry, children }; |
| 97 | } |
| 98 | |
| 99 | const rootedTree = listing.core ? buildNode(listing.core) : null; |
| 100 |
no test coverage detected