Fix webpack search

This commit is contained in:
Vendicated 2022-10-09 22:15:14 +02:00
parent e7fb4ebd4e
commit f875d63c6d
No known key found for this signature in database
GPG Key ID: EC781ADFB93EFFA3

@ -59,7 +59,7 @@ export function find(filter: FilterFn, getDefault = true) {
// is 3 is the longest obfuscated export? // is 3 is the longest obfuscated export?
// the length check makes search about 20% faster // the length check makes search about 20% faster
for (const nestedMod in mod.exports) if (nestedMod.length < 3) { for (const nestedMod in mod.exports) if (nestedMod.length <= 3) {
const nested = mod.exports[nestedMod]; const nested = mod.exports[nestedMod];
if (nested && filter(nested)) return nested; if (nested && filter(nested)) return nested;
} }
@ -68,7 +68,6 @@ export function find(filter: FilterFn, getDefault = true) {
return null; return null;
} }
// TODO fix
export function findAll(filter: FilterFn, getDefault = true) { export function findAll(filter: FilterFn, getDefault = true) {
if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got " + typeof filter); if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got " + typeof filter);
@ -84,7 +83,7 @@ export function findAll(filter: FilterFn, getDefault = true) {
if (mod.exports.default && filter(mod.exports.default)) if (mod.exports.default && filter(mod.exports.default))
ret.push(getDefault ? mod.exports.default : mod.exports); ret.push(getDefault ? mod.exports.default : mod.exports);
else for (const nestedMod in mod.exports) if (nestedMod.length < 3) { else for (const nestedMod in mod.exports) if (nestedMod.length <= 3) {
const nested = mod.exports[nestedMod]; const nested = mod.exports[nestedMod];
if (nested && filter(nested)) ret.push(nested); if (nested && filter(nested)) ret.push(nested);
} }