Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sindresorhus/plur
Pluralize a word
https://github.com/sindresorhus/plur
Last synced: 6 days ago
JSON representation
Pluralize a word
- Host: GitHub
- URL: https://github.com/sindresorhus/plur
- Owner: sindresorhus
- License: mit
- Created: 2015-06-21T00:23:08.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2022-07-08T12:49:38.000Z (over 2 years ago)
- Last Synced: 2025-02-08T10:12:44.964Z (13 days ago)
- Language: JavaScript
- Homepage:
- Size: 30.3 KB
- Stars: 248
- Watchers: 7
- Forks: 21
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
README
# plur
> Pluralize a word
## Install
```sh
npm install plur
```## Usage
```js
import plur from 'plur';plur('rainbow');
//=> 'rainbows'plur('unicorn', 4);
//=> 'unicorns'plur('puppy', 2);
//=> 'puppies'plur('box', 2);
//=> 'boxes'plur('cactus', 2);
//=> 'cacti'
```## API
### plur(word, plural?, count?)
#### word
Type: `string`
The word to pluralize.
#### plural
Type: `string`\
Default:- Irregular nouns will use this [list](https://github.com/sindresorhus/irregular-plurals/blob/main/irregular-plurals.json).
- Words ending in *s*, *x*, *z*, *ch*, *sh* will be pluralized with *-es* (eg. *foxes*).
- Words ending in *y* that are preceded by a consonant will be pluralized by replacing *y* with *-ies* (eg. *puppies*).
- All other words will have "s" added to the end (eg. *days*).Explicitly provide the pluralized word.
The plural suffix will match the case of the last letter in the word.
This option is only for extreme edge-cases. You probably won't need it.
#### count
Type: `number`
The count to determine whether to use singular or plural. If omitted, defaults to plural.