Comparing version 0.3.3 to 0.3.4
@@ -15,3 +15,3 @@ // Default inflections | ||
inflect.plural(/sis$/i, 'ses'); | ||
inflect.plural(/(?:([^f])fe|([lr])f)$/i, '$1ves'); | ||
inflect.plural(/(?:([^fa])fe|(?:(oa)f)|([lr])f)$/i, '$1ves'); | ||
inflect.plural(/(hive)$/i, '$1s'); | ||
@@ -27,3 +27,2 @@ inflect.plural(/([^aeiouy]|qu)y$/i, '$1ies'); | ||
inflect.singular(/s$/i, ''); | ||
@@ -37,2 +36,3 @@ inflect.singular(/(n)ews$/i, '$1ews'); | ||
inflect.singular(/(tive)s$/i, '$1'); | ||
inflect.singular(/(oave)s$/i, 'oaf'); | ||
inflect.singular(/([lr])ves$/i, '$1f'); | ||
@@ -64,4 +64,9 @@ inflect.singular(/([^aeiouy]|qu)ies$/i, '$1y'); | ||
inflect.irregular('zombie', 'zombies'); | ||
inflect.irregular('oaf', 'oafs', true); | ||
inflect.irregular('jefe', 'jefes'); | ||
inflect.irregular('save', 'saves'); | ||
inflect.irregular('safe', 'safes'); | ||
inflect.irregular('fife', 'fifes'); | ||
inflect.uncountable(['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans']); | ||
inflect.uncountable(['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'sushi']); | ||
} |
@@ -52,16 +52,20 @@ // A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional | ||
// irregular 'person', 'people' | ||
Inflections.prototype.irregular = function (singular, plural) { | ||
Inflections.prototype.irregular = function (singular, plural, fullMatchRequired) { | ||
this.uncountables = util.array.del(this.uncountables, singular); | ||
this.uncountables = util.array.del(this.uncountables, plural); | ||
var prefix = ""; | ||
if (fullMatchRequired) { | ||
prefix = "^"; | ||
} | ||
if (singular[0].toUpperCase() == plural[0].toUpperCase()) { | ||
this.plural(new RegExp("(" + singular[0] + ")" + singular.slice(1) + "$", "i"), '$1' + plural.slice(1)); | ||
this.plural(new RegExp("(" + plural[0] + ")" + plural.slice(1) + "$", "i"), '$1' + plural.slice(1)); | ||
this.singular(new RegExp("(" + plural[0] + ")" + plural.slice(1) + "$", "i"), '$1' + singular.slice(1)); | ||
this.plural(new RegExp("(" + prefix + singular[0] + ")" + singular.slice(1) + "$", "i"), '$1' + plural.slice(1)); | ||
this.plural(new RegExp("(" + prefix + plural[0] + ")" + plural.slice(1) + "$", "i"), '$1' + plural.slice(1)); | ||
this.singular(new RegExp("(" + prefix + plural[0] + ")" + plural.slice(1) + "$", "i"), '$1' + singular.slice(1)); | ||
} else { | ||
this.plural(new RegExp("" + (singular[0].toUpperCase()) + singular.slice(1) + "$"), plural[0].toUpperCase() + plural.slice(1)); | ||
this.plural(new RegExp("" + (singular[0].toLowerCase()) + singular.slice(1) + "$"), plural[0].toLowerCase() + plural.slice(1)); | ||
this.plural(new RegExp("" + (plural[0].toUpperCase()) + plural.slice(1) + "$"), plural[0].toUpperCase() + plural.slice(1)); | ||
this.plural(new RegExp("" + (plural[0].toLowerCase()) + plural.slice(1) + "$"), plural[0].toLowerCase() + plural.slice(1)); | ||
this.singular(new RegExp("" + (plural[0].toUpperCase()) + plural.slice(1) + "$"), singular[0].toUpperCase() + singular.slice(1)); | ||
this.singular(new RegExp("" + (plural[0].toLowerCase()) + plural.slice(1) + "$"), singular[0].toLowerCase() + singular.slice(1)); | ||
this.plural(new RegExp(prefix + (singular[0].toUpperCase()) + singular.slice(1) + "$"), plural[0].toUpperCase() + plural.slice(1)); | ||
this.plural(new RegExp(prefix + (singular[0].toLowerCase()) + singular.slice(1) + "$"), plural[0].toLowerCase() + plural.slice(1)); | ||
this.plural(new RegExp(prefix + (plural[0].toUpperCase()) + plural.slice(1) + "$"), plural[0].toUpperCase() + plural.slice(1)); | ||
this.plural(new RegExp(prefix + (plural[0].toLowerCase()) + plural.slice(1) + "$"), plural[0].toLowerCase() + plural.slice(1)); | ||
this.singular(new RegExp(prefix + (plural[0].toUpperCase()) + plural.slice(1) + "$"), singular[0].toUpperCase() + singular.slice(1)); | ||
this.singular(new RegExp(prefix + (plural[0].toLowerCase()) + plural.slice(1) + "$"), singular[0].toLowerCase() + singular.slice(1)); | ||
} | ||
@@ -68,0 +72,0 @@ }; |
{ | ||
"name": "i", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"author": "Pavan Kumar Sunkara <pavan.sss1991@gmail.com> (pksunkara.github.com)", | ||
@@ -39,3 +39,3 @@ "description": "custom inflections for nodejs", | ||
"devDependencies": { | ||
"vows": "~0.6.1" | ||
"vows": "0.7.0" | ||
}, | ||
@@ -42,0 +42,0 @@ "engines": { |
@@ -5,2 +5,4 @@ # inflect | ||
**NOTE: 0.3.2 was accidentally unpublished from the server and npm doesn't allow me to publish it back. Please upgrade to 0.3.3** | ||
## Installation | ||
@@ -7,0 +9,0 @@ |
@@ -84,3 +84,24 @@ (function() { | ||
"cow": "kine", | ||
"database": "databases" | ||
"database": "databases", | ||
"safe": "safes", | ||
"belief": "beliefs", | ||
"gaffe": "gaffes", | ||
"cafe": "cafes", | ||
"caffe": "caffes", | ||
"life": "lives", | ||
"wife": "wives", | ||
"save": "saves", | ||
"fife": "fifes", | ||
"carafe": "carafes", | ||
"giraffe": "giraffes", | ||
"elf": "elves", | ||
"calf": "calves", | ||
"bookshelf": "bookshelves", | ||
"wolf": "wolves", | ||
"half": "halves", | ||
"meatloaf": "meatloaves", | ||
"loaf": "loaves", | ||
"oaf": "oafs", | ||
"jefe": "jefes", | ||
"afterlife": "afterlives", | ||
}, | ||
@@ -87,0 +108,0 @@ CamelToUnderscore: { |
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
55090
1313
177