mirror of
https://github.com/NovaGM/ModuleBuilder.git
synced 2024-08-15 00:23:33 +00:00
34 lines
No EOL
934 B
JavaScript
34 lines
No EOL
934 B
JavaScript
const makeFinalFilter = (filter) => {
|
|
if (Array.isArray(filter)) {
|
|
const subs = filter;
|
|
filter = (mod) => subs.every((s) => mod[s] || (mod.__proto__ && mod.__proto__[s]));
|
|
}
|
|
|
|
return filter;
|
|
};
|
|
|
|
module.exports = {
|
|
getModule: (filter, retry, _forever) => { // Ignoring retry and forever arguments for basic implementation
|
|
filter = makeFinalFilter(filter);
|
|
|
|
const result = goosemodScope.webpackModules.find(filter);
|
|
|
|
if (!retry) { // retry = false: sync, retry = true: async (returns Promise)
|
|
return result;
|
|
}
|
|
|
|
return new Promise((res) => res(result));
|
|
},
|
|
|
|
getAllModules: (filter) => {
|
|
filter = makeFinalFilter(filter);
|
|
|
|
return goosemodScope.webpackModules.findAll(filter);
|
|
},
|
|
|
|
getModuleByDisplayName: (displayName) => {
|
|
return goosemodScope.webpackModules.findByDisplayName(displayName);
|
|
},
|
|
|
|
...goosemodScope.webpackModules.common // Export common modules (eg: React)
|
|
}; |