
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@looop/pluralize
Advanced tools
Pluralize and singularize any word.
This was forked from https://github.com/plurals/pluralize. It was refactored into TS and there is now a build step added. Everything else remains the same.
npm install pluralize --save
yarn add pluralize
import pluralize from 'pluralize';
const pluralize = require('pluralize');
define(function (require, exports, module) {
const 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
The npm package @looop/pluralize receives a total of 191 weekly downloads. As such, @looop/pluralize popularity was classified as not popular.
We found that @looop/pluralize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.