mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 02:44:45 +00:00
8 lines
273 B
TypeScript
8 lines
273 B
TypeScript
export type WordForms = [string, string, string];
|
|
|
|
export const plural = (count: number, words: WordForms): string => {
|
|
const cases = [2, 0, 1, 1, 1, 2];
|
|
return words[
|
|
count % 100 > 4 && count % 100 < 20 ? 2 : cases[Math.min(count % 10, 5)]
|
|
];
|
|
}; |