Use indexOf in more places

This commit is contained in:
Nuckyz 2024-05-31 05:29:01 -03:00
parent 545d69aa6d
commit f4cc95da5a
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -48,7 +48,7 @@ export const filters = {
if (typeof m !== "function") return false;
const s = Function.prototype.toString.call(m);
for (const c of code) {
if (!s.includes(c)) return false;
if (s.indexOf(c) === -1) return false;
}
return true;
},
@ -229,7 +229,7 @@ export const findModuleId = traceFunction("findModuleId", function findModuleId(
const str = String(wreq.m[id]);
for (const c of code) {
if (!str.includes(c)) continue outer;
if (str.indexOf(c) === -1) continue outer;
}
return id;
}
@ -526,7 +526,7 @@ export function search(...filters: Array<string | RegExp>) {
const factory = factories[id];
const factoryStr = String(factory);
for (const filter of filters) {
if (typeof filter === "string" && !factoryStr.includes(filter)) continue outer;
if (typeof filter === "string" && factoryStr.indexOf(filter) === -1) continue outer;
if (filter instanceof RegExp && !filter.test(factoryStr)) continue outer;
}
results[id] = factory;