(
graphNodes: Iterable<GraphNode>,
graphEdges: Iterable<GraphEdge>,
{ kindFilters = new Set(), langFilters = new Set(), dirScope = "" }: GraphFilters = {},
)
| 35 | } |
| 36 | |
| 37 | export function applyGraphFilters( |
| 38 | graphNodes: Iterable<GraphNode>, |
| 39 | graphEdges: Iterable<GraphEdge>, |
| 40 | { kindFilters = new Set(), langFilters = new Set(), dirScope = "" }: GraphFilters = {}, |
| 41 | ) { |
| 42 | const nodes: GraphNode[] = []; |
| 43 | const keep = new Set<string>(); |
| 44 | for (const node of graphNodes) { |
| 45 | if (kindFilters.size > 0 && !kindFilters.has(kindFamily(node.kind))) continue; |
| 46 | if (langFilters.size > 0 && !langFilters.has(languageForPath(node.file_path))) continue; |
| 47 | if (dirScope && !node.file_path.startsWith(dirScope)) continue; |
| 48 | nodes.push(node); |
| 49 | keep.add(node.id); |
| 50 | } |
| 51 | const edges: GraphEdge[] = []; |
| 52 | for (const edge of graphEdges) { |
| 53 | if (keep.has(edge.source) && keep.has(edge.target)) edges.push(edge); |
| 54 | } |
| 55 | return { nodes, edges }; |
| 56 | } |
| 57 | |
| 58 | export function deriveChipOptions(graphNodes: Iterable<GraphNode>) { |
| 59 | const families = new Set<string>(); |
no test coverage detected