blob: cd5b3dea22fe64c7b705d004187d2e039ce70106 (
plain)
1
2
3
4
5
6
7
8
9
|
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}`
}
|