toolbox-x 1.0.0

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.
Files changed (190) hide show
  1. package/LICENSE +201 -0
  2. package/dist/Color-B3mgF9Dh.d.cts +486 -0
  3. package/dist/Color-D38Xrw65.d.mts +486 -0
  4. package/dist/Stylog-Df7eq3-j.d.cts +519 -0
  5. package/dist/Stylog-jvlLcMQq.d.mts +519 -0
  6. package/dist/array-DvW0zIu6.d.mts +130 -0
  7. package/dist/array-rUnEVisO.d.cts +130 -0
  8. package/dist/basics-D_eSv0cu.cjs +132 -0
  9. package/dist/basics-Dp_aEK81.mjs +115 -0
  10. package/dist/basics-WEYWlnRO.d.cts +95 -0
  11. package/dist/basics-uBSfkBEI.d.mts +95 -0
  12. package/dist/case-BWIt8Ash.mjs +449 -0
  13. package/dist/case-C-S-b5YP.d.cts +327 -0
  14. package/dist/case-CS8Ii3A7.cjs +526 -0
  15. package/dist/case-CybASFPD.d.mts +327 -0
  16. package/dist/change-case.cjs +32 -0
  17. package/dist/change-case.d.cts +18 -0
  18. package/dist/change-case.d.mts +18 -0
  19. package/dist/change-case.mjs +19 -0
  20. package/dist/colors.cjs +574 -0
  21. package/dist/colors.d.cts +355 -0
  22. package/dist/colors.d.mts +355 -0
  23. package/dist/colors.mjs +547 -0
  24. package/dist/constants-2gAw23_7.mjs +144 -0
  25. package/dist/constants-B34K0QPi.d.cts +21 -0
  26. package/dist/constants-BIBDKY1u.cjs +924 -0
  27. package/dist/constants-BWT-810U.cjs +158 -0
  28. package/dist/constants-BwbHnXlM.mjs +662 -0
  29. package/dist/constants-BxN9l5el.cjs +74 -0
  30. package/dist/constants-CLS_bgKD.d.mts +847 -0
  31. package/dist/constants-D73iFu8g.mjs +171 -0
  32. package/dist/constants-DAfRxaa8.mjs +62 -0
  33. package/dist/constants-DQYeCjlx.cjs +207 -0
  34. package/dist/constants-Deeie-iH.d.mts +21 -0
  35. package/dist/constants-DpTG9RP6.d.mts +29 -0
  36. package/dist/constants-DqwnkJ_d.cjs +740 -0
  37. package/dist/constants-DvRUY_FY.cjs +150 -0
  38. package/dist/constants-VcRtQu0K.d.cts +29 -0
  39. package/dist/constants-X5hm1UtB.mjs +912 -0
  40. package/dist/constants-eNd-iYsV.mjs +134 -0
  41. package/dist/constants-qm8FafmD.d.cts +847 -0
  42. package/dist/constants.cjs +415 -0
  43. package/dist/constants.d.cts +184 -0
  44. package/dist/constants.d.mts +184 -0
  45. package/dist/constants.mjs +378 -0
  46. package/dist/convert-BOCgUv2D.cjs +252 -0
  47. package/dist/convert-Bn4jFomQ.mjs +169 -0
  48. package/dist/convert-BrzlG-m_.cjs +475 -0
  49. package/dist/convert-DhaUoPVU.mjs +368 -0
  50. package/dist/converter-1P90_RcP.d.mts +402 -0
  51. package/dist/converter-CmkcAppi.d.cts +402 -0
  52. package/dist/converter.cjs +780 -0
  53. package/dist/converter.d.cts +29 -0
  54. package/dist/converter.d.mts +29 -0
  55. package/dist/converter.mjs +771 -0
  56. package/dist/countries-CIpmtEzV.cjs +1469 -0
  57. package/dist/countries-Cy0xiqS3.mjs +1463 -0
  58. package/dist/css-colors-Bx947Ng3.d.cts +179 -0
  59. package/dist/css-colors-CXCDqQbG.cjs +186 -0
  60. package/dist/css-colors-CXTp1vvy.d.mts +179 -0
  61. package/dist/css-colors-DfUW3nTR.mjs +180 -0
  62. package/dist/date.cjs +332 -0
  63. package/dist/date.d.cts +213 -0
  64. package/dist/date.d.mts +213 -0
  65. package/dist/date.mjs +298 -0
  66. package/dist/dom.cjs +461 -0
  67. package/dist/dom.d.cts +228 -0
  68. package/dist/dom.d.mts +228 -0
  69. package/dist/dom.mjs +429 -0
  70. package/dist/form-BMFVGUrN.d.mts +118 -0
  71. package/dist/form-DRFbryvK.d.cts +118 -0
  72. package/dist/guards-3kaUX66g.mjs +157 -0
  73. package/dist/guards-C8gkvIHb.cjs +240 -0
  74. package/dist/guards-DdyU4h4o.mjs +110 -0
  75. package/dist/guards-Efhp1mNy.cjs +151 -0
  76. package/dist/guards.cjs +172 -0
  77. package/dist/guards.d.cts +399 -0
  78. package/dist/guards.d.mts +399 -0
  79. package/dist/guards.mjs +75 -0
  80. package/dist/hash-B6JPEyAz.d.mts +131 -0
  81. package/dist/hash-NTpeKYB_.d.cts +131 -0
  82. package/dist/hash.cjs +2126 -0
  83. package/dist/hash.d.cts +1239 -0
  84. package/dist/hash.d.mts +1239 -0
  85. package/dist/hash.mjs +2095 -0
  86. package/dist/http-status-BAZdtr7-.d.mts +65 -0
  87. package/dist/http-status-U_3MtoGb.d.cts +65 -0
  88. package/dist/http-status.cjs +173 -0
  89. package/dist/http-status.d.cts +142 -0
  90. package/dist/http-status.d.mts +142 -0
  91. package/dist/http-status.mjs +171 -0
  92. package/dist/index.cjs +2551 -0
  93. package/dist/index.d.cts +1493 -0
  94. package/dist/index.d.mts +1493 -0
  95. package/dist/index.mjs +2357 -0
  96. package/dist/object-B0TV3eHx.d.mts +8052 -0
  97. package/dist/object-Blq0Amdv.d.cts +8052 -0
  98. package/dist/objectify-CDs0Fbr1.mjs +417 -0
  99. package/dist/objectify-DIJ-OBmo.cjs +524 -0
  100. package/dist/paginator.cjs +245 -0
  101. package/dist/paginator.d.cts +144 -0
  102. package/dist/paginator.d.mts +144 -0
  103. package/dist/paginator.mjs +243 -0
  104. package/dist/parse-2ubxXZRp.cjs +211 -0
  105. package/dist/parse-N7g942uy.mjs +164 -0
  106. package/dist/pluralizer-BjMIc6uT.d.mts +42 -0
  107. package/dist/pluralizer-Cb6ZmrDl.d.cts +42 -0
  108. package/dist/pluralizer.cjs +678 -0
  109. package/dist/pluralizer.d.cts +152 -0
  110. package/dist/pluralizer.d.mts +152 -0
  111. package/dist/pluralizer.mjs +676 -0
  112. package/dist/primitives-B26uZolQ.cjs +228 -0
  113. package/dist/primitives-KsFUp3kQ.mjs +144 -0
  114. package/dist/specials-D48_IZbd.d.mts +108 -0
  115. package/dist/specials-DzLr1ZgU.cjs +477 -0
  116. package/dist/specials-LVONlKbQ.d.cts +108 -0
  117. package/dist/specials-uhDuRg8H.mjs +292 -0
  118. package/dist/string-CBAbxaG1.d.mts +258 -0
  119. package/dist/string-CsNsm_65.d.cts +258 -0
  120. package/dist/stylog.cjs +621 -0
  121. package/dist/stylog.d.cts +49 -0
  122. package/dist/stylog.d.mts +49 -0
  123. package/dist/stylog.mjs +614 -0
  124. package/dist/timezone-B2OYK6Fh.mjs +5589 -0
  125. package/dist/timezone-Beh9IGpw.cjs +5625 -0
  126. package/dist/types/array.cjs +16 -0
  127. package/dist/types/array.d.cts +18 -0
  128. package/dist/types/array.d.mts +18 -0
  129. package/dist/types/array.mjs +17 -0
  130. package/dist/types/colors.cjs +16 -0
  131. package/dist/types/colors.d.cts +18 -0
  132. package/dist/types/colors.d.mts +18 -0
  133. package/dist/types/colors.mjs +17 -0
  134. package/dist/types/converter.cjs +16 -0
  135. package/dist/types/converter.d.cts +18 -0
  136. package/dist/types/converter.d.mts +18 -0
  137. package/dist/types/converter.mjs +17 -0
  138. package/dist/types/form.cjs +16 -0
  139. package/dist/types/form.d.cts +18 -0
  140. package/dist/types/form.d.mts +18 -0
  141. package/dist/types/form.mjs +17 -0
  142. package/dist/types/hash.cjs +16 -0
  143. package/dist/types/hash.d.cts +18 -0
  144. package/dist/types/hash.d.mts +18 -0
  145. package/dist/types/hash.mjs +17 -0
  146. package/dist/types/http-status.cjs +16 -0
  147. package/dist/types/http-status.d.cts +18 -0
  148. package/dist/types/http-status.d.mts +18 -0
  149. package/dist/types/http-status.mjs +17 -0
  150. package/dist/types/index.cjs +16 -0
  151. package/dist/types/index.d.cts +18 -0
  152. package/dist/types/index.d.mts +18 -0
  153. package/dist/types/index.mjs +17 -0
  154. package/dist/types/number.cjs +16 -0
  155. package/dist/types/number.d.cts +18 -0
  156. package/dist/types/number.d.mts +18 -0
  157. package/dist/types/number.mjs +17 -0
  158. package/dist/types/object.cjs +16 -0
  159. package/dist/types/object.d.cts +18 -0
  160. package/dist/types/object.d.mts +18 -0
  161. package/dist/types/object.mjs +17 -0
  162. package/dist/types/pluralizer.cjs +16 -0
  163. package/dist/types/pluralizer.d.cts +18 -0
  164. package/dist/types/pluralizer.d.mts +18 -0
  165. package/dist/types/pluralizer.mjs +17 -0
  166. package/dist/types/string.cjs +16 -0
  167. package/dist/types/string.d.cts +18 -0
  168. package/dist/types/string.d.mts +18 -0
  169. package/dist/types/string.mjs +17 -0
  170. package/dist/types/stylog.cjs +16 -0
  171. package/dist/types/stylog.d.cts +18 -0
  172. package/dist/types/stylog.d.mts +18 -0
  173. package/dist/types/stylog.mjs +17 -0
  174. package/dist/types/utils.cjs +16 -0
  175. package/dist/types/utils.d.cts +18 -0
  176. package/dist/types/utils.d.mts +18 -0
  177. package/dist/types/utils.mjs +17 -0
  178. package/dist/types/verbalizer.cjs +16 -0
  179. package/dist/types/verbalizer.d.cts +30 -0
  180. package/dist/types/verbalizer.d.mts +30 -0
  181. package/dist/types/verbalizer.mjs +17 -0
  182. package/dist/utilities-CLUmdQeV.cjs +140 -0
  183. package/dist/utilities-m5yFKqLd.mjs +105 -0
  184. package/dist/utils-ClW9LA6f.mjs +449 -0
  185. package/dist/utils-DLFRgXUC.cjs +568 -0
  186. package/dist/verbalizer.cjs +998 -0
  187. package/dist/verbalizer.d.cts +148 -0
  188. package/dist/verbalizer.d.mts +148 -0
  189. package/dist/verbalizer.mjs +996 -0
  190. package/package.json +249 -0
