Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
The pluralize npm package is a simple utility for converting words between their singular and plural forms. It can also handle irregular forms and uncountable nouns.
Pluralization
Converts a singular noun to its plural form, or vice versa, depending on the count provided. It also correctly handles uncountable nouns.
const pluralize = require('pluralize');
console.log(pluralize('fish')); // 'fish'
console.log(pluralize('fish', 5)); // 'fish'
console.log(pluralize('fish', 1)); // 'fish'
Singularization
Converts a plural noun to its singular form.
const pluralize = require('pluralize');
console.log(pluralize.singular('wolves')); // 'wolf'
Adding Irregular Rules
Allows the addition of custom irregular rules for nouns that do not follow the normal pluralization pattern.
const pluralize = require('pluralize');
pluralize.addIrregularRule('goose', 'geese');
console.log(pluralize('goose')); // 'geese'
Adding Uncountable Rules
Allows the addition of uncountable rules for nouns that should not be pluralized.
const pluralize = require('pluralize');
pluralize.addUncountableRule('equipment');
console.log(pluralize('equipment')); // 'equipment'
This package provides similar functionality to pluralize, including the ability to pluralize and singularize words. It also offers additional features like camelizing, underscore, humanize, etc. It is a more comprehensive solution for inflection than pluralize.
This package generates slugs from strings, which includes pluralization as part of its features. It is more focused on URL readability and SEO, whereas pluralize is solely dedicated to pluralization and singularization.
Pluralize and singularize any word.
npm install pluralize --save
yarn add pluralize
bower install pluralize --save
var pluralize = require('pluralize')
define(function (require, exports, module) {
var pluralize = require('pluralize')
})
<script>
tag<script src="pluralize.js"></script>
This module uses a pre-defined list of rules, applied in order, to singularize or pluralize a given word. There are many cases where this is useful, such as any automation based on user input. For applications where the word(s) are known ahead of time, you can use a simple ternary (or function) which would be a much lighter alternative.
word: string
The word to pluralizecount: number
How many of the word existinclusive: boolean
Whether to prefix with the number (e.g. 3 ducks)Examples:
pluralize('test') //=> "tests"
pluralize('test', 0) //=> "tests"
pluralize('test', 1) //=> "test"
pluralize('test', 5) //=> "tests"
pluralize('test', 1, true) //=> "1 test"
pluralize('test', 5, true) //=> "5 tests"
pluralize('蘋果', 2, true) //=> "2 蘋果"
// Example of new plural rule:
pluralize.plural('regex') //=> "regexes"
pluralize.addPluralRule(/gex$/i, 'gexii')
pluralize.plural('regex') //=> "regexii"
// Example of new singular rule:
pluralize.singular('singles') //=> "single"
pluralize.addSingularRule(/singles$/i, 'singular')
pluralize.singular('singles') //=> "singular"
// Example of new irregular rule, e.g. "I" -> "we":
pluralize.plural('irregular') //=> "irregulars"
pluralize.addIrregularRule('irregular', 'regular')
pluralize.plural('irregular') //=> "regular"
// Example of uncountable rule (rules without singular/plural in context):
pluralize.plural('paper') //=> "papers"
pluralize.addUncountableRule('paper')
pluralize.plural('paper') //=> "paper"
// Example of asking whether a word looks singular or plural:
pluralize.isPlural('test') //=> false
pluralize.isSingular('test') //=> true
MIT
FAQs
Pluralize and singularize any word
We found that pluralize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.