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

Function graphOf

__tests__/sync.test.ts:40–49  ·  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

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