mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
23 lines
475 B
JavaScript
23 lines
475 B
JavaScript
(function () {
|
|
const modules = {};
|
|
const cache = {};
|
|
|
|
window.registerModule = function (name, factory) {
|
|
modules[name] = factory;
|
|
};
|
|
|
|
window.requireModule = function (name) {
|
|
if (cache[name]) {
|
|
return cache[name];
|
|
}
|
|
const factory = modules[name];
|
|
if (!factory) {
|
|
throw new Error(`Module ${name} not found`);
|
|
}
|
|
const exports = {};
|
|
cache[name] = exports;
|
|
factory(requireModule, exports);
|
|
return exports;
|
|
};
|
|
})();
|