MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / graphOf

Function graphOf

__tests__/sync.test.ts:41–50  ·  view source on GitHub ↗

Every node and edge by natural key, so two indexes of the same files compare directly.

(cg: CodeGraph)

Source from the content-addressed store, hash-verified

39
40/** Every node and edge by natural key, so two indexes of the same files compare directly. */
41function graphOf(cg: CodeGraph): { nodes: string[]; edges: string[] } {
42 const keys = new Map(
43 cg.getFiles()
44 .flatMap((file) => cg.getNodesInFile(file.path))
45 .map((n) => [n.id, `${n.kind} ${n.filePath}:${n.qualifiedName}:${n.startLine}`] as const)
46 );
47 const edges = cg.getOutgoingEdgesFrom([...keys.keys()])
48 .map((e) => `${e.kind} ${keys.get(e.source)} -> ${keys.get(e.target) ?? e.target}`);
49 return { nodes: [...keys.values()].sort(), edges: edges.sort() };
50}
51
52describe('Sync Module', () => {
53 describe('Sync Functionality', () => {

Callers 1

sync.test.tsFile · 0.70

Calls 5

mapMethod · 0.80
getFilesMethod · 0.80
getNodesInFileMethod · 0.65
getMethod · 0.65
getOutgoingEdgesFromMethod · 0.45

Tested by

no test coverage detected