Skip to content

Pluralize or singularize any word based on a count

License

Notifications You must be signed in to change notification settings

nparziale/pluralize

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pluralize

Return a pluralized or singularized word based on the input string.

Installation

npm install pluralize --save
bower install pluralize --save

Usage

var pluralize = require('pluralize');
  • pluralize(word, count, includeCount)
  • pluralize.plural(word)
  • pluralize.singular(word)
  • pluralize.addPluralRule(rule, replacement)
  • pluralize.addSingularRule(rule, replacement)
  • pluralize.addUncountableRule(word)
  • pluralize.addIrregularRule(singular, plural)
pluralize('test') // "tests"
pluralize('test', 1) // "test"
pluralize('test', 5) // "tests"
pluralize('test', 1, true) // "1 test"
pluralize('test', 5, true) // "5 tests"

plural('regex') // "regexes"
pluralize.addPluralRule(/gex$/i, 'gexii')
plural('regex') // "regexii"

plural('singles', 1) // "single"
pluralize.addSingularRule(/singles$/i, 'singular')
plural('singles', 1) // "singular"

plural('irregular') // "irregulars"
plural.addIrregularRule('irregular', 'regular')
plural('irregular') // "regular"

plural('paper') // "papers"
plural.addUncountableRule('paper');
plural('paper') // "paper"

License

MIT

About

Pluralize or singularize any word based on a count

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%