Formats a number with a unit, automatically pluralizing the unit based on the count.
function quantify( count: string | number, unit: string, plural?: string): stringstringFormats a number with a unit, automatically pluralizing the unit based on the count.
string | numberstringstringstringFormats a number with a unit, automatically pluralizing the unit based on the count.
If the count is exactly 1, the singular unit is used.
Otherwise, it either uses the provided plural form or calls
toPlural(unit)
to generate one.
quantify(1, "apple"); // "1 apple"
quantify(3, "apple"); // "3 apples"
quantify("02", "box"); // "02 boxes"
quantify(1, "child", "children"); // "1 child"
quantify(2, "child", "children"); // "2 children"
quantify(5, "CPU"); // "5 CPUs"
