Update ESLint to 2.1.0. ESLint has a number of potentially-useful new features but this change attempts to be minimal in its changes. However, some things could not be avoided reasonably. ESLint 2.1.0 found a few lint issues that ESLing 1.x missed with template strings that did not take advantage of any features of template strings, and `let` declarations where `const` sufficed. Additionally, ESLint 2.1.0 removes some granularity around enabling ES6 features. Some features (e.g., spread operator) that had been turned off in our configuration for ESLint 1.x are now permitted. PR-URL: https://github.com/nodejs/node/pull/5214 Reviewed-By: Michaël Zasso <mic.besace@gmail.com> Reviewed-By: jbergstroem - Johan Bergström <bugs@bergstroem.nu> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Myles Borins <myles.borins@gmail.com>
78 lines
2.2 KiB
Markdown
78 lines
2.2 KiB
Markdown
# Pluralize
|
|
|
|
[![NPM version][npm-image]][npm-url]
|
|
[![NPM downloads][downloads-image]][downloads-url]
|
|
[![Build status][travis-image]][travis-url]
|
|
[![Test coverage][coveralls-image]][coveralls-url]
|
|
|
|
> Pluralize and singularize any word.
|
|
|
|
## Installation
|
|
|
|
```
|
|
npm install pluralize --save
|
|
bower install pluralize --save
|
|
```
|
|
|
|
### Node
|
|
|
|
```javascript
|
|
var pluralize = require('pluralize')
|
|
```
|
|
|
|
### AMD
|
|
|
|
```javascript
|
|
define(function (require, exports, module) {
|
|
var pluralize = require('pluralize')
|
|
})
|
|
```
|
|
|
|
### `<script>` tag
|
|
|
|
```html
|
|
<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
|
|
|
|
```javascript
|
|
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
|
|
|
|
[npm-image]: https://img.shields.io/npm/v/pluralize.svg?style=flat
|
|
[npm-url]: https://npmjs.org/package/pluralize
|
|
[downloads-image]: https://img.shields.io/npm/dm/pluralize.svg?style=flat
|
|
[downloads-url]: https://npmjs.org/package/pluralize
|
|
[travis-image]: https://img.shields.io/travis/blakeembrey/pluralize.svg?style=flat
|
|
[travis-url]: https://travis-ci.org/blakeembrey/pluralize
|
|
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/pluralize.svg?style=flat
|
|
[coveralls-url]: https://coveralls.io/r/blakeembrey/pluralize?branch=master
|