UNPKG

fix-client

Version:
26 lines (21 loc) 699 B
const { COMPONENTS } = require('../spec/SpecComponents'); class Components { constructor() { this.components = COMPONENTS; this.cacheMap = new Map(); this.cacheMapByName = new Map(); this.components.forEach((component) => { this.cacheMap.set(component.ComponentID, component); }); this.components.forEach((component) => { this.cacheMapByName.set(component.Name, component); }); } find(componentId) { return this.cacheMap.get(String(componentId)); } findByName(name) { return this.cacheMapByName.get(String(name)); } } module.exports = { Components }