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.
- package/LICENSE +201 -0
- package/dist/Color-B3mgF9Dh.d.cts +486 -0
- package/dist/Color-D38Xrw65.d.mts +486 -0
- package/dist/Stylog-Df7eq3-j.d.cts +519 -0
- package/dist/Stylog-jvlLcMQq.d.mts +519 -0
- package/dist/array-DvW0zIu6.d.mts +130 -0
- package/dist/array-rUnEVisO.d.cts +130 -0
- package/dist/basics-D_eSv0cu.cjs +132 -0
- package/dist/basics-Dp_aEK81.mjs +115 -0
- package/dist/basics-WEYWlnRO.d.cts +95 -0
- package/dist/basics-uBSfkBEI.d.mts +95 -0
- package/dist/case-BWIt8Ash.mjs +449 -0
- package/dist/case-C-S-b5YP.d.cts +327 -0
- package/dist/case-CS8Ii3A7.cjs +526 -0
- package/dist/case-CybASFPD.d.mts +327 -0
- package/dist/change-case.cjs +32 -0
- package/dist/change-case.d.cts +18 -0
- package/dist/change-case.d.mts +18 -0
- package/dist/change-case.mjs +19 -0
- package/dist/colors.cjs +574 -0
- package/dist/colors.d.cts +355 -0
- package/dist/colors.d.mts +355 -0
- package/dist/colors.mjs +547 -0
- package/dist/constants-2gAw23_7.mjs +144 -0
- package/dist/constants-B34K0QPi.d.cts +21 -0
- package/dist/constants-BIBDKY1u.cjs +924 -0
- package/dist/constants-BWT-810U.cjs +158 -0
- package/dist/constants-BwbHnXlM.mjs +662 -0
- package/dist/constants-BxN9l5el.cjs +74 -0
- package/dist/constants-CLS_bgKD.d.mts +847 -0
- package/dist/constants-D73iFu8g.mjs +171 -0
- package/dist/constants-DAfRxaa8.mjs +62 -0
- package/dist/constants-DQYeCjlx.cjs +207 -0
- package/dist/constants-Deeie-iH.d.mts +21 -0
- package/dist/constants-DpTG9RP6.d.mts +29 -0
- package/dist/constants-DqwnkJ_d.cjs +740 -0
- package/dist/constants-DvRUY_FY.cjs +150 -0
- package/dist/constants-VcRtQu0K.d.cts +29 -0
- package/dist/constants-X5hm1UtB.mjs +912 -0
- package/dist/constants-eNd-iYsV.mjs +134 -0
- package/dist/constants-qm8FafmD.d.cts +847 -0
- package/dist/constants.cjs +415 -0
- package/dist/constants.d.cts +184 -0
- package/dist/constants.d.mts +184 -0
- package/dist/constants.mjs +378 -0
- package/dist/convert-BOCgUv2D.cjs +252 -0
- package/dist/convert-Bn4jFomQ.mjs +169 -0
- package/dist/convert-BrzlG-m_.cjs +475 -0
- package/dist/convert-DhaUoPVU.mjs +368 -0
- package/dist/converter-1P90_RcP.d.mts +402 -0
- package/dist/converter-CmkcAppi.d.cts +402 -0
- package/dist/converter.cjs +780 -0
- package/dist/converter.d.cts +29 -0
- package/dist/converter.d.mts +29 -0
- package/dist/converter.mjs +771 -0
- package/dist/countries-CIpmtEzV.cjs +1469 -0
- package/dist/countries-Cy0xiqS3.mjs +1463 -0
- package/dist/css-colors-Bx947Ng3.d.cts +179 -0
- package/dist/css-colors-CXCDqQbG.cjs +186 -0
- package/dist/css-colors-CXTp1vvy.d.mts +179 -0
- package/dist/css-colors-DfUW3nTR.mjs +180 -0
- package/dist/date.cjs +332 -0
- package/dist/date.d.cts +213 -0
- package/dist/date.d.mts +213 -0
- package/dist/date.mjs +298 -0
- package/dist/dom.cjs +461 -0
- package/dist/dom.d.cts +228 -0
- package/dist/dom.d.mts +228 -0
- package/dist/dom.mjs +429 -0
- package/dist/form-BMFVGUrN.d.mts +118 -0
- package/dist/form-DRFbryvK.d.cts +118 -0
- package/dist/guards-3kaUX66g.mjs +157 -0
- package/dist/guards-C8gkvIHb.cjs +240 -0
- package/dist/guards-DdyU4h4o.mjs +110 -0
- package/dist/guards-Efhp1mNy.cjs +151 -0
- package/dist/guards.cjs +172 -0
- package/dist/guards.d.cts +399 -0
- package/dist/guards.d.mts +399 -0
- package/dist/guards.mjs +75 -0
- package/dist/hash-B6JPEyAz.d.mts +131 -0
- package/dist/hash-NTpeKYB_.d.cts +131 -0
- package/dist/hash.cjs +2126 -0
- package/dist/hash.d.cts +1239 -0
- package/dist/hash.d.mts +1239 -0
- package/dist/hash.mjs +2095 -0
- package/dist/http-status-BAZdtr7-.d.mts +65 -0
- package/dist/http-status-U_3MtoGb.d.cts +65 -0
- package/dist/http-status.cjs +173 -0
- package/dist/http-status.d.cts +142 -0
- package/dist/http-status.d.mts +142 -0
- package/dist/http-status.mjs +171 -0
- package/dist/index.cjs +2551 -0
- package/dist/index.d.cts +1493 -0
- package/dist/index.d.mts +1493 -0
- package/dist/index.mjs +2357 -0
- package/dist/object-B0TV3eHx.d.mts +8052 -0
- package/dist/object-Blq0Amdv.d.cts +8052 -0
- package/dist/objectify-CDs0Fbr1.mjs +417 -0
- package/dist/objectify-DIJ-OBmo.cjs +524 -0
- package/dist/paginator.cjs +245 -0
- package/dist/paginator.d.cts +144 -0
- package/dist/paginator.d.mts +144 -0
- package/dist/paginator.mjs +243 -0
- package/dist/parse-2ubxXZRp.cjs +211 -0
- package/dist/parse-N7g942uy.mjs +164 -0
- package/dist/pluralizer-BjMIc6uT.d.mts +42 -0
- package/dist/pluralizer-Cb6ZmrDl.d.cts +42 -0
- package/dist/pluralizer.cjs +678 -0
- package/dist/pluralizer.d.cts +152 -0
- package/dist/pluralizer.d.mts +152 -0
- package/dist/pluralizer.mjs +676 -0
- package/dist/primitives-B26uZolQ.cjs +228 -0
- package/dist/primitives-KsFUp3kQ.mjs +144 -0
- package/dist/specials-D48_IZbd.d.mts +108 -0
- package/dist/specials-DzLr1ZgU.cjs +477 -0
- package/dist/specials-LVONlKbQ.d.cts +108 -0
- package/dist/specials-uhDuRg8H.mjs +292 -0
- package/dist/string-CBAbxaG1.d.mts +258 -0
- package/dist/string-CsNsm_65.d.cts +258 -0
- package/dist/stylog.cjs +621 -0
- package/dist/stylog.d.cts +49 -0
- package/dist/stylog.d.mts +49 -0
- package/dist/stylog.mjs +614 -0
- package/dist/timezone-B2OYK6Fh.mjs +5589 -0
- package/dist/timezone-Beh9IGpw.cjs +5625 -0
- package/dist/types/array.cjs +16 -0
- package/dist/types/array.d.cts +18 -0
- package/dist/types/array.d.mts +18 -0
- package/dist/types/array.mjs +17 -0
- package/dist/types/colors.cjs +16 -0
- package/dist/types/colors.d.cts +18 -0
- package/dist/types/colors.d.mts +18 -0
- package/dist/types/colors.mjs +17 -0
- package/dist/types/converter.cjs +16 -0
- package/dist/types/converter.d.cts +18 -0
- package/dist/types/converter.d.mts +18 -0
- package/dist/types/converter.mjs +17 -0
- package/dist/types/form.cjs +16 -0
- package/dist/types/form.d.cts +18 -0
- package/dist/types/form.d.mts +18 -0
- package/dist/types/form.mjs +17 -0
- package/dist/types/hash.cjs +16 -0
- package/dist/types/hash.d.cts +18 -0
- package/dist/types/hash.d.mts +18 -0
- package/dist/types/hash.mjs +17 -0
- package/dist/types/http-status.cjs +16 -0
- package/dist/types/http-status.d.cts +18 -0
- package/dist/types/http-status.d.mts +18 -0
- package/dist/types/http-status.mjs +17 -0
- package/dist/types/index.cjs +16 -0
- package/dist/types/index.d.cts +18 -0
- package/dist/types/index.d.mts +18 -0
- package/dist/types/index.mjs +17 -0
- package/dist/types/number.cjs +16 -0
- package/dist/types/number.d.cts +18 -0
- package/dist/types/number.d.mts +18 -0
- package/dist/types/number.mjs +17 -0
- package/dist/types/object.cjs +16 -0
- package/dist/types/object.d.cts +18 -0
- package/dist/types/object.d.mts +18 -0
- package/dist/types/object.mjs +17 -0
- package/dist/types/pluralizer.cjs +16 -0
- package/dist/types/pluralizer.d.cts +18 -0
- package/dist/types/pluralizer.d.mts +18 -0
- package/dist/types/pluralizer.mjs +17 -0
- package/dist/types/string.cjs +16 -0
- package/dist/types/string.d.cts +18 -0
- package/dist/types/string.d.mts +18 -0
- package/dist/types/string.mjs +17 -0
- package/dist/types/stylog.cjs +16 -0
- package/dist/types/stylog.d.cts +18 -0
- package/dist/types/stylog.d.mts +18 -0
- package/dist/types/stylog.mjs +17 -0
- package/dist/types/utils.cjs +16 -0
- package/dist/types/utils.d.cts +18 -0
- package/dist/types/utils.d.mts +18 -0
- package/dist/types/utils.mjs +17 -0
- package/dist/types/verbalizer.cjs +16 -0
- package/dist/types/verbalizer.d.cts +30 -0
- package/dist/types/verbalizer.d.mts +30 -0
- package/dist/types/verbalizer.mjs +17 -0
- package/dist/utilities-CLUmdQeV.cjs +140 -0
- package/dist/utilities-m5yFKqLd.mjs +105 -0
- package/dist/utils-ClW9LA6f.mjs +449 -0
- package/dist/utils-DLFRgXUC.cjs +568 -0
- package/dist/verbalizer.cjs +998 -0
- package/dist/verbalizer.d.cts +148 -0
- package/dist/verbalizer.d.mts +148 -0
- package/dist/verbalizer.mjs +996 -0
- package/package.json +249 -0
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
import { n as PluralizeOptions } from "./pluralizer-Cb6ZmrDl.cjs";
|
|
18
|
+
|
|
19
|
+
//#region src/pluralizer/Pluralizer.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* @class Handles English word pluralization and singularization with support for irregular forms and uncountable nouns.
|
|
22
|
+
*
|
|
23
|
+
* - Provides methods to convert words between singular and plural forms, check if a word is plural or singular, and manage custom pluralization rules.
|
|
24
|
+
* - Supports adding custom pluralization and singularization rules, as well as uncountable nouns.
|
|
25
|
+
* - Automatically handles common irregular forms like "child" to "children"
|
|
26
|
+
* - Automatically loads common irregular forms and uncountable nouns.
|
|
27
|
+
* - Supports options for count-based pluralization, allowing for inclusive formatting.
|
|
28
|
+
* - 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.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* - For simpler pluralization (plural with only 's'), please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/formatUnitWithPlural formatUnitWithPlural} instead.
|
|
32
|
+
*
|
|
33
|
+
* - For ready to use instance, please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/pluralizer pluralizer} instead.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const pluralizer = new Pluralizer();
|
|
37
|
+
* pluralizer.pluralize('child'); // "children"
|
|
38
|
+
* pluralizer.toSingular('geese'); // "goose"
|
|
39
|
+
* pluralizer.isPlural('fish'); // false (uncountable)
|
|
40
|
+
*/
|
|
41
|
+
declare class Pluralizer {
|
|
42
|
+
#private;
|
|
43
|
+
/**
|
|
44
|
+
* Initializes the Pluralizer with default rules and exceptions.
|
|
45
|
+
* Automatically loads irregular, pluralization and singular rules along with pre-defined uncountable nouns.
|
|
46
|
+
*/
|
|
47
|
+
constructor();
|
|
48
|
+
/**
|
|
49
|
+
* * Add a new pluralization rule.
|
|
50
|
+
* @param rule Pattern to match singular words.
|
|
51
|
+
* @param replacement Replacement pattern for plural form.
|
|
52
|
+
* @example
|
|
53
|
+
* pluralizer.addPluralRule(/(quiz)$/i, '$1zes');
|
|
54
|
+
*/
|
|
55
|
+
addPluralRule(rule: RegExp, replacement: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* * Add a new singularization rule.
|
|
58
|
+
* @param rule Pattern to match plural words.
|
|
59
|
+
* @param replacement Replacement pattern for singular form.
|
|
60
|
+
* @example
|
|
61
|
+
* pluralizer.addSingularRule(/(matr)ices$/i, '$1ix');
|
|
62
|
+
*/
|
|
63
|
+
addSingularRule(rule: RegExp, replacement: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* * Add a word or pattern that should never change between singular and plural.
|
|
66
|
+
* @param word A word or regex pattern.
|
|
67
|
+
* @example
|
|
68
|
+
* pluralizer.addUncountable('fish');
|
|
69
|
+
* pluralizer.addUncountable(/pok[eé]mon$/i);
|
|
70
|
+
*/
|
|
71
|
+
addUncountable(word: string | RegExp): void;
|
|
72
|
+
/**
|
|
73
|
+
* * Add a custom irregular form.
|
|
74
|
+
* @param single Singular word.
|
|
75
|
+
* @param plural Plural word.
|
|
76
|
+
* @example
|
|
77
|
+
* pluralizer.addIrregular('person', 'people');
|
|
78
|
+
*/
|
|
79
|
+
addIrregular(single: string, plural: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* * Get the proper singular or plural form based on optional count.
|
|
82
|
+
* @param word Target word to pluralize or singularize.
|
|
83
|
+
* @param options Optional count and inclusive formatting.
|
|
84
|
+
* @returns The transformed word.
|
|
85
|
+
* @example
|
|
86
|
+
* pluralizer.pluralize('category', { count: 3 }); // "categories"
|
|
87
|
+
* pluralizer.pluralize('child', { count: 1, inclusive: true }); // "1 child"
|
|
88
|
+
*/
|
|
89
|
+
pluralize(word: string, options?: PluralizeOptions): string;
|
|
90
|
+
/**
|
|
91
|
+
* * Convert a word to its plural form.
|
|
92
|
+
* @param word Singular form of the word.
|
|
93
|
+
* @returns Plural form of the word.
|
|
94
|
+
* @example
|
|
95
|
+
* pluralizer.toPlural('analysis'); // "analyses"
|
|
96
|
+
*/
|
|
97
|
+
toPlural(word: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* * Convert a word to its singular form.
|
|
100
|
+
* @param word Plural form of the word.
|
|
101
|
+
* @returns Singular form of the word.
|
|
102
|
+
* @example
|
|
103
|
+
* pluralizer.toSingular('geese'); // "goose"
|
|
104
|
+
*/
|
|
105
|
+
toSingular(word: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* * Check if a given word is plural.
|
|
108
|
+
* @param word Word to check.
|
|
109
|
+
* @returns `true` if the word is plural, otherwise `false`.
|
|
110
|
+
* @remarks Always returns `true` for uncountable nouns.
|
|
111
|
+
* @example
|
|
112
|
+
* pluralizer.isPlural('children'); // true
|
|
113
|
+
* pluralizer.isPlural('water'); // true
|
|
114
|
+
*/
|
|
115
|
+
isPlural(word: string): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* * Check if a given word is singular.
|
|
118
|
+
* @param word Word to check.
|
|
119
|
+
* @returns True if the word is singular, otherwise false.
|
|
120
|
+
* @remarks Always returns `true` for uncountable nouns.
|
|
121
|
+
* @example
|
|
122
|
+
* pluralizer.isSingular('child'); // true
|
|
123
|
+
* pluralizer.isPlural('water'); // true
|
|
124
|
+
*/
|
|
125
|
+
isSingular(word: string): boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Default shared instance of {@link https://toolbox.nazmul-nhb.dev/docs/classes/Pluralizer Pluralizer}.
|
|
129
|
+
*
|
|
130
|
+
* - _Use this when you don’t need multiple configurations._
|
|
131
|
+
* - _It comes preloaded with standard pluralization rules, irregular forms, and uncountable nouns._
|
|
132
|
+
*
|
|
133
|
+
* @remarks For simpler pluralization (plural with only 's'), please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/formatUnitWithPlural formatUnitWithPlural} instead.
|
|
134
|
+
*
|
|
135
|
+
* * Handles English word pluralization and singularization with support for irregular forms and uncountable nouns.
|
|
136
|
+
*
|
|
137
|
+
* - Provides methods to convert words between singular and plural forms, check if a word is plural or singular, and manage custom pluralization rules.
|
|
138
|
+
* - Supports adding custom pluralization and singularization rules, as well as uncountable nouns.
|
|
139
|
+
* - Automatically handles common irregular forms like "child" to "children"
|
|
140
|
+
* - Automatically loads common irregular forms and uncountable nouns.
|
|
141
|
+
* - Supports options for count-based pluralization, allowing for inclusive formatting.
|
|
142
|
+
* - 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.
|
|
143
|
+
* @example
|
|
144
|
+
* import { pluralizer } from 'nhb-toolbox';
|
|
145
|
+
*
|
|
146
|
+
* pluralizer.pluralize('child'); // "children"
|
|
147
|
+
* pluralizer.toSingular('geese'); // "goose"
|
|
148
|
+
* pluralizer.isPlural('fish'); // false (uncountable)
|
|
149
|
+
*/
|
|
150
|
+
declare const pluralizer: Pluralizer;
|
|
151
|
+
//#endregion
|
|
152
|
+
export { Pluralizer, pluralizer };
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
import { n as PluralizeOptions } from "./pluralizer-BjMIc6uT.mjs";
|
|
18
|
+
|
|
19
|
+
//#region src/pluralizer/Pluralizer.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* @class Handles English word pluralization and singularization with support for irregular forms and uncountable nouns.
|
|
22
|
+
*
|
|
23
|
+
* - Provides methods to convert words between singular and plural forms, check if a word is plural or singular, and manage custom pluralization rules.
|
|
24
|
+
* - Supports adding custom pluralization and singularization rules, as well as uncountable nouns.
|
|
25
|
+
* - Automatically handles common irregular forms like "child" to "children"
|
|
26
|
+
* - Automatically loads common irregular forms and uncountable nouns.
|
|
27
|
+
* - Supports options for count-based pluralization, allowing for inclusive formatting.
|
|
28
|
+
* - 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.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* - For simpler pluralization (plural with only 's'), please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/formatUnitWithPlural formatUnitWithPlural} instead.
|
|
32
|
+
*
|
|
33
|
+
* - For ready to use instance, please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/pluralizer pluralizer} instead.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const pluralizer = new Pluralizer();
|
|
37
|
+
* pluralizer.pluralize('child'); // "children"
|
|
38
|
+
* pluralizer.toSingular('geese'); // "goose"
|
|
39
|
+
* pluralizer.isPlural('fish'); // false (uncountable)
|
|
40
|
+
*/
|
|
41
|
+
declare class Pluralizer {
|
|
42
|
+
#private;
|
|
43
|
+
/**
|
|
44
|
+
* Initializes the Pluralizer with default rules and exceptions.
|
|
45
|
+
* Automatically loads irregular, pluralization and singular rules along with pre-defined uncountable nouns.
|
|
46
|
+
*/
|
|
47
|
+
constructor();
|
|
48
|
+
/**
|
|
49
|
+
* * Add a new pluralization rule.
|
|
50
|
+
* @param rule Pattern to match singular words.
|
|
51
|
+
* @param replacement Replacement pattern for plural form.
|
|
52
|
+
* @example
|
|
53
|
+
* pluralizer.addPluralRule(/(quiz)$/i, '$1zes');
|
|
54
|
+
*/
|
|
55
|
+
addPluralRule(rule: RegExp, replacement: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* * Add a new singularization rule.
|
|
58
|
+
* @param rule Pattern to match plural words.
|
|
59
|
+
* @param replacement Replacement pattern for singular form.
|
|
60
|
+
* @example
|
|
61
|
+
* pluralizer.addSingularRule(/(matr)ices$/i, '$1ix');
|
|
62
|
+
*/
|
|
63
|
+
addSingularRule(rule: RegExp, replacement: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* * Add a word or pattern that should never change between singular and plural.
|
|
66
|
+
* @param word A word or regex pattern.
|
|
67
|
+
* @example
|
|
68
|
+
* pluralizer.addUncountable('fish');
|
|
69
|
+
* pluralizer.addUncountable(/pok[eé]mon$/i);
|
|
70
|
+
*/
|
|
71
|
+
addUncountable(word: string | RegExp): void;
|
|
72
|
+
/**
|
|
73
|
+
* * Add a custom irregular form.
|
|
74
|
+
* @param single Singular word.
|
|
75
|
+
* @param plural Plural word.
|
|
76
|
+
* @example
|
|
77
|
+
* pluralizer.addIrregular('person', 'people');
|
|
78
|
+
*/
|
|
79
|
+
addIrregular(single: string, plural: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* * Get the proper singular or plural form based on optional count.
|
|
82
|
+
* @param word Target word to pluralize or singularize.
|
|
83
|
+
* @param options Optional count and inclusive formatting.
|
|
84
|
+
* @returns The transformed word.
|
|
85
|
+
* @example
|
|
86
|
+
* pluralizer.pluralize('category', { count: 3 }); // "categories"
|
|
87
|
+
* pluralizer.pluralize('child', { count: 1, inclusive: true }); // "1 child"
|
|
88
|
+
*/
|
|
89
|
+
pluralize(word: string, options?: PluralizeOptions): string;
|
|
90
|
+
/**
|
|
91
|
+
* * Convert a word to its plural form.
|
|
92
|
+
* @param word Singular form of the word.
|
|
93
|
+
* @returns Plural form of the word.
|
|
94
|
+
* @example
|
|
95
|
+
* pluralizer.toPlural('analysis'); // "analyses"
|
|
96
|
+
*/
|
|
97
|
+
toPlural(word: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* * Convert a word to its singular form.
|
|
100
|
+
* @param word Plural form of the word.
|
|
101
|
+
* @returns Singular form of the word.
|
|
102
|
+
* @example
|
|
103
|
+
* pluralizer.toSingular('geese'); // "goose"
|
|
104
|
+
*/
|
|
105
|
+
toSingular(word: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* * Check if a given word is plural.
|
|
108
|
+
* @param word Word to check.
|
|
109
|
+
* @returns `true` if the word is plural, otherwise `false`.
|
|
110
|
+
* @remarks Always returns `true` for uncountable nouns.
|
|
111
|
+
* @example
|
|
112
|
+
* pluralizer.isPlural('children'); // true
|
|
113
|
+
* pluralizer.isPlural('water'); // true
|
|
114
|
+
*/
|
|
115
|
+
isPlural(word: string): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* * Check if a given word is singular.
|
|
118
|
+
* @param word Word to check.
|
|
119
|
+
* @returns True if the word is singular, otherwise false.
|
|
120
|
+
* @remarks Always returns `true` for uncountable nouns.
|
|
121
|
+
* @example
|
|
122
|
+
* pluralizer.isSingular('child'); // true
|
|
123
|
+
* pluralizer.isPlural('water'); // true
|
|
124
|
+
*/
|
|
125
|
+
isSingular(word: string): boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Default shared instance of {@link https://toolbox.nazmul-nhb.dev/docs/classes/Pluralizer Pluralizer}.
|
|
129
|
+
*
|
|
130
|
+
* - _Use this when you don’t need multiple configurations._
|
|
131
|
+
* - _It comes preloaded with standard pluralization rules, irregular forms, and uncountable nouns._
|
|
132
|
+
*
|
|
133
|
+
* @remarks For simpler pluralization (plural with only 's'), please refer to {@link https://toolbox.nazmul-nhb.dev/docs/utilities/string/formatUnitWithPlural formatUnitWithPlural} instead.
|
|
134
|
+
*
|
|
135
|
+
* * Handles English word pluralization and singularization with support for irregular forms and uncountable nouns.
|
|
136
|
+
*
|
|
137
|
+
* - Provides methods to convert words between singular and plural forms, check if a word is plural or singular, and manage custom pluralization rules.
|
|
138
|
+
* - Supports adding custom pluralization and singularization rules, as well as uncountable nouns.
|
|
139
|
+
* - Automatically handles common irregular forms like "child" to "children"
|
|
140
|
+
* - Automatically loads common irregular forms and uncountable nouns.
|
|
141
|
+
* - Supports options for count-based pluralization, allowing for inclusive formatting.
|
|
142
|
+
* - 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.
|
|
143
|
+
* @example
|
|
144
|
+
* import { pluralizer } from 'nhb-toolbox';
|
|
145
|
+
*
|
|
146
|
+
* pluralizer.pluralize('child'); // "children"
|
|
147
|
+
* pluralizer.toSingular('geese'); // "goose"
|
|
148
|
+
* pluralizer.isPlural('fish'); // false (uncountable)
|
|
149
|
+
*/
|
|
150
|
+
declare const pluralizer: Pluralizer;
|
|
151
|
+
//#endregion
|
|
152
|
+
export { Pluralizer, pluralizer };
|