Pluralize
Pluralize and singularize any word.
Installation
npm install pluralize --save
yarn add pluralize
bower install pluralize --save
Node
var pluralize =
AMD
<script>
tag
Why?
This module uses a pre-defined list of rules, applied in order, to singularize or pluralize a given word. There are many cases where this is useful, such as any automation based on user input. For applications where the word(s) are known ahead of time, you can use a simple ternary (or function) which would be a much lighter alternative.
Usage
word: string
The word to pluralizecount: number
How many of the word existinclusive: boolean
Whether to prefix with the number (e.g. 3 ducks)
Examples:
//=> "tests" //=> "tests" //=> "test" //=> "tests" //=> "1 test" //=> "5 tests" //=> "2 蘋果" // Example of new plural rule:pluralize //=> "regexes"pluralizepluralize //=> "regexii" // Example of new singular rule:pluralize //=> "single"pluralizepluralize //=> "singular" // Example of new irregular rule, e.g. "I" -> "we":pluralize //=> "irregulars"pluralizepluralize //=> "regular" // Example of uncountable rule (rules without singular/plural in context):pluralize //=> "papers"pluralizepluralize //=> "paper" // Example of asking whether a word looks singular or plural:pluralize //=> falsepluralize //=> true
License
MIT