├── .editorconfig ├── .gitattributes ├── .github ├── security.md └── workflows │ └── main.yml ├── .gitignore ├── .npmrc ├── index.d.ts ├── index.js ├── irregular-plurals.json ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/security.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. 4 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node.js ${{ matrix.node-version }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | node-version: 13 | - 20 14 | - 18 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: actions/setup-node@v4 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - run: npm install 21 | - run: npm test 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | A map of nouns to their irregular plural form. 3 | 4 | @example 5 | ``` 6 | import irregularPlurals from 'irregular-plurals'; 7 | 8 | console.log(irregularPlurals.get('cactus')); 9 | //=> 'cacti' 10 | 11 | console.log(irregularPlurals); 12 | // Map { 13 | // [addendum, 'addenda'], 14 | // [alga, 'algae'], 15 | // … 16 | // } 17 | ``` 18 | */ 19 | declare const irregularPlurals: ReadonlyMap; 20 | 21 | export default irregularPlurals; 22 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import irregularPlurals_ from './irregular-plurals.json' with {type: 'json'}; 2 | 3 | const irregularPlurals = new Map(Object.entries(irregularPlurals_)); 4 | 5 | export default irregularPlurals; 6 | -------------------------------------------------------------------------------- /irregular-plurals.json: -------------------------------------------------------------------------------- 1 | { 2 | "addendum": "addenda", 3 | "aircraft": "aircraft", 4 | "alga": "algae", 5 | "alumna": "alumnae", 6 | "alumnus": "alumni", 7 | "alveolus": "alveoli", 8 | "amoeba": "amoebae", 9 | "analysis": "analyses", 10 | "antenna": "antennae", 11 | "antithesis": "antitheses", 12 | "apex": "apices", 13 | "appendix": "appendices", 14 | "automaton": "automata", 15 | "axis": "axes", 16 | "bacillus": "bacilli", 17 | "bacterium": "bacteria", 18 | "baculum": "bacula", 19 | "barracks": "barracks", 20 | "basis": "bases", 21 | "beau": "beaux", 22 | "bison": "bison", 23 | "buffalo": "buffalo", 24 | "bureau": "bureaus", 25 | "cactus": "cacti", 26 | "calf": "calves", 27 | "carcinoma": "carcinomata", 28 | "carp": "carp", 29 | "census": "censuses", 30 | "chassis": "chassis", 31 | "cherub": "cherubim", 32 | "child": "children", 33 | "château": "châteaus", 34 | "cloaca": "cloacae", 35 | "cod": "cod", 36 | "codex": "codices", 37 | "concerto": "concerti", 38 | "consortium": "consortia", 39 | "corpus": "corpora", 40 | "crisis": "crises", 41 | "criterion": "criteria", 42 | "curriculum": "curricula", 43 | "cystoma": "cystomata", 44 | "datum": "data", 45 | "deer": "deer", 46 | "diagnosis": "diagnoses", 47 | "die": "dice", 48 | "dwarf": "dwarfs", 49 | "echo": "echoes", 50 | "elf": "elves", 51 | "elk": "elk", 52 | "ellipsis": "ellipses", 53 | "embargo": "embargoes", 54 | "emphasis": "emphases", 55 | "erratum": "errata", 56 | "faux pas": "faux pas", 57 | "fez": "fezes", 58 | "firmware": "firmware", 59 | "fish": "fish", 60 | "focus": "foci", 61 | "foot": "feet", 62 | "formula": "formulae", 63 | "fungus": "fungi", 64 | "gallows": "gallows", 65 | "genus": "genera", 66 | "glomerulus": "glomeruli", 67 | "goose": "geese", 68 | "graffito": "graffiti", 69 | "grouse": "grouse", 70 | "half": "halves", 71 | "hamulus": "hamuli", 72 | "hero": "heroes", 73 | "hippopotamus": "hippopotami", 74 | "hoof": "hooves", 75 | "hovercraft": "hovercraft", 76 | "hypothesis": "hypotheses", 77 | "iliac": "ilia", 78 | "incubus": "incubi", 79 | "index": "indices", 80 | "interstitium": "interstitia", 81 | "kakapo": "kakapo", 82 | "knife": "knives", 83 | "larva": "larvae", 84 | "leaf": "leaves", 85 | "libretto": "libretti", 86 | "life": "lives", 87 | "loaf": "loaves", 88 | "loculus": "loculi", 89 | "locus": "loci", 90 | "louse": "lice", 91 | "man": "men", 92 | "matrix": "matrices", 93 | "means": "means", 94 | "measles": "measles", 95 | "media": "media", 96 | "medium": "media", 97 | "memorandum": "memoranda", 98 | "millennium": "millennia", 99 | "minutia": "minutiae", 100 | "moose": "moose", 101 | "mouse": "mice", 102 | "nebula": "nebulae", 103 | "nemesis": "nemeses", 104 | "neurosis": "neuroses", 105 | "news": "news", 106 | "nucleolus": "nucleoli", 107 | "nucleus": "nuclei", 108 | "oasis": "oases", 109 | "occiput": "occipita", 110 | "offspring": "offspring", 111 | "omphalos": "omphaloi", 112 | "opus": "opera", 113 | "ovum": "ova", 114 | "ox": "oxen", 115 | "paralysis": "paralyses", 116 | "parenthesis": "parentheses", 117 | "person": "people", 118 | "phenomenon": "phenomena", 119 | "phylum": "phyla", 120 | "pike": "pike", 121 | "polyhedron": "polyhedra", 122 | "potato": "potatoes", 123 | "primus": "primi", 124 | "prognosis": "prognoses", 125 | "quiz": "quizzes", 126 | "radius": "radii", 127 | "referendum": "referenda", 128 | "salmon": "salmon", 129 | "scarf": "scarves", 130 | "scrotum": "scrota", 131 | "self": "selves", 132 | "seminoma": "seminomata", 133 | "series": "series", 134 | "sheep": "sheep", 135 | "shelf": "shelves", 136 | "shrimp": "shrimp", 137 | "simulacrum": "simulacra", 138 | "soliloquy": "soliloquies", 139 | "spacecraft": "spacecraft", 140 | "species": "species", 141 | "spectrum": "spectra", 142 | "squid": "squid", 143 | "stimulus": "stimuli", 144 | "stratum": "strata", 145 | "swine": "swine", 146 | "syconium": "syconia", 147 | "syllabus": "syllabi", 148 | "symposium": "symposia", 149 | "synopsis": "synopses", 150 | "synthesis": "syntheses", 151 | "tableau": "tableaus", 152 | "testis": "testes", 153 | "that": "those", 154 | "thesis": "theses", 155 | "thief": "thieves", 156 | "this": "these", 157 | "thrombus": "thrombi", 158 | "tomato": "tomatoes", 159 | "tooth": "teeth", 160 | "torus": "tori", 161 | "trout": "trout", 162 | "tuna": "tuna", 163 | "umbilicus": "umbilici", 164 | "uterus": "uteri", 165 | "vertebra": "vertebrae", 166 | "vertex": "vertices", 167 | "veto": "vetoes", 168 | "vita": "vitae", 169 | "vortex": "vortices", 170 | "watercraft": "watercraft", 171 | "wharf": "wharves", 172 | "wife": "wives", 173 | "wolf": "wolves", 174 | "woman": "women" 175 | } 176 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "irregular-plurals", 3 | "version": "4.0.0", 4 | "description": "Map of nouns to their irregular plural form", 5 | "license": "MIT", 6 | "repository": "sindresorhus/irregular-plurals", 7 | "funding": "https://github.com/sponsors/sindresorhus", 8 | "author": { 9 | "name": "Sindre Sorhus", 10 | "email": "sindresorhus@gmail.com", 11 | "url": "https://sindresorhus.com" 12 | }, 13 | "type": "module", 14 | "exports": { 15 | "types": "./index.d.ts", 16 | "default": "./index.js" 17 | }, 18 | "sideEffects": false, 19 | "engines": { 20 | "node": ">=18.20" 21 | }, 22 | "scripts": { 23 | "//test": "xo && ava && tsc --noEmit index.d.ts", 24 | "test": "ava && tsc --noEmit index.d.ts" 25 | }, 26 | "files": [ 27 | "index.js", 28 | "index.d.ts", 29 | "irregular-plurals.json" 30 | ], 31 | "keywords": [ 32 | "word", 33 | "words", 34 | "list", 35 | "map", 36 | "hash", 37 | "json", 38 | "irregular", 39 | "plural", 40 | "plurals", 41 | "noun", 42 | "nouns" 43 | ], 44 | "devDependencies": { 45 | "ava": "^6.1.2", 46 | "tsd": "^0.31.0", 47 | "xo": "^0.58.0" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # irregular-plurals 2 | 3 | > Map of nouns to their irregular plural form 4 | 5 | > An irregular plural in this library is defined as a noun that cannot be made plural by applying these rules: 6 | > - If the noun ends in an "s", "x", "z", "ch" or "sh", add "es" 7 | > - If the noun ends in a "y" and is preceded by a consonant, drop the "y" and add "ies" 8 | > - If the noun ends in a "y" and is preceded by a vowel, add "s" 9 | 10 | The list is just a [JSON file](irregular-plurals.json) and can be used anywhere. 11 | 12 | ## Install 13 | 14 | ```sh 15 | npm install irregular-plurals 16 | ``` 17 | 18 | ## Usage 19 | 20 | ```js 21 | import irregularPlurals from 'irregular-plurals'; 22 | 23 | console.log(irregularPlurals.get('cactus')); 24 | //=> 'cacti' 25 | 26 | console.log(irregularPlurals); 27 | /* 28 | Map { 29 | [addendum, 'addenda'], 30 | [alga, 'algae'], 31 | … 32 | } 33 | */ 34 | ``` 35 | 36 | ## Related 37 | 38 | - [plur](https://github.com/sindresorhus/plur) - Pluralize a word 39 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import irregularPlurals from './index.js'; 3 | 4 | test('main', t => { 5 | t.true(irregularPlurals.has('calf')); 6 | t.is(irregularPlurals.get('calf'), 'calves'); 7 | }); 8 | 9 | test.failing('isolated', async t => { 10 | const {default: fresh1} = await import('./index.js'); 11 | const {default: fresh2} = await import('./index.js'); 12 | fresh1.delete('calf'); 13 | t.false(fresh1.has('calf')); 14 | t.true(fresh2.has('calf')); 15 | t.true(irregularPlurals.has('calf')); 16 | }); 17 | --------------------------------------------------------------------------------