This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/pluralize
2019-08-11 20:48:02 +02:00
..
LICENSE Update Framework 2019-08-11 20:48:02 +02:00
package.json Update Framework 2019-08-11 20:48:02 +02:00
pluralize.js Update Framework 2019-08-11 20:48:02 +02:00
Readme.md Update Framework 2019-08-11 20:48:02 +02:00

Pluralize

NPM version NPM downloads Build status Test coverage File Size CDNJS Greenkeeper badge

Pluralize and singularize any word.

Installation

npm install pluralize --save
yarn add pluralize
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('蘋果', 2, true) //=> "2 蘋果"

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

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

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

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

pluralize.isPlural('test') //=> false
pluralize.isSingular('test') //=> true

License

MIT