package
Pluralize and singularize any word
npm install pluralizeGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
17.3 kB
Includes dependencies.
Pluralize and singularize any word.
npm install pluralize --save
yarn add pluralize
bower install pluralize --savevar pluralize = require('pluralize')define(function (require, exports, module) {
var pluralize = require('pluralize')
})<script> tag<script src="pluralize.js"></script>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.
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:
pluralize('test') //=> "tests"
pluralize('test', 0) //=> "tests"
pluralize('test', 1) //=> "test"
pluralize('test', 5) //=> "tests"
pluralize('test', 1, true) //=> "1 test"
pluralize('test', 5, true) //=> "5 tests"
pluralize('蘋果', 2, true) //=> "2 蘋果"
// Example of new plural rule:
pluralize.plural('regex') //=> "regexes"
MIT