mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-30 06:34:35 +02:00
refactor(Patches): use find() instead of for loop
This commit is contained in:
parent
26dbc8ec84
commit
a4267a99f6
@ -25,27 +25,19 @@
|
|||||||
let timeout: any = null;
|
let timeout: any = null;
|
||||||
let mobilePackages = false;
|
let mobilePackages = false;
|
||||||
|
|
||||||
function filterByPackage(pkg: string | undefined, packageList: any) {
|
function filterByPackage(pkg: string | undefined, packageList: any[]) {
|
||||||
for (let i = 0; i < packageList.length; i++) {
|
return packageList.find((x: Package) => x.name === pkg);
|
||||||
if (packageList[i].name === pkg) {
|
}
|
||||||
return true;
|
|
||||||
}
|
function checkPkgName(pkg: string, packageList: any[]) {
|
||||||
}
|
// Basically the same function as before lol
|
||||||
|
return packageList.find((x: Package) => x.name.replace(/\./g, '').includes(pkg));
|
||||||
}
|
}
|
||||||
|
|
||||||
function search(patch: Patch) {
|
function search(patch: Patch) {
|
||||||
function checkPkgName(pkg: string | undefined, packageList: any) {
|
|
||||||
// Basically the same function as before lol
|
|
||||||
for (let i = 0; i < packageList.length; i++) {
|
|
||||||
if (packageList[i].name.replace(/\./g, '').includes(pkg)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
patch.description.toLowerCase().replace(/\s/g, '').includes(searchTermFiltered) ||
|
patch.description.toLowerCase().replace(/\s/g, '').includes(searchTermFiltered) ||
|
||||||
patch.name.replace(/-/g, '').toLowerCase().includes(searchTermFiltered) ||
|
patch.name.toLowerCase().replace(/-/g, '').includes(searchTermFiltered) ||
|
||||||
checkPkgName(searchTermFiltered, patch.compatiblePackages)
|
checkPkgName(searchTermFiltered, patch.compatiblePackages)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user