monogon
Version:
Modern syntax highlighting for developer tooling
25 lines • 1.01 kB
JavaScript
import { monoLog } from './utils.js';
const supportedModules = ['plaintext', 'json', 'yaml', 'css'];
const moduleMap = {
plaintext: () => import('./modules/plaintext.js'),
json: () => import('./modules/json.js'),
yaml: () => import('./modules/yaml.js'),
css: () => import('./modules/css.js'),
};
export const getModule = async (name) => {
// @ts-expect-error - name is user-defined, can be any string
if (!supportedModules.includes(name)) {
monoLog(`Language "${name}" not found, unable to process. Select a supported lang param`, true);
monoLog(`Supported: ${supportedModules.toString()}`, true);
const plaintext = await moduleMap['plaintext']();
return plaintext.default;
}
const module = await moduleMap[name]();
if (!module) {
monoLog(`Language "${name}" not found`);
const plaintext = await moduleMap['plaintext']();
return plaintext.default;
}
return module.default;
};
//# sourceMappingURL=modules.js.map