homepage/out/_/jd3ymgfg3gk6vrlaxhbn/moduleruntime.js
2022-03-01 22:41:44 +02:00

26 lines
718 B
JavaScript

const modules = {
_cache: {},
_registry: {},
require(moduleName) {
if (this._cache[moduleName]) {
return this._cache[moduleName];
}
if (this._registry[moduleName]) {
const loaderFunction = this._registry[moduleName];
this._cache[moduleName] = loaderFunction(1);
return this._cache[moduleName];
}
return null;
},
register(moduleName, loaderFunction) {
this._registry[moduleName] = loaderFunction;
this._cache[moduleName] = loaderFunction(0);
},
registerLazy(moduleName, loaderFunction) {
this._registry[moduleName] = loaderFunction;
}
};
window.modules = modules;