main code

This commit is contained in:
Akshat Mehta
2025-11-23 11:03:57 +05:30
parent 0737ead33d
commit edd5728428
705 changed files with 80627 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
function applyRules(rules, navigator, data) {
const { userAgent } = navigator !== null && navigator !== void 0 ? navigator : {};
if (typeof userAgent !== 'string' || userAgent.trim() === '') {
return data;
}
for (const rule of rules){
const patterns = rule.slice(0, -1);
const parser = rule[rule.length - 1];
let match = null;
for (const pattern of patterns){
match = userAgent.match(pattern);
if (match !== null) {
Object.assign(data, parser(match, navigator, data));
break;
}
}
if (match !== null) break;
}
return data;
}
export { applyRules };