mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
modularize code, add dummy version of roverd
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
(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;
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user