Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Erik Römmelt d20e8a9d10 Fix EsLint Brackets (error markup 'const'). 6 years ago
..
LICENSE Fix EsLint Brackets (error markup 'const'). 6 years ago
Readme.md Fix EsLint Brackets (error markup 'const'). 6 years ago
package.json Fix EsLint Brackets (error markup 'const'). 6 years ago
pluralize.js Fix EsLint Brackets (error markup 'const'). 6 years ago

Readme.md

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