pluralize() — react Function Reference
Architecture documentation for the pluralize() function in utils.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 32c9cded_7802_2453_63ff_40e62addad6e["pluralize()"] d7b27d30_728f_ba37_ed97_d371fbd3de62["utils.js"] 32c9cded_7802_2453_63ff_40e62addad6e -->|defined in| d7b27d30_728f_ba37_ed97_d371fbd3de62 1a0ee4d1_83f7_0dc1_4412_fcab95a7984d["SuspendedByGroup()"] 1a0ee4d1_83f7_0dc1_4412_fcab95a7984d -->|calls| 32c9cded_7802_2453_63ff_40e62addad6e style 32c9cded_7802_2453_63ff_40e62addad6e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/devtools/views/utils.js lines 202–257
export function pluralize(word: string): string {
if (!/^[a-z]+$/i.test(word)) {
// If it's not a single a-z word, give up.
return word;
}
// Bail out if it's already plural.
switch (word) {
case 'men':
case 'women':
case 'children':
case 'feet':
case 'teeth':
case 'mice':
case 'people':
return word;
}
if (
/(ches|shes|ses|xes|zes)$/i.test(word) ||
/[^s]ies$/i.test(word) ||
/ves$/i.test(word) ||
/[^s]s$/i.test(word)
) {
return word;
}
switch (word) {
case 'man':
return 'men';
case 'woman':
return 'women';
case 'child':
return 'children';
case 'foot':
return 'feet';
case 'tooth':
return 'teeth';
case 'mouse':
return 'mice';
case 'person':
return 'people';
}
// Words ending in s, x, z, ch, sh → add "es"
if (/(s|x|z|ch|sh)$/i.test(word)) return word + 'es';
// Words ending in consonant + y → replace y with "ies"
if (/[bcdfghjklmnpqrstvwxz]y$/i.test(word)) return word.slice(0, -1) + 'ies';
// Words ending in f or fe → replace with "ves"
if (/(?:f|fe)$/i.test(word)) return word.replace(/(?:f|fe)$/i, 'ves');
// Default: just add "s"
return word + 's';
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does pluralize() do?
pluralize() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/utils.js.
Where is pluralize() defined?
pluralize() is defined in packages/react-devtools-shared/src/devtools/views/utils.js at line 202.
What calls pluralize()?
pluralize() is called by 1 function(s): SuspendedByGroup.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free