Skip to content

Pluralize or singularize any word based on a count

License

Notifications You must be signed in to change notification settings

Boltmade/pluralize

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pluralize

NPM version Build status Test coverage Gittip

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

Installation

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

Node

var pluralize = require('pluralize');

AMD

define(function (require, exports, module) {
  var pluralize = require('pluralize');
});

<script> tag

<script src="pluralize.js"></script>

Usage

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

About

Pluralize or singularize any word based on a count

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%