techieshark / plural-for

Pluralize English words (stupidly simple code)
https://www.npmjs.com/package/plural-for
2 stars 0 forks source link

plural-for: tiny node module to pluralize English words

Greenkeeper badge

This is meant to be small and stupidly simple.

For the absolutely simplest alternative, see sorp.

For smarter/bigger options, you've got:

Install

npm install --save plural-for

Example Usage

var pluralFor = require('plural-for')
var asWord = require('zero-to-nine').asWord

let nOcelots = 0
let nWolves = 2

console.log(`There will be ${asWord(nOcelots)} ${pluralFor(nOcelots, 'ocelot')} left after building the wall.`)
// output: "There will be zero ocelots left after building the wall."

console.log(`There will be only ${asWord(nWolves)} Mexican gray ${pluralFor(nWolves, 'wolf', 'wolves')} left, sadly.`)
// output: There will be only two Mexican gray wolves left, sadly.

See also: more about biodiversity threats example.