@mythpe/quasar-ui-qui 0.1.93 → 0.1.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythpe/quasar-ui-qui",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
package/src/utils/Str.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * Github: https://github.com/mythpe
7
7
  */
8
8
 
9
- import { plural, singular } from 'pluralize'
9
+ import __pluralize from './__pluralize'
10
10
  import { camelCase, capitalCase, dotCase, kebabCase, pascalCase, snakeCase } from 'change-case'
11
11
 
12
12
  export const Str = {
@@ -92,10 +92,10 @@ export const Str = {
92
92
  return string ? dotCase(string?.toString() || '') : ''
93
93
  },
94
94
  pluralize (string?: unknown): string {
95
- return string ? plural(string?.toString() || '') : ''
95
+ return string ? __pluralize.plural(string?.toString() || '') : ''
96
96
  },
97
97
  singular (string?: unknown): string {
98
- return string ? singular(string?.toString() || '') : ''
98
+ return string ? __pluralize.singular(string?.toString() || '') : ''
99
99
  },
100
100
  flipChoice (data: Record<any, any>) {
101
101
  const f: Record<any, any> = {}
@@ -0,0 +1,510 @@
1
+ /* global define */
2
+
3
+ (function (root, pluralize) {
4
+ /* istanbul ignore else */
5
+ if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
6
+ // Node.
7
+ // module.exports = pluralize()
8
+ module.exports = {
9
+ pluralize: pluralize(),
10
+ default: pluralize()
11
+ }
12
+ } else if (typeof define === 'function' && define.amd) {
13
+ // AMD, registers as an anonymous module.
14
+ define(function () {
15
+ return pluralize()
16
+ })
17
+ } else {
18
+ // Browser global.
19
+ root.pluralize = pluralize()
20
+ }
21
+ })(this, function () {
22
+ // Rule storage - pluralize and singularize need to be run sequentially,
23
+ // while other rules can be optimized using an object for instant lookups.
24
+ const pluralRules = []
25
+ const singularRules = []
26
+ const uncountables = {}
27
+ const irregularPlurals = {}
28
+ const irregularSingles = {}
29
+
30
+ /**
31
+ * Sanitize a pluralization rule to a usable regular expression.
32
+ *
33
+ * @param {(RegExp|string)} rule
34
+ * @return {RegExp}
35
+ */
36
+ function sanitizeRule (rule) {
37
+ if (typeof rule === 'string') {
38
+ return new RegExp('^' + rule + '$', 'i')
39
+ }
40
+
41
+ return rule
42
+ }
43
+
44
+ /**
45
+ * Pass in a word token to produce a function that can replicate the case on
46
+ * another word.
47
+ *
48
+ * @param {string} word
49
+ * @param {string} token
50
+ * @return {Function}
51
+ */
52
+ function restoreCase (word, token) {
53
+ // Tokens are an exact match.
54
+ if (word === token) return token
55
+
56
+ // Lower cased words. E.g. "hello".
57
+ if (word === word.toLowerCase()) return token.toLowerCase()
58
+
59
+ // Upper cased words. E.g. "WHISKY".
60
+ if (word === word.toUpperCase()) return token.toUpperCase()
61
+
62
+ // Title cased words. E.g. "Title".
63
+ if (word[0] === word[0].toUpperCase()) {
64
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase()
65
+ }
66
+
67
+ // Lower cased words. E.g. "test".
68
+ return token.toLowerCase()
69
+ }
70
+
71
+ /**
72
+ * Interpolate a regexp string.
73
+ *
74
+ * @param {string} str
75
+ * @param {Array} args
76
+ * @return {string}
77
+ */
78
+ function interpolate (str, args) {
79
+ return str.replace(/\$(\d{1,2})/g, function (match, index) {
80
+ return args[index] || ''
81
+ })
82
+ }
83
+
84
+ /**
85
+ * Replace a word using a rule.
86
+ *
87
+ * @param {string} word
88
+ * @param {Array} rule
89
+ * @return {string}
90
+ */
91
+ function replace (word, rule) {
92
+ return word.replace(rule[0], function (match, index) {
93
+ const result = interpolate(rule[1], arguments)
94
+
95
+ if (match === '') {
96
+ return restoreCase(word[index - 1], result)
97
+ }
98
+
99
+ return restoreCase(match, result)
100
+ })
101
+ }
102
+
103
+ /**
104
+ * Sanitize a word by passing in the word and sanitization rules.
105
+ *
106
+ * @param {string} token
107
+ * @param {string} word
108
+ * @param {Array} rules
109
+ * @return {string}
110
+ */
111
+ function sanitizeWord (token, word, rules) {
112
+ // Empty string or doesn't need fixing.
113
+ if (!token.length || uncountables.hasOwnProperty(token)) {
114
+ return word
115
+ }
116
+
117
+ let len = rules.length
118
+
119
+ // Iterate over the sanitization rules and use the first one to match.
120
+ while (len--) {
121
+ const rule = rules[len]
122
+
123
+ if (rule[0].test(word)) return replace(word, rule)
124
+ }
125
+
126
+ return word
127
+ }
128
+
129
+ /**
130
+ * Replace a word with the updated word.
131
+ *
132
+ * @param {Object} replaceMap
133
+ * @param {Object} keepMap
134
+ * @param {Array} rules
135
+ * @return {Function}
136
+ */
137
+ function replaceWord (replaceMap, keepMap, rules) {
138
+ return function (word) {
139
+ // Get the correct token and case restoration functions.
140
+ const token = word.toLowerCase()
141
+
142
+ // Check against the keep object map.
143
+ if (keepMap.hasOwnProperty(token)) {
144
+ return restoreCase(word, token)
145
+ }
146
+
147
+ // Check against the replacement map for a direct word replacement.
148
+ if (replaceMap.hasOwnProperty(token)) {
149
+ return restoreCase(word, replaceMap[token])
150
+ }
151
+
152
+ // Run all the rules against the word.
153
+ return sanitizeWord(token, word, rules)
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Check if a word is part of the map.
159
+ */
160
+ function checkWord (replaceMap, keepMap, rules, bool) {
161
+ return function (word) {
162
+ const token = word.toLowerCase()
163
+
164
+ if (keepMap.hasOwnProperty(token)) return true
165
+ if (replaceMap.hasOwnProperty(token)) return false
166
+
167
+ return sanitizeWord(token, token, rules) === token
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Pluralize or singularize a word based on the passed in count.
173
+ *
174
+ * @param {string} word The word to pluralize
175
+ * @param {number} count How many of the word exist
176
+ * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)
177
+ * @return {string}
178
+ */
179
+ function pluralize (word, count, inclusive) {
180
+ const pluralized = count === 1
181
+ ? pluralize.singular(word) : pluralize.plural(word)
182
+
183
+ return (inclusive ? count + ' ' : '') + pluralized
184
+ }
185
+
186
+ /**
187
+ * Pluralize a word.
188
+ *
189
+ * @type {Function}
190
+ */
191
+ pluralize.plural = replaceWord(
192
+ irregularSingles, irregularPlurals, pluralRules
193
+ )
194
+
195
+ /**
196
+ * Check if a word is plural.
197
+ *
198
+ * @type {Function}
199
+ */
200
+ pluralize.isPlural = checkWord(
201
+ irregularSingles, irregularPlurals, pluralRules
202
+ )
203
+
204
+ /**
205
+ * Singularize a word.
206
+ *
207
+ * @type {Function}
208
+ */
209
+ pluralize.singular = replaceWord(
210
+ irregularPlurals, irregularSingles, singularRules
211
+ )
212
+
213
+ /**
214
+ * Check if a word is singular.
215
+ *
216
+ * @type {Function}
217
+ */
218
+ pluralize.isSingular = checkWord(
219
+ irregularPlurals, irregularSingles, singularRules
220
+ )
221
+
222
+ /**
223
+ * Add a pluralization rule to the collection.
224
+ *
225
+ * @param {(string|RegExp)} rule
226
+ * @param {string} replacement
227
+ */
228
+ pluralize.addPluralRule = function (rule, replacement) {
229
+ pluralRules.push([sanitizeRule(rule), replacement])
230
+ }
231
+
232
+ /**
233
+ * Add a singularization rule to the collection.
234
+ *
235
+ * @param {(string|RegExp)} rule
236
+ * @param {string} replacement
237
+ */
238
+ pluralize.addSingularRule = function (rule, replacement) {
239
+ singularRules.push([sanitizeRule(rule), replacement])
240
+ }
241
+
242
+ /**
243
+ * Add an uncountable word rule.
244
+ *
245
+ * @param {(string|RegExp)} word
246
+ */
247
+ pluralize.addUncountableRule = function (word) {
248
+ if (typeof word === 'string') {
249
+ uncountables[word.toLowerCase()] = true
250
+ return
251
+ }
252
+
253
+ // Set singular and plural references for the word.
254
+ pluralize.addPluralRule(word, '$0')
255
+ pluralize.addSingularRule(word, '$0')
256
+ }
257
+
258
+ /**
259
+ * Add an irregular word definition.
260
+ *
261
+ * @param {string} single
262
+ * @param {string} plural
263
+ */
264
+ pluralize.addIrregularRule = function (single, plural) {
265
+ plural = plural.toLowerCase()
266
+ single = single.toLowerCase()
267
+
268
+ irregularSingles[single] = plural
269
+ irregularPlurals[plural] = single
270
+ }
271
+
272
+ /**
273
+ * Irregular rules.
274
+ */
275
+ [
276
+ // Pronouns.
277
+ ['I', 'we'],
278
+ ['me', 'us'],
279
+ ['he', 'they'],
280
+ ['she', 'they'],
281
+ ['them', 'them'],
282
+ ['myself', 'ourselves'],
283
+ ['yourself', 'yourselves'],
284
+ ['itself', 'themselves'],
285
+ ['herself', 'themselves'],
286
+ ['himself', 'themselves'],
287
+ ['themself', 'themselves'],
288
+ ['is', 'are'],
289
+ ['was', 'were'],
290
+ ['has', 'have'],
291
+ ['this', 'these'],
292
+ ['that', 'those'],
293
+ // Words ending in with a consonant and `o`.
294
+ ['echo', 'echoes'],
295
+ ['dingo', 'dingoes'],
296
+ ['volcano', 'volcanoes'],
297
+ ['tornado', 'tornadoes'],
298
+ ['torpedo', 'torpedoes'],
299
+ // Ends with `us`.
300
+ ['genus', 'genera'],
301
+ ['viscus', 'viscera'],
302
+ // Ends with `ma`.
303
+ ['stigma', 'stigmata'],
304
+ ['stoma', 'stomata'],
305
+ ['dogma', 'dogmata'],
306
+ ['lemma', 'lemmata'],
307
+ ['schema', 'schemata'],
308
+ ['anathema', 'anathemata'],
309
+ // Other irregular rules.
310
+ ['ox', 'oxen'],
311
+ ['axe', 'axes'],
312
+ ['die', 'dice'],
313
+ ['yes', 'yeses'],
314
+ ['foot', 'feet'],
315
+ ['eave', 'eaves'],
316
+ ['goose', 'geese'],
317
+ ['tooth', 'teeth'],
318
+ ['quiz', 'quizzes'],
319
+ ['human', 'humans'],
320
+ ['proof', 'proofs'],
321
+ ['carve', 'carves'],
322
+ ['valve', 'valves'],
323
+ ['looey', 'looies'],
324
+ ['thief', 'thieves'],
325
+ ['groove', 'grooves'],
326
+ ['pickaxe', 'pickaxes'],
327
+ ['passerby', 'passersby']
328
+ ].forEach(function (rule) {
329
+ return pluralize.addIrregularRule(rule[0], rule[1])
330
+ })
331
+
332
+ /**
333
+ * Pluralization rules.
334
+ */
335
+ [
336
+ [/s?$/i, 's'],
337
+ [/[^\u0000-\u007F]$/i, '$0'],
338
+ [/([^aeiou]ese)$/i, '$1'],
339
+ [/(ax|test)is$/i, '$1es'],
340
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'],
341
+ [/(e[mn]u)s?$/i, '$1s'],
342
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'],
343
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'],
344
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],
345
+ [/(seraph|cherub)(?:im)?$/i, '$1im'],
346
+ [/(her|at|gr)o$/i, '$1oes'],
347
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'],
348
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'],
349
+ [/sis$/i, 'ses'],
350
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'],
351
+ [/([^aeiouy]|qu)y$/i, '$1ies'],
352
+ [/([^ch][ieo][ln])ey$/i, '$1ies'],
353
+ [/(x|ch|ss|sh|zz)$/i, '$1es'],
354
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],
355
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'],
356
+ [/(pe)(?:rson|ople)$/i, '$1ople'],
357
+ [/(child)(?:ren)?$/i, '$1ren'],
358
+ [/eaux$/i, '$0'],
359
+ [/m[ae]n$/i, 'men'],
360
+ ['thou', 'you']
361
+ ].forEach(function (rule) {
362
+ return pluralize.addPluralRule(rule[0], rule[1])
363
+ })
364
+
365
+ /**
366
+ * Singularization rules.
367
+ */
368
+ [
369
+ [/s$/i, ''],
370
+ [/(ss)$/i, '$1'],
371
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'],
372
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'],
373
+ [/ies$/i, 'y'],
374
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'],
375
+ [/\b(mon|smil)ies$/i, '$1ey'],
376
+ [/\b((?:tit)?m|l)ice$/i, '$1ouse'],
377
+ [/(seraph|cherub)im$/i, '$1'],
378
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'],
379
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'],
380
+ [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],
381
+ [/(test)(?:is|es)$/i, '$1is'],
382
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'],
383
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'],
384
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'],
385
+ [/(alumn|alg|vertebr)ae$/i, '$1a'],
386
+ [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'],
387
+ [/(matr|append)ices$/i, '$1ix'],
388
+ [/(pe)(rson|ople)$/i, '$1rson'],
389
+ [/(child)ren$/i, '$1'],
390
+ [/(eau)x?$/i, '$1'],
391
+ [/men$/i, 'man']
392
+ ].forEach(function (rule) {
393
+ return pluralize.addSingularRule(rule[0], rule[1])
394
+ })
395
+
396
+ /**
397
+ * Uncountable rules.
398
+ */
399
+ [
400
+ // Singular words with no plurals.
401
+ 'adulthood',
402
+ 'advice',
403
+ 'agenda',
404
+ 'aid',
405
+ 'aircraft',
406
+ 'alcohol',
407
+ 'ammo',
408
+ 'analytics',
409
+ 'anime',
410
+ 'athletics',
411
+ 'audio',
412
+ 'bison',
413
+ 'blood',
414
+ 'bream',
415
+ 'buffalo',
416
+ 'butter',
417
+ 'carp',
418
+ 'cash',
419
+ 'chassis',
420
+ 'chess',
421
+ 'clothing',
422
+ 'cod',
423
+ 'commerce',
424
+ 'cooperation',
425
+ 'corps',
426
+ 'debris',
427
+ 'diabetes',
428
+ 'digestion',
429
+ 'elk',
430
+ 'energy',
431
+ 'equipment',
432
+ 'excretion',
433
+ 'expertise',
434
+ 'firmware',
435
+ 'flounder',
436
+ 'fun',
437
+ 'gallows',
438
+ 'garbage',
439
+ 'graffiti',
440
+ 'hardware',
441
+ 'headquarters',
442
+ 'health',
443
+ 'herpes',
444
+ 'highjinks',
445
+ 'homework',
446
+ 'housework',
447
+ 'information',
448
+ 'jeans',
449
+ 'justice',
450
+ 'kudos',
451
+ 'labour',
452
+ 'literature',
453
+ 'machinery',
454
+ 'mackerel',
455
+ 'mail',
456
+ 'media',
457
+ 'mews',
458
+ 'moose',
459
+ 'music',
460
+ 'mud',
461
+ 'manga',
462
+ 'news',
463
+ 'only',
464
+ 'personnel',
465
+ 'pike',
466
+ 'plankton',
467
+ 'pliers',
468
+ 'police',
469
+ 'pollution',
470
+ 'premises',
471
+ 'rain',
472
+ 'research',
473
+ 'rice',
474
+ 'salmon',
475
+ 'scissors',
476
+ 'series',
477
+ 'sewage',
478
+ 'shambles',
479
+ 'shrimp',
480
+ 'software',
481
+ 'species',
482
+ 'staff',
483
+ 'swine',
484
+ 'tennis',
485
+ 'traffic',
486
+ 'transportation',
487
+ 'trout',
488
+ 'tuna',
489
+ 'wealth',
490
+ 'welfare',
491
+ 'whiting',
492
+ 'wildebeest',
493
+ 'wildlife',
494
+ 'you',
495
+ /pok[eé]mon$/i,
496
+ // Regexes.
497
+ /[^aeiou]ese$/i, // "chinese", "japanese"
498
+ /deer$/i, // "deer", "reindeer"
499
+ /fish$/i, // "fish", "blowfish", "angelfish"
500
+ /measles$/i,
501
+ /o[iu]s$/i, // "carnivorous"
502
+ /pox$/i, // "chickpox", "smallpox"
503
+ /sheep$/i
504
+ ].forEach(pluralize.addUncountableRule)
505
+
506
+ return pluralize
507
+ })
508
+
509
+ import pluralize from 'pluralize'
510
+ export default pluralize
@@ -1,241 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
- // @ts-ignore
5
-
6
- // __pluralize.js
7
-
8
- // Rule storage - __pluralize and singularize need to be run sequentially,
9
- // while other rules can be optimized using an object for instant lookups.
10
- const pluralRules = []
11
- const singularRules = []
12
- const uncountables = {}
13
- const irregularPlurals = {}
14
- const irregularSingles = {}
15
-
16
- /**
17
- * Sanitize a pluralization rule to a usable regular expression.
18
- * @param {(RegExp|string)} rule
19
- * @return {RegExp}
20
- */
21
- function sanitizeRule (rule) {
22
- return typeof rule === 'string' ? new RegExp(`^${rule}$`, 'i') : rule
23
- }
24
-
25
- /**
26
- * Pass in a word token to produce a function that can replicate the case on another word.
27
- * @param {string} word
28
- * @param {string} token
29
- * @return {string}
30
- */
31
- function restoreCase (word, token) {
32
- if (word === token) return token
33
- if (word === word.toLowerCase()) return token.toLowerCase()
34
- if (word === word.toUpperCase()) return token.toUpperCase()
35
- if (word[0] === word[0].toUpperCase()) {
36
- return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase()
37
- }
38
- return token.toLowerCase()
39
- }
40
-
41
- /**
42
- * Interpolate a regexp string.
43
- * @param {string} str
44
- * @param {Array} args
45
- * @return {string}
46
- */
47
- function interpolate (str, args) {
48
- return str.replace(/\$(\d{1,2})/g, (match, index) => args[index] || '')
49
- }
50
-
51
- /**
52
- * Replace a word using a rule.
53
- * @param {string} word
54
- * @param {Array} rule
55
- * @return {string}
56
- */
57
- function replace (word, rule) {
58
- return word.replace(rule[0], (match, ...args) => {
59
- const result = interpolate(rule[1], args)
60
- return match === '' ? restoreCase(word[args[args.length - 2] - 1], result) : restoreCase(match, result)
61
- })
62
- }
63
-
64
- /**
65
- * Sanitize a word by passing in the word and sanitization rules.
66
- * @param {string} token
67
- * @param {string} word
68
- * @param {Array} rules
69
- * @return {string}
70
- */
71
- function sanitizeWord (token, word, rules) {
72
- if (!token.length || uncountables.hasOwnProperty(token)) return word
73
-
74
- for (let i = rules.length - 1; i >= 0; i--) {
75
- const rule = rules[i]
76
- if (rule[0].test(word)) return replace(word, rule)
77
- }
78
-
79
- return word
80
- }
81
-
82
- /**
83
- * Replace a word with the updated word.
84
- * @param {Object} replaceMap
85
- * @param {Object} keepMap
86
- * @param {Array} rules
87
- * @return {Function}
88
- */
89
- function replaceWord (replaceMap, keepMap, rules) {
90
- return function (word) {
91
- const token = word.toLowerCase()
92
-
93
- if (keepMap.hasOwnProperty(token)) return restoreCase(word, token)
94
- if (replaceMap.hasOwnProperty(token)) return restoreCase(word, replaceMap[token])
95
-
96
- return sanitizeWord(token, word, rules)
97
- }
98
- }
99
-
100
- /**
101
- * Check if a word is part of the map.
102
- */
103
- function checkWord (replaceMap, keepMap, rules) {
104
- return function (word) {
105
- const token = word.toLowerCase()
106
- if (keepMap.hasOwnProperty(token)) return true
107
- if (replaceMap.hasOwnProperty(token)) return false
108
- return sanitizeWord(token, token, rules) === token
109
- }
110
- }
111
-
112
- /**
113
- * Pluralize or singularize a word based on the passed in count.
114
- * @param {string} word The word to __pluralize
115
- * @param {number} count How many of the word exist
116
- * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)
117
- * @return {string}
118
- */
119
- function __pluralize (word, count, inclusive) {
120
- const pluralized = count === 1 ? __pluralize.singular(word) : __pluralize.plural(word)
121
- return (inclusive ? `${count} ` : '') + pluralized
122
- }
123
-
124
- // Attach methods to __pluralize function
125
- __pluralize.plural = replaceWord(irregularSingles, irregularPlurals, pluralRules)
126
- __pluralize.isPlural = checkWord(irregularSingles, irregularPlurals, pluralRules)
127
- __pluralize.singular = replaceWord(irregularPlurals, irregularSingles, singularRules)
128
- __pluralize.isSingular = checkWord(irregularPlurals, irregularSingles, singularRules)
129
-
130
- /**
131
- * Add a pluralization rule to the collection.
132
- * @param {(string|RegExp)} rule
133
- * @param {string} replacement
134
- */
135
- __pluralize.addPluralRule = function (rule, replacement) {
136
- pluralRules.push([sanitizeRule(rule), replacement])
137
- }
138
-
139
- /**
140
- * Add a singularization rule to the collection.
141
- * @param {(string|RegExp)} rule
142
- * @param {string} replacement
143
- */
144
- __pluralize.addSingularRule = function (rule, replacement) {
145
- singularRules.push([sanitizeRule(rule), replacement])
146
- }
147
-
148
- /**
149
- * Add an uncountable word rule.
150
- * @param {(string|RegExp)} word
151
- */
152
- __pluralize.addUncountableRule = function (word) {
153
- if (typeof word === 'string') {
154
- uncountables[word.toLowerCase()] = true
155
- return
156
- }
157
- __pluralize.addPluralRule(word, '$0')
158
- __pluralize.addSingularRule(word, '$0')
159
- }
160
-
161
- /**
162
- * Add an irregular word definition.
163
- * @param {string} single
164
- * @param {string} plural
165
- */
166
- __pluralize.addIrregularRule = function (single, plural) {
167
- const pluralLower = plural.toLowerCase()
168
- const singleLower = single.toLowerCase()
169
- irregularSingles[singleLower] = pluralLower
170
- irregularPlurals[pluralLower] = singleLower
171
- };
172
-
173
- // Irregular rules
174
- [
175
- ['I', 'we'], ['me', 'us'], ['he', 'they'], ['she', 'they'], ['them', 'them'],
176
- ['myself', 'ourselves'], ['yourself', 'yourselves'], ['itself', 'themselves'],
177
- ['herself', 'themselves'], ['himself', 'themselves'], ['themself', 'themselves'],
178
- ['is', 'are'], ['was', 'were'], ['has', 'have'], ['this', 'these'], ['that', 'those'],
179
- ['echo', 'echoes'], ['dingo', 'dingoes'], ['volcano', 'volcanoes'], ['tornado', 'tornadoes'],
180
- ['torpedo', 'torpedoes'], ['genus', 'genera'], ['viscus', 'viscera'], ['stigma', 'stigmata'],
181
- ['stoma', 'stomata'], ['dogma', 'dogmata'], ['lemma', 'lemmata'], ['schema', 'schemata'],
182
- ['anathema', 'anathemata'], ['ox', 'oxen'], ['axe', 'axes'], ['die', 'dice'], ['yes', 'yeses'],
183
- ['foot', 'feet'], ['eave', 'eaves'], ['goose', 'geese'], ['tooth', 'teeth'], ['quiz', 'quizzes'],
184
- ['human', 'humans'], ['proof', 'proofs'], ['carve', 'carves'], ['valve', 'valves'],
185
- ['looey', 'looies'], ['thief', 'thieves'], ['groove', 'grooves'], ['pickaxe', 'pickaxes'],
186
- ['passerby', 'passersby']
187
- ].forEach(([single, plural]) => __pluralize.addIrregularRule(single, plural));
188
-
189
- // Pluralization rules
190
- [
191
- [/s?$/i, 's'], [/[^\u0000-\u007F]$/i, '$0'], [/([^aeiou]ese)$/i, '$1'],
192
- [/(ax|test)is$/i, '$1es'], [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'],
193
- [/(e[mn]u)s?$/i, '$1s'], [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'],
194
- [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'],
195
- [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'], [/(seraph|cherub)(?:im)?$/i, '$1im'],
196
- [/(her|at|gr)o$/i, '$1oes'],
197
- [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'],
198
- [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'],
199
- [/sis$/i, 'ses'], [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'],
200
- [/([^aeiouy]|qu)y$/i, '$1ies'], [/([^ch][ieo][ln])ey$/i, '$1ies'],
201
- [/(x|ch|ss|sh|zz)$/i, '$1es'], [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],
202
- [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'], [/(pe)(?:rson|ople)$/i, '$1ople'],
203
- [/(child)(?:ren)?$/i, '$1ren'], [/eaux$/i, '$0'], [/m[ae]n$/i, 'men'], ['thou', 'you']
204
- ].forEach(([rule, replacement]) => __pluralize.addPluralRule(rule, replacement));
205
-
206
- // Singularization rules
207
- [
208
- [/s$/i, ''], [/(ss)$/i, '$1'], [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'],
209
- [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'], [/ies$/i, 'y'],
210
- [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'],
211
- [/\b(mon|smil)ies$/i, '$1ey'], [/\b((?:tit)?m|l)ice$/i, '$1ouse'],
212
- [/(seraph|cherub)im$/i, '$1'], [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'],
213
- [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'],
214
- [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'], [/(test)(?:is|es)$/i, '$1is'],
215
- [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'],
216
- [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'],
217
- [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'],
218
- [/(alumn|alg|vertebr)ae$/i, '$1a'], [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'],
219
- [/(matr|append)ices$/i, '$1ix'], [/(pe)(rson|ople)$/i, '$1rson'], [/(child)ren$/i, '$1'],
220
- [/(eau)x?$/i, '$1'], [/men$/i, 'man']
221
- ].forEach(([rule, replacement]) => __pluralize.addSingularRule(rule, replacement));
222
-
223
- // Uncountable rules
224
- [
225
- 'adulthood', 'advice', 'agenda', 'aid', 'aircraft', 'alcohol', 'ammo', 'analytics',
226
- 'anime', 'athletics', 'audio', 'bison', 'blood', 'bream', 'buffalo', 'butter',
227
- 'carp', 'cash', 'chassis', 'chess', 'clothing', 'cod', 'commerce', 'cooperation',
228
- 'corps', 'debris', 'diabetes', 'digestion', 'elk', 'energy', 'equipment',
229
- 'excretion', 'expertise', 'firmware', 'flounder', 'fun', 'gallows', 'garbage',
230
- 'graffiti', 'hardware', 'headquarters', 'health', 'herpes', 'highjinks', 'homework',
231
- 'housework', 'information', 'jeans', 'justice', 'kudos', 'labour', 'literature',
232
- 'machinery', 'mackerel', 'mail', 'media', 'mews', 'moose', 'music', 'mud', 'manga',
233
- 'news', 'only', 'personnel', 'pike', 'plankton', 'pliers', 'police', 'pollution',
234
- 'premises', 'rain', 'research', 'rice', 'salmon', 'scissors', 'series', 'sewage',
235
- 'shambles', 'shrimp', 'software', 'species', 'staff', 'swine', 'tennis', 'traffic',
236
- 'transportation', 'trout', 'tuna', 'wealth', 'welfare', 'whiting', 'wildebeest',
237
- 'wildlife', 'you', /pok[eé]mon$/i, /[^aeiou]ese$/i, /deer$/i, /fish$/i,
238
- /measles$/i, /o[iu]s$/i, /pox$/i, /sheep$/i
239
- ].forEach(__pluralize.addUncountableRule)
240
-
241
- export default __pluralize