feat: search filtering and better weighting

This commit is contained in:
Oleksandr 2026-03-16 10:59:00 +02:00 committed by outfoxxed
parent 1cafa09456
commit ea02034a3c
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
4 changed files with 59 additions and 9 deletions

13
src/config/io/search.ts Normal file
View file

@ -0,0 +1,13 @@
function getSearchWeight(version: string) {
const versionArr = version.split(".");
versionArr[0] = versionArr[0].substring(1);
const searchWeightArr = versionArr.map(w => parseInt(w));
const weight = searchWeightArr.reduce((p, c, i, _) => {
const mult = i - 1 === 0 || i === 0 ? 10 : 1;
const acc = p * mult + c * mult;
return acc;
});
return weight;
}
export { getSearchWeight };