diff options
author | Vendicated <vendicated@riseup.net> | 2022-09-27 14:34:57 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-09-27 14:34:57 +0200 |
commit | 6398dd25d20e6bc3e02425b709233066baf64e0c (patch) | |
tree | 3502593fdb4912c678ce6e840726114ccdb8c218 /src/webpack | |
parent | d0940a8b194805173dae029d0fe284974ffecc7a (diff) | |
download | Vencord-6398dd25d20e6bc3e02425b709233066baf64e0c.tar.gz Vencord-6398dd25d20e6bc3e02425b709233066baf64e0c.tar.bz2 Vencord-6398dd25d20e6bc3e02425b709233066baf64e0c.zip |
Unbrick Vencord - Pt 1
Diffstat (limited to 'src/webpack')
-rw-r--r-- | src/webpack/webpack.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 27306de..a1fd2fb 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -32,15 +32,22 @@ export function find(filter: FilterFn, getDefault = true) { for (const key in cache) { const mod = cache[key]; - if (mod?.exports && filter(mod.exports)) + if (!mod?.exports) continue; + + if (filter(mod.exports)) return mod.exports; - if (mod?.exports?.default && filter(mod.exports.default)) + if (mod.exports.default && filter(mod.exports.default)) return getDefault ? mod.exports.default : mod.exports; + for (const nestedMod in mod.exports) { + const nested = mod.exports[nestedMod]; + if (nested && filter(nested)) return nested; + } } return null; } +// TODO fix export function findAll(filter: FilterFn, getDefault = true) { if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got", filter); |