es-guard
Version:
A tool to check JavaScript compatibility with target environments
17 lines • 590 B
JavaScript
/**
* Returns the plural form of a word based on the count.
* Simple English pluralization: adds 's' for plural, keeps singular for count of 1.
*
* @param word - The word to pluralize
* @param count - The count to determine if plural is needed
* @returns The singular word if count is 1, otherwise the plural form (word + 's')
*
* @example
* pluralize("error", 1) // "error"
* pluralize("error", 2) // "errors"
* pluralize("warning", 0) // "warnings"
*/
export function pluralize(word, count) {
return count === 1 ? word : `${word}s`;
}
//# sourceMappingURL=pluralize.js.map