Stirling-PDF/shared-operations/src/workflow/getOperatorByName.ts
2023-11-21 14:57:58 +01:00

31 lines
930 B
TypeScript

import { Operator } from "../functions";
// TODO: Import other Operators (could make this dynamic)
import { Impose } from "../functions/impose";
export const Operators = {
Impose: Impose
}
// TODO: Convert this to a map or similar
export function getOperatorByName(name: string): typeof Operator | undefined {
let foundClass: typeof Operator | undefined = undefined;
// Loop over each default export
Object.entries(Operators).some(([className, exportedClass]) => {
// Check if the exported item is a class
if (typeof exportedClass === 'function' && exportedClass.prototype) {
if (exportedClass.type === name) {
foundClass = exportedClass;
return true; // Stop the iteration
}
}
return false;
});
return foundClass;
}
export function listOperatorNames(): string[] {
// TODO: Implement this
return [];
}