1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/pluralize
詹力 1fbb667270 完善文档,完善若干细节 2023-12-28 23:41:32 +08:00
..
LICENSE i4 2023-12-18 13:12:25 +08:00
Readme.md i4 2023-12-18 13:12:25 +08:00
package.json 完善文档,完善若干细节 2023-12-28 23:41:32 +08:00
pluralize.js i4 2023-12-18 13:12:25 +08:00

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