Created
September 30, 2024 12:49
-
-
Save andreasvirkus/0fc10cd83ff886ab22c1b232f206262f to your computer and use it in GitHub Desktop.
Revisions
-
andreasvirkus created this gist
Sep 30, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ function singularize(word) { const endings = { ves: 'fe', ies: 'y', i: 'us', zes: 'ze', ses: 's', xes: 'x', es: 'e', s: '' }; return word.replace( new RegExp(`(${Object.keys(endings).join('|')})$`), r => endings[r] ); }