node/tools/eslint/node_modules/pluralize
Rich Trott 6a76485ad7 tools: update ESLint to 2.9.0
ESLint 2.9.0 fixes some minor bugs that we have been experiencing and
introduces some new rules that we may wish to consider.

PR-URL: https://github.com/nodejs/node/pull/6498
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-06-23 17:25:14 -07:00
..
LICENSE tools: update ESLint to version 2.1.0 2016-03-02 14:01:11 -08:00
package.json tools: update ESLint to 2.9.0 2016-06-23 17:25:14 -07:00
pluralize.js tools: update ESLint to version 2.1.0 2016-03-02 14:01:11 -08:00
Readme.md tools: update ESLint to version 2.1.0 2016-03-02 14:01:11 -08:00

Pluralize

NPM version NPM downloads Build status Test coverage

Pluralize and singularize any word.

Installation

npm install pluralize --save
bower install pluralize --save

Node

var pluralize = require('pluralize')

AMD

define(function (require, exports, module) {
  var pluralize = require('pluralize')
})

<script> tag

<script src="pluralize.js"></script>

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

pluralize('test') //=> "tests"
pluralize('test', 1) //=> "test"
pluralize('test', 5) //=> "tests"
pluralize('test', 1, true) //=> "1 test"
pluralize('test', 5, true) //=> "5 tests"

pluralize.plural('regex') //=> "regexes"
pluralize.addPluralRule(/gex$/i, 'gexii')
pluralize.plural('regex') //=> "regexii"

pluralize.plural('singles', 1) //=> "single"
pluralize.addSingularRule(/singles$/i, 'singular')
pluralize.plural('singles', 1) //=> "singular"

pluralize.plural('irregular') //=> "irregulars"
pluralize.addIrregularRule('irregular', 'regular')
pluralize.plural('irregular') //=> "regular"

pluralize.plural('paper') //=> "papers"
pluralize.addUncountableRule('paper')
pluralize.plural('paper') //=> "paper"

License

MIT