
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
This package does one thing simply. It does not try to be clever.
This package is considered STABLE therefore may not be updated frequently. It works really well, is small, and there are no open issues. It is used in a number of projects (hence the download count). Please use with all your might but let me know if you find any bugs. Bugs will be fixed and published quickly. :) Thanks, @andychilton.
npm install --save pluralise
Firstly, require the library:
const pluralise = require('pluralise')
There are two functions for two general cases. The first case is when you just want the plural of a word:
pluralise(0, 'book') // -> 'books'
pluralise(1, 'book') // -> 'book'
pluralise(2, 'book') // -> 'books'
Just passing the count
and the singular
version of the word will result in just the word (if count is 1)
or the word plus an s
when count is !== 1. ie. for zero or 2 and above.
Other times you want to be specific about what the plural actually is. Since this package contains no logic related to sheep, wolves or lorries then you need to pass it yourself:
pluralise(0, 'wolf', 'wolves') // -> 'wolves'
pluralise(1, 'wolf', 'wolves') // -> 'wolf'
pluralise(2, 'wolf', 'wolves') // -> 'wolves'
The second case is when you want to include the number with the singular/plural. This also has the case where you might
want to say something different when you have no things. For example you might say 'no wolves', '1 wolf' or '2
wolves'. Just use the %
symbol for where you would like the number to appear:
pluralise.withCount(0, '% wolf', '% wolves', 'no wolves') // -> 'no wolves'
pluralise.withCount(1, '% wolf', '% wolves', 'no wolves') // -> '1 wolf'
pluralise.withCount(2, '% wolf', '% wolves', 'no wolves') // -> '2 wolves'
If you have a regular plural such as 'item' and 'items', then you just miss the plural
out. It will take on the
singular form with an added 's' (or just pass the singular form twice):
pluralise.withCount(0, '% horse', null, 'no horses') // -> 'no horses'
pluralise.withCount(1, '% horse', null, 'no horses') // -> '1 horse'
pluralise.withCount(2, '% horse', null, 'no horses') // -> '2 horses'
pluralise.withCount(0, '% horse', '% horse', 'no horses') // -> 'no horses'
pluralise.withCount(1, '% horse', '% horse', 'no horses') // -> '1 horse'
pluralise.withCount(2, '% horse', '% horse', 'no horses') // -> '2 horses'
That's all pluralise(Infinity, 'folk')
.
With lodash, you can .partialRight()
so that you could create a module such
as this:
const lodash = require('lodash')
const pluralise = require('pluralise')
module.exports = {
cow : lodash.partialRight(pluralise, 'cow'),
sheep : lodash.partialRight(pluralise, 'sheep', 'sheep'),
wolf : lodash.partialRight(pluralise, 'wolf', 'wolves'),
}
Which you can then use as follows:
const plurals = require('path/to/above-file.js')
const cows = 3
console.log('Farmer Brown has %d %s', cows, plurals.cow(cows))
// -> 'Farmer Brown has 3 cows'
The same can be done withCount
:
module.exports = {
cow : lodash.partialRight(pluralise.withCount, '% cow', null, 'no cows'),
sheep : lodash.partialRight(pluralise.withCount, '% sheep', '% sheep', 'no sheep'),
wolf : lodash.partialRight(pluralise.withCount, '% wolf', '% wolves', 'no wolves'),
}
$ npx chilts
╒════════════════════════════════════════════════════╕
│ │
│ Andrew Chilton (Personal) │
│ ------------------------- │
│ │
│ Email : andychilton@gmail.com │
│ Web : https://chilts.org │
│ Twitter : https://twitter.com/andychilton │
│ GitHub : https://github.com/chilts │
│ GitLab : https://gitlab.org/chilts │
│ │
│ Apps Attic Ltd (My Company) │
│ --------------------------- │
│ │
│ Email : chilts@appsattic.com │
│ Web : https://appsattic.com │
│ Twitter : https://twitter.com/AppsAttic │
│ GitLab : https://gitlab.com/appsattic │
│ │
│ Node.js / npm │
│ ------------- │
│ │
│ Profile : https://www.npmjs.com/~chilts │
│ Card : $ npx chilts │
│ │
╘════════════════════════════════════════════════════╛
MIT - http://chilts.mit-license.org/2015/
(Ends)
FAQs
Plurals for the masses.
The npm package pluralise receives a total of 217 weekly downloads. As such, pluralise popularity was classified as not popular.
We found that pluralise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.