import { Struct } from './struct'; import { load } from './loader'; import { extendErrorMessage } from './common'; // Store Loaded Structures const structures: Record = {}; // Get Or Load Structure export function getStructure(name: string) { if (structures[name]) { // Already Loaded return structures[name]; } else { // Load Structure try { // Create Structure const target = new Struct(name); structures[name] = target; // Parse File load(target, name, false); // Return return target; } catch (e) { throw new Error(extendErrorMessage(e, 'Loading ' + name)); } } }