[Metro] Remove duplicated code

This commit is contained in:
Beef 2023-01-07 23:04:35 +00:00
parent aabb478f9c
commit 6de4183647

View file

@ -24,11 +24,13 @@ for (const key in window.modules) {
}
}
const basicFind = (prop: string) => Object.values(window.modules).find(m => m.publicModule.exports?.[prop]).publicModule.exports;
// Hoist React
window.React = Object.values(window.modules).find(m => m.publicModule.exports.createElement).publicModule.exports;
window.React = basicFind("createElement");
// Find moment
let moment = Object.values(window.modules).find(m => m.publicModule.exports.isMoment).publicModule.exports;
let moment = basicFind("isMoment");
// Function to filter through modules
export const filterModules = (modules: MetroModules, single = false) => (filter: (m: any) => boolean) => {