mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 17:12:43 +00:00
refactor: initalize meta classes in translator
This commit is contained in:
@@ -77,6 +77,13 @@ export class SCThingTranslator {
|
|||||||
this.sourceCache = new LRUCache(cacheCapacity);
|
this.sourceCache = new LRUCache(cacheCapacity);
|
||||||
this._language = language;
|
this._language = language;
|
||||||
this.metaClasses = SCClasses;
|
this.metaClasses = SCClasses;
|
||||||
|
|
||||||
|
// Initalize all meta classes once
|
||||||
|
if (typeof (this.metaClasses as any)[Object.keys(this.metaClasses)[0]] === 'function') {
|
||||||
|
for (const metaClass of Object.keys(this.metaClasses)) {
|
||||||
|
(this.metaClasses as any)[metaClass] = new (SCClasses as any)[metaClass]();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,7 +150,7 @@ export class SCThingTranslator {
|
|||||||
*/
|
*/
|
||||||
private getMetaClassInstance(thingType: SCThingType): any {
|
private getMetaClassInstance(thingType: SCThingType): any {
|
||||||
if (thingType in this.metaClasses) {
|
if (thingType in this.metaClasses) {
|
||||||
return new (this.metaClasses as any)[thingType]();
|
return this.metaClasses[thingType];
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user