0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Update utils.ts: Optimize and simplify code (#10749)

Update utils.ts: Optimize and simplify code
This commit is contained in:
aswind7 2024-04-11 17:04:22 +08:00 committed by GitHub
parent 7e825604dd
commit f1bc3dea92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -71,11 +71,7 @@ function sortAndFilterLocales(browserLocaleList: BrowserLocale[], locales: Local
})
.sort((a, b) => {
if (a.qualityValue && b.qualityValue) {
if (a.qualityValue > b.qualityValue) {
return -1;
} else if (a.qualityValue < b.qualityValue) {
return 1;
}
return Math.sign(b.qualityValue - a.qualityValue);
}
return 0;
});