[Metro] Remove duplicated code
This commit is contained in:
parent
aabb478f9c
commit
6de4183647
1 changed files with 4 additions and 2 deletions
|
@ -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
|
// Hoist React
|
||||||
window.React = Object.values(window.modules).find(m => m.publicModule.exports.createElement).publicModule.exports;
|
window.React = basicFind("createElement");
|
||||||
|
|
||||||
// Find moment
|
// 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
|
// Function to filter through modules
|
||||||
export const filterModules = (modules: MetroModules, single = false) => (filter: (m: any) => boolean) => {
|
export const filterModules = (modules: MetroModules, single = false) => (filter: (m: any) => boolean) => {
|
||||||
|
|
Loading…
Reference in a new issue