1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

showing comments left count

This commit is contained in:
Fedor Katurov 2020-04-09 13:48:26 +07:00
parent 911beea4ad
commit 319e66616c
9 changed files with 101 additions and 115 deletions

View file

@ -152,3 +152,13 @@ export const getYoutubeThumb = (url: string) => {
return match && match[1] ? `https://i.ytimg.com/vi/${match[1]}/hqdefault.jpg` : null;
};
export function plural(n: number, one: string, two: string, five: string) {
if (n % 10 === 1 && n % 100 !== 11) {
return `${n} ${one}`;
} else if (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20)) {
return `${n} ${two}`;
} else {
return `${n} ${five}`;
}
}