Multiple miscellaneous fixes

This commit is contained in:
Vanilagy
2025-02-18 22:13:21 +01:00
parent 3848a59ec3
commit 7988b6c2f8
9 changed files with 50 additions and 39 deletions
+9
View File
@@ -393,6 +393,10 @@ export const roundToPrecision = (value: number, digits: number) => {
return Math.round(value * factor) / factor;
};
export const roundToMultiple = (value: number, multiple: number) => {
return Math.round(value / multiple) * multiple;
};
export const ilog = (x: number) => {
let ret = 0;
while (x) {
@@ -401,3 +405,8 @@ export const ilog = (x: number) => {
}
return ret;
};
const ISO_639_2_REGEX = /^[a-z]{3}$/;
export const isIso639Dash2LanguageCode = (x: string) => {
return ISO_639_2_REGEX.test(x);
};