All files / app/codeCharta/services/idToBuilding idToBuilding.service.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 3/3
100% Lines 7/7

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 2049x       49x 186x     20x 20x 34x           16x      
import { Injectable } from "@angular/core"
import { CodeMapBuilding } from "../../ui/codeMap/rendering/codeMapBuilding"
 
@Injectable({ providedIn: "root" })
export class IdToBuildingService {
    private idToBuilding = new Map<number, CodeMapBuilding>()
 
    setIdToBuilding(buildings: CodeMapBuilding[]) {
        this.idToBuilding = new Map<number, CodeMapBuilding>()
        for (const building of buildings) {
            this.idToBuilding.set(building.node.id, building)
        }
    }
 
    /** id is buildings' node.id */
    get(id: number) {
        return this.idToBuilding.get(id)
    }
}