summaryrefslogtreecommitdiff
path: root/source/helpers/pluralize.ts
blob: e0ed4e33ac0db34601fb64ce1b84a91c7e786204 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
export default function pluralize(count: number, single: string, plural: string, zero?: string): string {
	if (count === 0 && zero) {
		return zero.replace('$$', '0');
	}

	if (count === 1) {
		return single.replace('$$', '1');
	}

	return plural.replace('$$', String(count));
}