What is irregular-plurals?
The irregular-plurals npm package is designed to provide a simple way to handle irregular plural forms of words in English. It is particularly useful for applications that need to dynamically generate text that conforms to grammatical rules.
What are irregular-plurals's main functionalities?
Get the plural form of an irregular noun
This feature allows you to retrieve the plural form of an irregular noun. You simply pass the singular form of the noun to the `get` method, and it returns the corresponding plural form.
const irregularPlurals = require('irregular-plurals');
console.log(irregularPlurals.get('mouse')); // Outputs: 'mice'
Other packages similar to irregular-plurals
pluralize
The pluralize package is similar to irregular-plurals but offers more comprehensive functionality. It not only handles irregular plurals but also correctly pluralizes regular nouns and can revert plurals to their singular form. This makes it more versatile for applications that deal with a broader range of vocabulary.
inflection
Inflection is another package that provides similar functionalities to irregular-plurals. It includes methods for pluralizing and singularizing both regular and irregular nouns. Additionally, it supports other string transformations such as camelizing, underscoring, and humanizing, making it suitable for more complex text processing tasks.
irregular-plurals
Map of nouns to their irregular plural form
An irregular plural in this library is defined as a noun that cannot be made plural by applying these rules:
- If the noun ends in an "s", "x", "z", "ch" or "sh", add "es"
- If the noun ends in a "y" and is preceded by a consonant, drop the "y" and add "ies"
- If the noun ends in a "y" and is preceded by a vowel, add "s"
The list is just a JSON file and can be used anywhere.
Install
npm install irregular-plurals
Usage
import irregularPlurals from 'irregular-plurals';
console.log(irregularPlurals.get('cactus'));
console.log(irregularPlurals);
Related