diff options
Diffstat (limited to 'node_modules/plur/index.js')
-rw-r--r-- | node_modules/plur/index.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/node_modules/plur/index.js b/node_modules/plur/index.js new file mode 100644 index 000000000..ed3f9b06b --- /dev/null +++ b/node_modules/plur/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; +}; |