pax_global_header00006660000000000000000000000064126363670650014530gustar00rootroot0000000000000052 comment=d896377c1ccd97ac612c491e4926176b5f92d8a6 plur-2.1.2/000077500000000000000000000000001263636706500125145ustar00rootroot00000000000000plur-2.1.2/.editorconfig000066400000000000000000000003471263636706500151750ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 [*.md] trim_trailing_whitespace = false plur-2.1.2/.gitattributes000066400000000000000000000000141263636706500154020ustar00rootroot00000000000000* text=auto plur-2.1.2/.gitignore000066400000000000000000000000151263636706500145000ustar00rootroot00000000000000node_modules plur-2.1.2/.travis.yml000066400000000000000000000001101263636706500146150ustar00rootroot00000000000000sudo: false language: node_js node_js: - 'iojs' - '0.12' - '0.10' plur-2.1.2/index.js000066400000000000000000000011271263636706500141620ustar00rootroot00000000000000'use strict'; var irregularPlurals = require('irregular-plurals'); module.exports = function (str, plural, count) { if (typeof plural === 'number') { count = plural; } if (str in irregularPlurals) { plural = irregularPlurals[str]; } else if (typeof plural !== 'string') { plural = (str.replace(/(?:s|x|z|ch|sh)$/i, '$&e').replace(/([^aeiou])y$/i, '$1ie') + 's') .replace(/i?e?s$/i, function (m) { var isTailLowerCase = str.slice(-1) === str.slice(-1).toLowerCase(); return isTailLowerCase ? m.toLowerCase() : m.toUpperCase(); }); } return count === 1 ? str : plural; }; plur-2.1.2/license000066400000000000000000000021371263636706500140640ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. plur-2.1.2/package.json000066400000000000000000000012451263636706500150040ustar00rootroot00000000000000{ "name": "plur", "version": "2.1.2", "description": "Pluralize a word", "license": "MIT", "repository": "sindresorhus/plur", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "plur", "plural", "plurals", "pluralize", "singular", "count", "word", "string", "str", "irregular", "noun", "nouns" ], "dependencies": { "irregular-plurals": "^1.0.0" }, "devDependencies": { "ava": "*", "xo": "*" } } plur-2.1.2/readme.md000066400000000000000000000022761263636706500143020ustar00rootroot00000000000000# plur [![Build Status](https://travis-ci.org/sindresorhus/plur.svg?branch=master)](https://travis-ci.org/sindresorhus/plur) > Pluralize a word ## Install ``` $ npm install --save plur ``` ## Usage ```js const plur = require('plur'); plur('unicorn', 4); //=> 'unicorns' plur('puppy', 2); //=> 'puppies' plur('box', 2); //=> 'boxes' plur('cactus', 2); //=> 'cacti' ``` ## API ### plur(word, [plural], count) #### word Type: `string` Word to pluralize. #### plural Type: `string` Default: - Irregular nouns will use this [list](https://github.com/sindresorhus/irregular-plurals/blob/master/irregular-plurals.json). - Words ending in *s*, *x*, *z*, *ch*, *sh* will be pluralized with *-es* (eg. *foxes*). - Words ending in *y* that are preceded by a consonant will be pluralized by replacing *y* with *-ies* (eg. *puppies*). - All other words will have "s" added to the end (eg. *days*). Pluralized word. The plural suffix will match the case of the last letter in the word. This option is only for extreme edge-cases. You probably won't need it. #### count Type: `number` Count to determine whether to use singular or plural. ## License MIT © [Sindre Sorhus](http://sindresorhus.com) plur-2.1.2/test.js000066400000000000000000000017301263636706500140320ustar00rootroot00000000000000import test from 'ava'; import fn from './'; test(t => { t.is(fn('unicorn', 0), 'unicorns'); t.is(fn('unicorn', 1), 'unicorn'); t.is(fn('unicorn', 2), 'unicorns'); t.is(fn('unicorn', 'horse', 0), 'horse'); t.is(fn('unicorn', 'horse', 1), 'unicorn'); t.is(fn('unicorn', 'horse', 2), 'horse'); t.is(fn('bus', 2), 'buses'); t.is(fn('box', 2), 'boxes'); t.is(fn('fizz', 2), 'fizzes'); t.is(fn('batch', 2), 'batches'); t.is(fn('bush', 2), 'bushes'); t.is(fn('guppy', 2), 'guppies'); t.is(fn('UNICORN', 2), 'UNICORNS'); t.is(fn('puppY', 2), 'puppIES'); t.is(fn('man', 2), 'men'); t.is(fn('woman', 2), 'women'); t.is(fn('fish', 2), 'fish'); t.is(fn('sheep', 2), 'sheep'); t.is(fn('tooth', 2), 'teeth'); t.is(fn('tomato', 2), 'tomatoes'); t.is(fn('torpedo', 2), 'torpedoes'); t.is(fn('wife', 2), 'wives'); t.is(fn('shelf', 2), 'shelves'); t.is(fn('day', 2), 'days'); t.is(fn('diy', 2), 'diys'); t.is(fn('child', 2), 'children'); t.is(fn('child', 1), 'child'); });