All files / app/codeCharta/state/effects/updateFileSettings/utils attributeTypes.merger.ts

100% Statements 11/11
100% Branches 2/2
100% Functions 1/1
100% Lines 11/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 21 22 23 24 25 26    2x 4x 4x   4x 7x 11x 7x       7x 7x 6x         4x          
import { AttributeTypes } from "../../../../codeCharta.model"
 
export function getMergedAttributeTypes(allAttributeTypes: AttributeTypes[]): AttributeTypes {
    const attributeTypesNodes = {}
    const attributeTypesEdges = {}
 
    for (const attributeTypes of allAttributeTypes) {
        for (const metric of Object.keys(attributeTypes.nodes)) {
            if (!attributeTypesNodes[metric]) {
                attributeTypesNodes[metric] = attributeTypes.nodes[metric]
            }
        }
 
        for (const metric of Object.keys(attributeTypes.edges)) {
            if (!attributeTypesEdges[metric]) {
                attributeTypesEdges[metric] = attributeTypes.edges[metric]
            }
        }
    }
 
    return {
        nodes: attributeTypesNodes,
        edges: attributeTypesEdges
    }
}