All files / app/codeCharta/state/selectors/accumulatedData/utils addEdgeMetricsForLeaves.ts

41.66% Statements 5/12
0% Branches 0/2
0% Functions 0/1
36.36% Lines 4/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2182x   82x   82x   82x                            
import { hierarchy } from "d3-hierarchy"
import { CodeMapNode } from "../../../../codeCharta.model"
import { isLeaf } from "../../../../util/codeMapHelper"
import { NodeEdgeMetricsMap } from "../metricData/edgeMetricData.calculator"
import { getMetricValuesForNode } from "./getMetricValuesForNode"
 
export const addEdgeMetricsForLeaves = (nodeEdgeMetricsMap: NodeEdgeMetricsMap, map: CodeMapNode, metricNames: string[]) => {
    Iif (metricNames.length === 0) {
        return
    }
 
    for (const node of hierarchy(map)) {
        Iif (isLeaf(node)) {
            const edgeMetrics = getMetricValuesForNode(nodeEdgeMetricsMap, node, metricNames)
            for (const [key, value] of edgeMetrics) {
                node.data.edgeAttributes[key] = value
            }
        }
    }
}