27 lines
1023 B
JavaScript
27 lines
1023 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.registerGameModule = registerGameModule;
|
|
exports.getGameModuleByImplementation = getGameModuleByImplementation;
|
|
exports.listRegisteredModules = listRegisteredModules;
|
|
exports.listRegisteredImplementationKeys = listRegisteredImplementationKeys;
|
|
exports.isRegisteredImplementationKey = isRegisteredImplementationKey;
|
|
const modules = new Map();
|
|
function registerGameModule(mod) {
|
|
if (modules.has(mod.implementationKey)) {
|
|
throw new Error(`Game module already registered: ${mod.implementationKey}`);
|
|
}
|
|
modules.set(mod.implementationKey, mod);
|
|
}
|
|
function getGameModuleByImplementation(key) {
|
|
return modules.get(key);
|
|
}
|
|
function listRegisteredModules() {
|
|
return [...modules.values()];
|
|
}
|
|
function listRegisteredImplementationKeys() {
|
|
return listRegisteredModules().map((m) => m.implementationKey);
|
|
}
|
|
function isRegisteredImplementationKey(key) {
|
|
return modules.has(key);
|
|
}
|
|
//# sourceMappingURL=registry.js.map
|