sb-pluralize

    1.2.2 • Public • Published

    Pluralize

    NPM version NPM downloads Build status Test coverage

    Pluralize and singularize any word.

    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>

    Why fork?

    The original library was using UMD and didn't play consistently between electron and browser, we forked it and made a few customizations to fix that.

    Why?

    This module uses a pre-defined list of rules, applied in order, to singularize or pluralize a given word. There are many cases where this is useful, such as any automation based on user input. For applications where the word(s) are known ahead of time, you can use a simple ternary (or function) which would be a much lighter alternative.

    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

    Install

    npm i sb-pluralize

    DownloadsWeekly Downloads

    1

    Version

    1.2.2

    License

    MIT

    Last publish

    Collaborators

    • avatar