[Pkg-javascript-commits] [node-plur] 01/05: Import Upstream version 2.1.2

Abhishek Lolage abhisheklolage-guest at moszumanska.debian.org
Sun Feb 12 17:16:06 UTC 2017


This is an automated email from the git hooks/post-receive script.

abhisheklolage-guest pushed a commit to branch master
in repository node-plur.

commit 91fc1932d1d525c269c8756c1e816b5c83e8e0d7
Author: Abhishek Lolage <abhisheklolage at gmail.com>
Date:   Fri Jan 6 06:15:00 2017 +0000

    Import Upstream version 2.1.2
---
 .editorconfig  | 15 +++++++++++++
 .gitattributes |  1 +
 .gitignore     |  1 +
 .travis.yml    |  6 ++++++
 index.js       | 20 ++++++++++++++++++
 license        | 21 ++++++++++++++++++
 package.json   | 42 ++++++++++++++++++++++++++++++++++++
 readme.md      | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test.js        | 32 ++++++++++++++++++++++++++++
 9 files changed, 205 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..8f9d77e
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,15 @@
+root = 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
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..dedfc07
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+sudo: false
+language: node_js
+node_js:
+  - 'iojs'
+  - '0.12'
+  - '0.10'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..ed3f9b0
--- /dev/null
+++ b/index.js
@@ -0,0 +1,20 @@
+'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;
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (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.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..6a7c051
--- /dev/null
+++ b/package.json
@@ -0,0 +1,42 @@
+{
+  "name": "plur",
+  "version": "2.1.2",
+  "description": "Pluralize a word",
+  "license": "MIT",
+  "repository": "sindresorhus/plur",
+  "author": {
+    "name": "Sindre Sorhus",
+    "email": "sindresorhus at 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": "*"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..40103d8
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,67 @@
+# 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)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..fd677fa
--- /dev/null
+++ b/test.js
@@ -0,0 +1,32 @@
+import 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');
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-plur.git



More information about the Pkg-javascript-commits mailing list