Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 291x 291x 291x 291x 291x 232x | /**
* Converts an English plural word to its singular form.
* Used for normalizing module names and file paths during dependency analysis.
* Handles common irregular plurals and regular -s/-es endings.
*
* @param word - The plural word to convert to singular form
* @returns The singular form of the word (e.g., 'children' -> 'child')
*/
export function singularize(word: string): string {
const irregulars: Record<string, string> = {
people: 'person',
children: 'child',
men: 'man',
women: 'woman',
};
Iif (irregulars[word]) return irregulars[word];
Iif (word.endsWith('ies')) return word.slice(0, -3) + 'y';
Iif (word.endsWith('ses')) return word.slice(0, -2);
if (word.endsWith('s') && word.length > 3) return word.slice(0, -1);
return word;
}
|