@@ -0,0 +1,678 @@
1
+ /**
2
+ * Copyright 2026 - present Nazmul Hassan
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
18
+ const require_primitives = require('./primitives-B26uZolQ.cjs');
19
+ const require_utilities = require('./utilities-CLUmdQeV.cjs');
20
+
21
+ //#region src/pluralizer/rules.ts
22
+ /** Irregular singular → plural mappings */
23
+ const irregularRules = /* @__PURE__ */ Object.freeze([
24
+ ["I", "we"],
25
+ ["me", "us"],
26
+ ["he", "they"],
27
+ ["she", "they"],
28
+ ["them", "them"],
29
+ ["myself", "ourselves"],
30
+ ["yourself", "yourselves"],
31
+ ["itself", "themselves"],
32
+ ["herself", "themselves"],
33
+ ["himself", "themselves"],
34
+ ["themself", "themselves"],
35
+ ["this", "these"],
36
+ ["that", "those"],
37
+ ["my", "our"],
38
+ ["its", "their"],
39
+ ["his", "their"],
40
+ ["her", "their"],
41
+ ["is", "are"],
42
+ ["was", "were"],
43
+ ["has", "have"],
44
+ ["analysis", "analyses"],
45
+ ["anathema", "anathemata"],
46
+ ["appendix", "appendices"],
47
+ ["automaton", "automata"],
48
+ ["basis", "bases"],
49
+ ["calf", "calves"],
50
+ ["carve", "carves"],
51
+ ["child", "children"],
52
+ ["codex", "codices"],
53
+ ["criterion", "criteria"],
54
+ ["crisis", "crises"],
55
+ ["datum", "data"],
56
+ ["diagnosis", "diagnoses"],
57
+ ["die", "dice"],
58
+ ["dogma", "dogmata"],
59
+ ["echo", "echoes"],
60
+ ["elf", "elves"],
61
+ ["foot", "feet"],
62
+ ["genus", "genera"],
63
+ ["goose", "geese"],
64
+ ["groove", "grooves"],
65
+ ["half", "halves"],
66
+ ["hedron", "hedra"],
67
+ ["hero", "heroes"],
68
+ ["hoof", "hooves"],
69
+ ["human", "humans"],
70
+ ["honey", "honeys"],
71
+ ["index", "indices"],
72
+ ["leaf", "leaves"],
73
+ ["lemma", "lemmata"],
74
+ ["loaf", "loaves"],
75
+ ["looey", "looies"],
76
+ ["man", "men"],
77
+ ["mango", "mangoes"],
78
+ ["matrix", "matrices"],
79
+ ["medium", "media"],
80
+ ["mouse", "mice"],
81
+ ["neurosis", "neuroses"],
82
+ ["noumenon", "noumena"],
83
+ ["organon", "organa"],
84
+ ["ox", "oxen"],
85
+ ["passerby", "passersby"],
86
+ ["phenomenon", "phenomena"],
87
+ ["pickaxe", "pickaxes"],
88
+ ["potato", "potatoes"],
89
+ ["prolegomenon", "prolegomena"],
90
+ ["proof", "proofs"],
91
+ ["quiz", "quizzes"],
92
+ ["schema", "schemata"],
93
+ ["self", "selves"],
94
+ ["shelf", "shelves"],
95
+ ["stigma", "stigmata"],
96
+ ["stoma", "stomata"],
97
+ ["thief", "thieves"],
98
+ ["tooth", "teeth"],
99
+ ["tomato", "tomatoes"],
100
+ ["torpedo", "torpedoes"],
101
+ ["tornado", "tornadoes"],
102
+ ["valve", "valves"],
103
+ ["vertex", "vertices"],
104
+ ["virus", "viruses"],
105
+ ["viscus", "viscera"],
106
+ ["volcano", "volcanoes"],
107
+ ["woman", "women"],
108
+ ["wolf", "wolves"],
109
+ ["yes", "yeses"]
110
+ ]);
111
+ /** Pluralization rules with regex and replacements */
112
+ const pluralRules = /* @__PURE__ */ Object.freeze([
113
+ [/s?$/i, "s"],
114
+ [/(pe)(rson|ople)$/i, "$1ople"],
115
+ [/(child)(?:ren)?$/i, "$1ren"],
116
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
117
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1a"],
118
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)um$/i, "$1a"],
119
+ [/(octop|vir)us$/i, "$1i"],
120
+ [/(cris|ax|test)is$/i, "$1es"],
121
+ [/(alias|status)$/i, "$1es"],
122
+ [/(shoe)$/i, "$1s"],
123
+ [/(bus)$/i, "$1es"],
124
+ [/(o)es$/i, "$1es"],
125
+ [/(x|ch|ss|sh|zz)$/i, "$1es"],
126
+ [/(her|at|gr)o$/i, "$1oes"],
127
+ [/sis$/i, "ses"],
128
+ [/^(chief|chef|belief|roof|cliff|reef)$/i, "$1s"],
129
+ [/(seraph|cherub)$/i, "$1im"],
130
+ [/(kni|wi|li)fe$/i, "$1ves"],
131
+ [/(ar|l|ea|eo|oa|hoo)f$/i, "$1ves"],
132
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
133
+ [/(tive)$/i, "$1s"],
134
+ [/(hive)$/i, "$1s"],
135
+ [/(quiz)$/i, "$1zes"],
136
+ [/m[ae]n$/i, "men"],
137
+ [/eaux$/i, "$0"],
138
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"]
139
+ ]);
140
+ /** Singularization rules with regex and replacements */
141
+ const singularRules = /* @__PURE__ */ Object.freeze([
142
+ [/s$/i, ""],
143
+ [/(\P{ASCII})$/u, "$1"],
144
+ [/(pe)(rson|ople)$/i, "$1rson"],
145
+ [/(child)ren$/i, "$1"],
146
+ [/(eau)x?$/i, "$1"],
147
+ [/men$/i, "man"],
148
+ [/(matr|append)ices$/i, "$1ix"],
149
+ [/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
150
+ [/(alumn|alg|vertebr)ae$/i, "$1a"],
151
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
152
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
153
+ [/(test)(?:is|es)$/i, "$1is"],
154
+ [/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
155
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
156
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
157
+ [/^(chief|chef|belief|roof|cliff|reef)s$/i, "$1"],
158
+ [/(seraph|cherub)im$/i, "$1"],
159
+ [/\b((?:tit)?m|l)ice$/i, "$1ouse"],
160
+ [/\b(mon|smil)ies$/i, "$1ey"],
161
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, "$1ie"],
162
+ [/ies$/i, "y"],
163
+ [/(kni|wi|li)ves$/i, "$1fe"],
164
+ [/(ar|l|ea|eo|oa|hoo)ves$/i, "$1f"],
165
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
166
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, "$1fe"],
167
+ [/(ss)$/i, "$1"],
168
+ [/(quiz)zes$/i, "$1"],
169
+ [/(vert|ind)ices$/i, "$1ex"],
170
+ [/^(ox)en$/i, "$1"],
171
+ [/(alias|status)es$/i, "$1"],
172
+ [/(octop|vir)i$/i, "$1us"],
173
+ [/(cris|ax|test)es$/i, "$1is"],
174
+ [/(shoe)s$/i, "$1"],
175
+ [/(her|at|gr)oes$/i, "$1o"],
176
+ [/oes$/i, "o"],
177
+ [/(bus)es$/i, "$1"],
178
+ [/ices$/i, "ex"],
179
+ [/(hive)s$/i, "$1"],
180
+ [/(tive)s$/i, "$1"],
181
+ [/([^f])ves$/i, "$1fe"],
182
+ [/([lr])ves$/i, "$1f"],
183
+ [/(^analy)ses$/i, "$1sis"],
184
+ [/([ti])a$/i, "$1um"],
185
+ [/(n)ews$/i, "$1ews"],
186
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"]
187
+ ]);
188
+ /** Uncountable words */
189
+ const uncountables = /* @__PURE__ */ Object.freeze(new Set([
190
+ "aircraft",
191
+ "alcohol",
192
+ "ammo",
193
+ "analytics",
194
+ "anime",
195
+ "athletics",
196
+ "audio",
197
+ "bison",
198
+ "blood",
199
+ "butter",
200
+ "cash",
201
+ "chess",
202
+ "clothing",
203
+ "commerce",
204
+ "corps",
205
+ "debris",
206
+ "diabetes",
207
+ "energy",
208
+ "equipment",
209
+ "furniture",
210
+ "hardware",
211
+ "headquarters",
212
+ "health",
213
+ "homework",
214
+ "housework",
215
+ "information",
216
+ "insurance",
217
+ "jewelry",
218
+ "jewellery",
219
+ "knowledge",
220
+ "livestock",
221
+ "luck",
222
+ "machinery",
223
+ "metadata",
224
+ "money",
225
+ "music",
226
+ "news",
227
+ "poetry",
228
+ "pollution",
229
+ "research",
230
+ "rice",
231
+ "series",
232
+ "software",
233
+ "species",
234
+ "staff",
235
+ "traffic",
236
+ "transportation",
237
+ "weather",
238
+ "wildlife",
239
+ "you",
240
+ "adulthood",
241
+ "advertising",
242
+ "anger",
243
+ "applause",
244
+ "arithmetic",
245
+ "bacon",
246
+ "beef",
247
+ "biology",
248
+ "botany",
249
+ "carbon",
250
+ "chaos",
251
+ "cheese",
252
+ "childhood",
253
+ "coffee",
254
+ "compassion",
255
+ "cotton",
256
+ "dancing",
257
+ "delight",
258
+ "dignity",
259
+ "dirt",
260
+ "distribution",
261
+ "dust",
262
+ "economics",
263
+ "education",
264
+ "electricity",
265
+ "engineering",
266
+ "envy",
267
+ "ethics",
268
+ "evidence",
269
+ "evolution",
270
+ "failure",
271
+ "faith",
272
+ "fame",
273
+ "fiction",
274
+ "flour",
275
+ "flu",
276
+ "freedom",
277
+ "fuel",
278
+ "fun",
279
+ "garbage",
280
+ "garlic",
281
+ "genetics",
282
+ "golf",
283
+ "gossip",
284
+ "grammar",
285
+ "gratitude",
286
+ "grief",
287
+ "guilt",
288
+ "gymnastics",
289
+ "happiness",
290
+ "harm",
291
+ "hate",
292
+ "hatred",
293
+ "height",
294
+ "help",
295
+ "honesty",
296
+ "hospitality",
297
+ "humor",
298
+ "humour",
299
+ "hunger",
300
+ "importance",
301
+ "inflation",
302
+ "injustice",
303
+ "innocence",
304
+ "intelligence",
305
+ "irony",
306
+ "jealousy",
307
+ "joy",
308
+ "judo",
309
+ "justice",
310
+ "karate",
311
+ "kindness",
312
+ "labour",
313
+ "lack",
314
+ "laughter",
315
+ "lava",
316
+ "leather",
317
+ "leisure",
318
+ "lightning",
319
+ "linguistics",
320
+ "literature",
321
+ "litter",
322
+ "logic",
323
+ "loneliness",
324
+ "love",
325
+ "luggage",
326
+ "magic",
327
+ "management",
328
+ "mankind",
329
+ "marble",
330
+ "mathematics",
331
+ "mayonnaise",
332
+ "measles",
333
+ "meat",
334
+ "methane",
335
+ "mud",
336
+ "nature",
337
+ "nitrogen",
338
+ "nonsense",
339
+ "nurture",
340
+ "nutrition",
341
+ "obedience",
342
+ "obesity",
343
+ "passion",
344
+ "patience",
345
+ "permission",
346
+ "physics",
347
+ "poverty",
348
+ "pride",
349
+ "production",
350
+ "progress",
351
+ "pronunciation",
352
+ "psychology",
353
+ "publicity",
354
+ "punctuation",
355
+ "quality",
356
+ "quantity",
357
+ "quartz",
358
+ "racism",
359
+ "rain",
360
+ "recreation",
361
+ "relaxation",
362
+ "reliability",
363
+ "research",
364
+ "respect",
365
+ "revenge",
366
+ "rubbish",
367
+ "rum",
368
+ "safety",
369
+ "salt",
370
+ "sand",
371
+ "satire",
372
+ "scenery",
373
+ "shame",
374
+ "shopping",
375
+ "silence",
376
+ "sleep",
377
+ "smoke",
378
+ "smoking",
379
+ "snow",
380
+ "soap",
381
+ "soil",
382
+ "sorrow",
383
+ "speed",
384
+ "spelling",
385
+ "steam",
386
+ "strength",
387
+ "stuff",
388
+ "stupidity",
389
+ "success",
390
+ "sugar",
391
+ "sunshine",
392
+ "symmetry",
393
+ "tea",
394
+ "tennis",
395
+ "thirst",
396
+ "thunder",
397
+ "timber",
398
+ "toast",
399
+ "tolerance",
400
+ "trade",
401
+ "trust",
402
+ "understanding",
403
+ "underwear",
404
+ "unemployment",
405
+ "unity",
406
+ "usage",
407
+ "validity",
408
+ "veal",
409
+ "vegetation",
410
+ "vegetarianism",
411
+ "vengeance",
412
+ "violence",
413
+ "vision",
414
+ "vitality",
415
+ "warmth",
416
+ "wealth",
417
+ "weight",
418
+ "welfare",
419
+ "whiskey",
420
+ "width",
421
+ "wisdom",
422
+ "wool",
423
+ "yeast",
424
+ "yoga",
425
+ "youth",
426
+ "zinc",
427
+ "zoology",
428
+ /pok[eé]mon$/i,
429
+ /[^aeiou]ese$/i,
430
+ /deer$/i,
431
+ /fish$/i,
432
+ /measles$/i,
433
+ /o[iu]s$/i,
434
+ /pox$/i,
435
+ /sheep$/i,
436
+ /scissors$/i,
437
+ /pants$/i,
438
+ /shorts$/i,
439
+ /trousers$/i,
440
+ /jeans$/i
441
+ ]));
442
+
443
+ //#endregion
444
+ //#region src/pluralizer/Pluralizer.ts
445
+ /**
446
+ * @class Handles English word pluralization and singularization with support for irregular forms and uncountable nouns.
447
+ *
448
+ * - Provides methods to convert words between singular and plural forms, check if a word is plural or singular, and manage custom pluralization rules.
449
+ * - Supports adding custom pluralization and singularization rules, as well as uncountable nouns.
450
+ * - Automatically handles common irregular forms like "child" to "children"
451
+ * - Automatically loads common irregular forms and uncountable nouns.
452
+ * - Supports options for count-based pluralization, allowing for inclusive formatting.
453
+ * - This class is useful for applications that need to handle natural language processing, such as chatbots, content management systems, or any text processing tasks that require accurate pluralization.
454
+ *
455
+ * @remarks
456
+ * - For simpler pluralization (plural with only 's'), please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/formatUnitWithPlural formatUnitWithPlural} instead.
457
+ *
458
+ * - For ready to use instance, please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/pluralizer pluralizer} instead.
459
+ *
460
+ * @example
461
+ * const pluralizer = new Pluralizer();
462
+ * pluralizer.pluralize('child'); // "children"
463
+ * pluralizer.toSingular('geese'); // "goose"
464
+ * pluralizer.isPlural('fish'); // false (uncountable)
465
+ */
466
+ var Pluralizer = class {
467
+ #pluralRules = [];
468
+ #singularRules = [];
469
+ #uncountables = /* @__PURE__ */ new Set();
470
+ #irregularSingles = {};
471
+ #irregularPlurals = {};
472
+ /**
473
+ * Initializes the Pluralizer with default rules and exceptions.
474
+ * Automatically loads irregular, pluralization and singular rules along with pre-defined uncountable nouns.
475
+ */
476
+ constructor() {
477
+ this.#loadRules();
478
+ }
479
+ #loadRules() {
480
+ irregularRules.forEach(([single, plural]) => {
481
+ this.addIrregular(single, plural);
482
+ });
483
+ pluralRules.forEach(([rule, replacement]) => {
484
+ this.addPluralRule(rule, replacement);
485
+ });
486
+ singularRules.forEach(([rule, replacement]) => {
487
+ this.addSingularRule(rule, replacement);
488
+ });
489
+ uncountables.forEach((word) => {
490
+ this.addUncountable(word);
491
+ });
492
+ }
493
+ /** Restore case order(s) */
494
+ #restoreCase(original, transformed) {
495
+ original = original?.trim();
496
+ if (original === transformed) return transformed;
497
+ if (original === original.toLowerCase()) return transformed.toLowerCase();
498
+ if (original === original.toUpperCase()) return transformed.toUpperCase();
499
+ if (original[0] === original[0].toUpperCase() && original.slice(1) === original.slice(1).toLowerCase()) return transformed.charAt(0).toUpperCase() + transformed.slice(1).toLowerCase();
500
+ let result = "";
501
+ for (let i = 0; i < transformed.length; i++) {
502
+ const origChar = original[i];
503
+ if (origChar && origChar === origChar.toUpperCase() && origChar !== origChar.toLowerCase()) result += transformed[i].toUpperCase();
504
+ else result += transformed[i].toLowerCase();
505
+ }
506
+ return result;
507
+ }
508
+ /** Apply corresponding rules */
509
+ #applyRules(word, rules) {
510
+ if (!require_primitives.isNonEmptyString(word)) return "";
511
+ if (this.#isUncountable(word)) return word;
512
+ for (let i = rules.length - 1; i >= 0; i--) {
513
+ const [rule, replacement] = rules[i];
514
+ if (rule.test(word)) return word.replace(rule, replacement);
515
+ }
516
+ return word;
517
+ }
518
+ /**
519
+ * Check if a word is uncountable.
520
+ * Supports both `string` and `RegExp` entries.
521
+ */
522
+ #isUncountable(word) {
523
+ for (const entry of this.#uncountables) if (require_primitives.isString(entry)) {
524
+ if (entry.toLowerCase() === word) return true;
525
+ } else if (entry?.test(word)) return true;
526
+ return false;
527
+ }
528
+ /**
529
+ * * Add a new pluralization rule.
530
+ * @param rule Pattern to match singular words.
531
+ * @param replacement Replacement pattern for plural form.
532
+ * @example
533
+ * pluralizer.addPluralRule(/(quiz)$/i, '$1zes');
534
+ */
535
+ addPluralRule(rule, replacement) {
536
+ this.#pluralRules.push([rule, replacement]);
537
+ }
538
+ /**
539
+ * * Add a new singularization rule.
540
+ * @param rule Pattern to match plural words.
541
+ * @param replacement Replacement pattern for singular form.
542
+ * @example
543
+ * pluralizer.addSingularRule(/(matr)ices$/i, '$1ix');
544
+ */
545
+ addSingularRule(rule, replacement) {
546
+ this.#singularRules.push([rule, replacement]);
547
+ }
548
+ /**
549
+ * * Add a word or pattern that should never change between singular and plural.
550
+ * @param word A word or regex pattern.
551
+ * @example
552
+ * pluralizer.addUncountable('fish');
553
+ * pluralizer.addUncountable(/pok[eé]mon$/i);
554
+ */
555
+ addUncountable(word) {
556
+ this.#uncountables.add(require_primitives.isString(word) ? word?.toLowerCase() : word);
557
+ }
558
+ /**
559
+ * * Add a custom irregular form.
560
+ * @param single Singular word.
561
+ * @param plural Plural word.
562
+ * @example
563
+ * pluralizer.addIrregular('person', 'people');
564
+ */
565
+ addIrregular(single, plural) {
566
+ const singleLower = single?.toLowerCase();
567
+ const pluralLower = plural?.toLowerCase();
568
+ this.#irregularSingles[singleLower] = pluralLower;
569
+ this.#irregularPlurals[pluralLower] = singleLower;
570
+ }
571
+ /**
572
+ * * Get the proper singular or plural form based on optional count.
573
+ * @param word Target word to pluralize or singularize.
574
+ * @param options Optional count and inclusive formatting.
575
+ * @returns The transformed word.
576
+ * @example
577
+ * pluralizer.pluralize('category', { count: 3 }); // "categories"
578
+ * pluralizer.pluralize('child', { count: 1, inclusive: true }); // "1 child"
579
+ */
580
+ pluralize(word, options = {}) {
581
+ const count = require_utilities.normalizeNumber(options?.count);
582
+ if (!require_primitives.isUndefined(count)) {
583
+ const pluralized = count === 1 ? this.toSingular(word) : this.toPlural(word);
584
+ return options?.inclusive ? `${count} ${pluralized}` : pluralized;
585
+ }
586
+ return this.toPlural(word);
587
+ }
588
+ /**
589
+ * * Convert a word to its plural form.
590
+ * @param word Singular form of the word.
591
+ * @returns Plural form of the word.
592
+ * @example
593
+ * pluralizer.toPlural('analysis'); // "analyses"
594
+ */
595
+ toPlural(word) {
596
+ if (!require_primitives.isNonEmptyString(word)) return "";
597
+ const lower = word?.trim()?.toLowerCase();
598
+ if (this.#isUncountable(lower)) return word;
599
+ if (this.#irregularSingles[lower]) return this.#restoreCase(word, this.#irregularSingles[lower]);
600
+ return this.#restoreCase(word, this.#applyRules(lower, this.#pluralRules));
601
+ }
602
+ /**
603
+ * * Convert a word to its singular form.
604
+ * @param word Plural form of the word.
605
+ * @returns Singular form of the word.
606
+ * @example
607
+ * pluralizer.toSingular('geese'); // "goose"
608
+ */
609
+ toSingular(word) {
610
+ if (!require_primitives.isNonEmptyString(word)) return "";
611
+ const lower = word?.trim()?.toLowerCase();
612
+ if (this.#isUncountable(lower)) return word;
613
+ if (this.#irregularPlurals[lower]) return this.#restoreCase(word, this.#irregularPlurals[lower]);
614
+ return this.#restoreCase(word, this.#applyRules(lower, this.#singularRules));
615
+ }
616
+ /**
617
+ * * Check if a given word is plural.
618
+ * @param word Word to check.
619
+ * @returns `true` if the word is plural, otherwise `false`.
620
+ * @remarks Always returns `true` for uncountable nouns.
621
+ * @example
622
+ * pluralizer.isPlural('children'); // true
623
+ * pluralizer.isPlural('water'); // true
624
+ */
625
+ isPlural(word) {
626
+ if (!require_primitives.isNonEmptyString(word)) return false;
627
+ const lower = word?.trim()?.toLowerCase();
628
+ if (this.#isUncountable(lower)) return true;
629
+ if (this.#irregularPlurals[lower]) return true;
630
+ if (this.#irregularSingles[lower]) return false;
631
+ return this.toSingular(lower) !== lower;
632
+ }
633
+ /**
634
+ * * Check if a given word is singular.
635
+ * @param word Word to check.
636
+ * @returns True if the word is singular, otherwise false.
637
+ * @remarks Always returns `true` for uncountable nouns.
638
+ * @example
639
+ * pluralizer.isSingular('child'); // true
640
+ * pluralizer.isPlural('water'); // true
641
+ */
642
+ isSingular(word) {
643
+ if (!require_primitives.isNonEmptyString(word)) return false;
644
+ const lower = word?.trim()?.toLowerCase();
645
+ if (this.#isUncountable(lower)) return true;
646
+ if (this.#irregularSingles[lower]) return true;
647
+ if (this.#irregularPlurals[lower]) return false;
648
+ return this.toSingular(lower) === lower;
649
+ }
650
+ };
651
+ /**
652
+ * Default shared instance of {@link https://toolbox.nazmul-nhb.dev/docs/classes/Pluralizer Pluralizer}.
653
+ *
654
+ * - _Use this when you don’t need multiple configurations._
655
+ * - _It comes preloaded with standard pluralization rules, irregular forms, and uncountable nouns._
656
+ *
657
+ * @remarks For simpler pluralization (plural with only 's'), please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/formatUnitWithPlural formatUnitWithPlural} instead.
658
+ *
659
+ * * Handles English word pluralization and singularization with support for irregular forms and uncountable nouns.
660
+ *
661
+ * - Provides methods to convert words between singular and plural forms, check if a word is plural or singular, and manage custom pluralization rules.
662
+ * - Supports adding custom pluralization and singularization rules, as well as uncountable nouns.
663
+ * - Automatically handles common irregular forms like "child" to "children"
664
+ * - Automatically loads common irregular forms and uncountable nouns.
665
+ * - Supports options for count-based pluralization, allowing for inclusive formatting.
666
+ * - This is useful for applications that need to handle natural language processing, such as chatbots, content management systems, or any text processing tasks that require accurate pluralization.
667
+ * @example
668
+ * import { pluralizer } from 'nhb-toolbox';
669
+ *
670
+ * pluralizer.pluralize('child'); // "children"
671
+ * pluralizer.toSingular('geese'); // "goose"
672
+ * pluralizer.isPlural('fish'); // false (uncountable)
673
+ */
674
+ const pluralizer = new Pluralizer();
675
+
676
+ //#endregion
677
+ exports.Pluralizer = Pluralizer;
678
+ exports.pluralizer = pluralizer;