blob: 3716367782d87e33005a3afd77d1c56eb0ac4bdc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
export function unit(
n: number,
singular: string,
plural: string,
f: (n: number, unit: string) => string = format
): string {
return n > 1
? f(n, plural)
: f(n, singular)
}
function format(n: number, unit: string): string {
return `${n} ${unit}`
}
|