Comparing version 2.1.2 to 3.0.0
16
index.js
'use strict'; | ||
var irregularPlurals = require('irregular-plurals'); | ||
const irregularPlurals = require('irregular-plurals'); | ||
module.exports = function (str, plural, count) { | ||
module.exports = (word, plural, count) => { | ||
if (typeof plural === 'number') { | ||
@@ -9,8 +9,8 @@ count = plural; | ||
if (str in irregularPlurals) { | ||
plural = irregularPlurals[str]; | ||
if (irregularPlurals.has(word)) { | ||
plural = irregularPlurals.get(word); | ||
} 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(); | ||
plural = (word.replace(/(?:s|x|z|ch|sh)$/i, '$&e').replace(/([^aeiou])y$/i, '$1ie') + 's') | ||
.replace(/i?e?s$/i, m => { | ||
const isTailLowerCase = word.slice(-1) === word.slice(-1).toLowerCase(); | ||
return isTailLowerCase ? m.toLowerCase() : m.toUpperCase(); | ||
@@ -20,3 +20,3 @@ }); | ||
return count === 1 ? str : plural; | ||
return Math.abs(count) === 1 ? word : plural; | ||
}; |
{ | ||
"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": "*" | ||
} | ||
"name": "plur", | ||
"version": "3.0.0", | ||
"description": "Pluralize a word", | ||
"license": "MIT", | ||
"repository": "sindresorhus/plur", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"plur", | ||
"plural", | ||
"plurals", | ||
"pluralize", | ||
"singular", | ||
"count", | ||
"word", | ||
"string", | ||
"str", | ||
"irregular", | ||
"noun", | ||
"nouns" | ||
], | ||
"dependencies": { | ||
"irregular-plurals": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # plur [![Build Status](https://travis-ci.org/sindresorhus/plur.svg?branch=master)](https://travis-ci.org/sindresorhus/plur) | ||
``` | ||
$ npm install --save plur | ||
$ npm install plur | ||
``` | ||
@@ -45,3 +45,3 @@ | ||
Type: `string` | ||
Type: `string`<br> | ||
Default: | ||
@@ -69,2 +69,2 @@ | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3542
+ Addedirregular-plurals@2.0.0(transitive)
- Removedirregular-plurals@1.4.0(transitive)
Updatedirregular-plurals@^2.0.0