@rzl-zone/utils-js 2.1.0 → 3.0.0-beta.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/dist/NumberRangeUnion-DC-C3_Kq.d.ts +26 -0
- package/dist/any-BmdI8UbK.d.ts +67 -0
- package/dist/array-CIZRbqTF.d.ts +223 -0
- package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +72 -0
- package/dist/assertions/index.cjs +1 -0
- package/dist/assertions/index.d.ts +428 -0
- package/dist/assertions/index.js +1 -0
- package/dist/chunk-2TRAPBZ7.cjs +1 -0
- package/dist/chunk-3D74QO5D.cjs +1 -0
- package/dist/chunk-4DK3RCC4.js +2 -0
- package/dist/chunk-4JOQ45HL.js +1 -0
- package/dist/chunk-55CZALRS.js +1 -0
- package/dist/chunk-56QBKKRE.js +1 -0
- package/dist/chunk-5JFV3GDE.cjs +4 -0
- package/dist/chunk-5SZUSNGZ.js +1 -0
- package/dist/chunk-62HX5Z45.cjs +1 -0
- package/dist/chunk-7NA6DUHR.cjs +2 -0
- package/dist/chunk-7YWAQOA4.cjs +1 -0
- package/dist/chunk-BVPMMWDL.cjs +1 -0
- package/dist/chunk-BYZAD3XN.cjs +1 -0
- package/dist/chunk-CEFYHEM4.cjs +1 -0
- package/dist/chunk-CN53M4QZ.cjs +1 -0
- package/dist/chunk-D47MHBSD.cjs +1 -0
- package/dist/chunk-DGH75GJD.js +1 -0
- package/dist/chunk-E5NUI7PN.js +1 -0
- package/dist/chunk-ELDDNERR.js +1 -0
- package/dist/chunk-EXZ47NOW.js +1 -0
- package/dist/chunk-FDITZ5C6.cjs +1 -0
- package/dist/chunk-FF76ISQ2.js +1 -0
- package/dist/chunk-FIEZKTAZ.cjs +1 -0
- package/dist/chunk-FSSV24W7.cjs +1 -0
- package/dist/chunk-G5LXIEFO.js +0 -0
- package/dist/chunk-GCGU2WB7.js +1 -0
- package/dist/chunk-GECI2YBP.js +1 -0
- package/dist/chunk-GQE4OVHC.cjs +1 -0
- package/dist/chunk-GRVZXQXL.cjs +1 -0
- package/dist/chunk-I4AVNHPA.cjs +1 -0
- package/dist/chunk-JFRL7NKU.js +4 -0
- package/dist/chunk-JWHM3WZQ.cjs +1 -0
- package/dist/chunk-KCQDDZJE.cjs +1 -0
- package/dist/chunk-L54ZPSYJ.js +1 -0
- package/dist/chunk-LVKAYEZ4.js +1 -0
- package/dist/chunk-MBDWTK54.cjs +1 -0
- package/dist/chunk-MMSYCIJ2.cjs +1 -0
- package/dist/chunk-MNGGDB2G.js +1 -0
- package/dist/chunk-MY7BA4GI.cjs +1 -0
- package/dist/chunk-N2IJPIND.cjs +1 -0
- package/dist/chunk-NIMNTEGV.js +1 -0
- package/dist/chunk-NNM7QCNB.js +1 -0
- package/dist/chunk-PUQXRLZH.cjs +1 -0
- package/dist/chunk-PVJF2JHM.js +1 -0
- package/dist/chunk-QCFXEUKL.js +1 -0
- package/dist/chunk-QFCGBBSY.js +1 -0
- package/dist/chunk-QQYAUPSK.cjs +1 -0
- package/dist/chunk-RN3TP3S3.js +1 -0
- package/dist/chunk-RV2VULM7.cjs +1 -0
- package/dist/chunk-SW6HYEW7.cjs +1 -0
- package/dist/chunk-SYJC7UAW.js +1 -0
- package/dist/chunk-TC4VBE4Y.cjs +1 -0
- package/dist/chunk-TUXDINHF.cjs +1 -0
- package/dist/chunk-U5Y2FXMN.cjs +1 -0
- package/dist/chunk-UUPQI6ND.cjs +1 -0
- package/dist/chunk-VYCGZ2S6.js +1 -0
- package/dist/chunk-W5EDKJK3.js +1 -0
- package/dist/chunk-WHAVUFEU.js +1 -0
- package/dist/chunk-XCFIOTCV.js +1 -0
- package/dist/chunk-XE27XPJR.js +1 -0
- package/dist/chunk-XH6MCRLP.js +1 -0
- package/dist/chunk-XVB3ZZEB.js +1 -0
- package/dist/chunk-ZBSIGJFO.cjs +1 -0
- package/dist/chunk-ZYAML74V.js +1 -0
- package/dist/conversions/index.cjs +1 -0
- package/dist/conversions/index.d.ts +1633 -0
- package/dist/conversions/index.js +1 -0
- package/dist/env/index.cjs +1 -0
- package/dist/env/index.d.ts +19 -0
- package/dist/env/index.js +1 -0
- package/dist/events/index.cjs +1 -0
- package/dist/events/index.d.ts +119 -0
- package/dist/events/index.js +1 -0
- package/dist/extends-Mp81Hq9-.d.ts +145 -0
- package/dist/formatting/index.cjs +1 -0
- package/dist/formatting/index.d.ts +912 -0
- package/dist/formatting/index.js +1 -0
- package/dist/generator/index.cjs +1 -0
- package/dist/generator/index.d.ts +163 -0
- package/dist/generator/index.js +1 -0
- package/dist/if-CvT4R7Kh.d.ts +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -4334
- package/dist/index.js +1 -1
- package/dist/is-array-Ckm_47hw.d.ts +1557 -0
- package/dist/isPlainObject-BKYaI6a8.d.ts +182 -0
- package/dist/never-BfayMBF9.d.ts +75 -0
- package/dist/next/index.cjs +8 -1
- package/dist/next/index.d.ts +169 -169
- package/dist/next/index.js +8 -1
- package/dist/next/server/index.cjs +2 -1
- package/dist/next/server/index.d.ts +37 -37
- package/dist/next/server/index.js +2 -1
- package/dist/nils-DMz3kU7M.d.ts +177 -0
- package/dist/omit-VvmIsZmX.d.ts +28 -0
- package/dist/operations/index.cjs +1 -0
- package/dist/operations/index.d.ts +182 -0
- package/dist/operations/index.js +1 -0
- package/dist/parsers/index.cjs +1 -0
- package/dist/parsers/index.d.ts +37 -0
- package/dist/parsers/index.js +1 -0
- package/dist/predicates/index.cjs +1 -0
- package/dist/predicates/index.d.ts +1839 -0
- package/dist/predicates/index.js +1 -0
- package/dist/prettify-C4xLcYOP.d.ts +353 -0
- package/dist/promise/index.cjs +1 -0
- package/dist/promise/index.d.ts +40 -0
- package/dist/promise/index.js +1 -0
- package/dist/rzl-utils.global.js +4 -1
- package/dist/strings/index.cjs +1 -0
- package/dist/strings/index.d.ts +816 -0
- package/dist/strings/index.js +1 -0
- package/dist/stylings/index.cjs +1 -0
- package/dist/stylings/index.d.ts +49 -0
- package/dist/stylings/index.js +1 -0
- package/dist/type-data-DDs-u2kq.d.ts +261 -0
- package/dist/types/index.d.ts +3589 -2090
- package/dist/urls/index.cjs +1 -0
- package/dist/urls/index.d.ts +418 -0
- package/dist/urls/index.js +1 -0
- package/package.json +147 -21
|
@@ -0,0 +1,816 @@
|
|
|
1
|
+
import{c as Nilable}from'../nils-DMz3kU7M.js';
|
|
2
|
+
/** ----------------------------------------------------------
|
|
3
|
+
* * Capitalizes the first letter of a string.
|
|
4
|
+
* * Optionally lowercases the rest and trims whitespace.
|
|
5
|
+
* ----------------------------------------------------------
|
|
6
|
+
*
|
|
7
|
+
* @param string - The string to be processed.
|
|
8
|
+
* @param options - Options to control behavior.
|
|
9
|
+
* @param options.lowerCaseNextRest - If true, lowercases the rest (next first letter) (default: true).
|
|
10
|
+
* @param options.trim - If true, trims the string before processing (default: false).
|
|
11
|
+
* @returns The processed string. Returns "" if input is null, undefined, or not a valid string.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* capitalizeFirst(" hello WORLD ") // " Hello world"
|
|
15
|
+
* capitalizeFirst(" hello WORLD ", { trim: true }) // "Hello world"
|
|
16
|
+
* capitalizeFirst("FOO", { lowerCaseNextRest: false }) // "FOO"
|
|
17
|
+
* capitalizeFirst(" foo BAR ", { trim: true, lowerCaseNextRest: false }) // "Foo BAR"
|
|
18
|
+
*/
|
|
19
|
+
declare const capitalizeFirst:(string?:string|null,options?:{
|
|
20
|
+
/**
|
|
21
|
+
* @description If true, the rest of the string will be converted to lowercase after capitalizing the first letter.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
lowerCaseNextRest?:boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @description If true, the string will trimmed.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
trim?:boolean;})=>string;
|
|
30
|
+
/** ----------------------------------------------------------
|
|
31
|
+
* * ***Capitalizes the first letter of each word in a string
|
|
32
|
+
* while converting the rest to lowercase.***
|
|
33
|
+
* ----------------------------------------------------------
|
|
34
|
+
*
|
|
35
|
+
* @param value - The input string to be processed. If `null` or `undefined`, returns an empty string.
|
|
36
|
+
* @param options - Optional settings to control the output:
|
|
37
|
+
* - `trim`: If `true`, removes leading and trailing spaces, defaultValue: `false`.
|
|
38
|
+
* - `collapseSpaces`: If `true`, collapses multiple spaces **between words** into a single space (while preserving leading/trailing spaces), defaultValue: `false`.
|
|
39
|
+
*
|
|
40
|
+
* @returns A new string where each word starts with an uppercase letter
|
|
41
|
+
* and the remaining letters are lowercase. If `value` is empty, `null`, or `undefined`,
|
|
42
|
+
* returns an empty string.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* capitalizeWords(" hello world ");
|
|
46
|
+
* // => " Hello World "
|
|
47
|
+
*
|
|
48
|
+
* capitalizeWords(" hello world ", { trim: true });
|
|
49
|
+
* // => "Hello World"
|
|
50
|
+
*
|
|
51
|
+
* capitalizeWords(" hello world ", { collapseSpaces: true });
|
|
52
|
+
* // => " Hello World "
|
|
53
|
+
*
|
|
54
|
+
* capitalizeWords(" hello world ", { trim: true, collapseSpaces: true });
|
|
55
|
+
* // => "Hello World"
|
|
56
|
+
*/
|
|
57
|
+
declare const capitalizeWords:(value?:string|null,options?:{
|
|
58
|
+
/** If `true`, removes leading and trailing spaces, default `false`. */
|
|
59
|
+
trim?:boolean;
|
|
60
|
+
/** If `true`, collapses multiple spaces **between words** into a single space (while preserving leading/trailing spaces), default `false`. */
|
|
61
|
+
collapseSpaces?:boolean;})=>string;
|
|
62
|
+
/** --------------------------------------------------
|
|
63
|
+
* * ***Represents a string input that may be:***
|
|
64
|
+
* - a single string,
|
|
65
|
+
* - an array of strings,
|
|
66
|
+
* - a readonly array of strings,
|
|
67
|
+
* - or `null` / `undefined`.
|
|
68
|
+
* --------------------------------------------------
|
|
69
|
+
*
|
|
70
|
+
* @template T A string or array of strings.
|
|
71
|
+
*/
|
|
72
|
+
type StringLike=Nilable<string|string[]|ReadonlyArray<string>>;
|
|
73
|
+
/** --------------------------------------------------
|
|
74
|
+
* * ***Represents a collection of strings, which can be:***
|
|
75
|
+
* - a single string,
|
|
76
|
+
* - an array of strings,
|
|
77
|
+
* - a readonly array of strings,
|
|
78
|
+
* - a `Set` of strings, or
|
|
79
|
+
* - a `ReadonlySet` of strings.
|
|
80
|
+
* --------------------------------------------------
|
|
81
|
+
*/
|
|
82
|
+
type StringCollection=string|string[]|ReadonlyArray<string>|Set<string>|ReadonlySet<string>;
|
|
83
|
+
/** ----------------------------------------------------------
|
|
84
|
+
* * ***Converts a string (or array of strings) into `camelCase`, with optionally leaving specific words unchanged.***
|
|
85
|
+
* ----------------------------------------------------------
|
|
86
|
+
*
|
|
87
|
+
* @description
|
|
88
|
+
* - Accepts a `string` or an array of `strings`:
|
|
89
|
+
* - If an array is provided, elements are trimmed, empty ones removed,
|
|
90
|
+
* then joined with `"-"` before conversion.
|
|
91
|
+
* - Splits the input by non-alphanumeric characters
|
|
92
|
+
* (spaces, punctuation, symbols, hyphens, underscores, emojis, etc.).
|
|
93
|
+
* - The first word is fully lowercase; subsequent words are capitalized.
|
|
94
|
+
* - Words listed in `ignoreWord` remain unchanged in the output.
|
|
95
|
+
* - `ignoreWord` is normalized (trimmed, delimiters removed); empty values ignored.
|
|
96
|
+
* - `ignoreWord` accepts:
|
|
97
|
+
* - a single string,
|
|
98
|
+
* - an array of strings, or
|
|
99
|
+
* - a `Set` of strings.
|
|
100
|
+
* - Multiple delimiters collapse into one; empty segments ignored.
|
|
101
|
+
* - Returns `""` if the input is `null`, `undefined`, or empty.
|
|
102
|
+
*
|
|
103
|
+
* @param {StringLike} input - The string or array to convert. Returns `""` if empty, `null`, or `undefined`.
|
|
104
|
+
* @param {StringCollection} [ignoreWord] - Optional word(s) to leave unchanged in the output.
|
|
105
|
+
* @returns {string} The camelCase formatted string.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* // Basic usage
|
|
109
|
+
* toCamelCase("hello world");
|
|
110
|
+
* // ➔ "helloWorld"
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* // Array input is joined before conversion
|
|
114
|
+
* toCamelCase(["Join", "Words", "Here"]);
|
|
115
|
+
* // ➔ "joinWordsHere"
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* // Supports mixed delimiters
|
|
119
|
+
* toCamelCase("convert_to-camel case");
|
|
120
|
+
* // ➔ "convertToCamelCase"
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* // Words in ignoreWord stay unchanged
|
|
124
|
+
* toCamelCase("this URL path will ignore", "URL");
|
|
125
|
+
* // ➔ "thisURLPathWillIgnore"
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* // Multiple ignored words
|
|
129
|
+
* toCamelCase("ignore API and URL", ["API", "URL"]);
|
|
130
|
+
* // ➔ "ignoreAPIAndURL"
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* // Set can also be used
|
|
134
|
+
* toCamelCase("ignore API and URL", new Set(["API", "URL"]));
|
|
135
|
+
* // ➔ "ignoreAPIAndURL"
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* // Null or empty input returns empty string
|
|
139
|
+
* toCamelCase(null);
|
|
140
|
+
* // ➔ ""
|
|
141
|
+
*/
|
|
142
|
+
declare const toCamelCase:(input:StringLike,ignoreWord?:StringCollection)=>string;
|
|
143
|
+
/** ----------------------------------------------------------
|
|
144
|
+
* * ***Converts a string (or array of strings) into `PascalCaseSpace`, with optionally leaving specific words unchanged.***
|
|
145
|
+
* ----------------------------------------------------------
|
|
146
|
+
*
|
|
147
|
+
* @description
|
|
148
|
+
* - Accepts a `string` or an array of `strings`:
|
|
149
|
+
* - If an array is provided, elements are trimmed, empty ones removed,
|
|
150
|
+
* then joined with `"-"` before conversion.
|
|
151
|
+
* - Splits the input by non-alphanumeric characters
|
|
152
|
+
* (spaces, punctuation, symbols, hyphens, underscores, emojis, etc.).
|
|
153
|
+
* - The first word is fully lowercase; subsequent words are capitalized.
|
|
154
|
+
* - Words listed in `ignoreWord` remain unchanged in the output.
|
|
155
|
+
* - `ignoreWord` is normalized (trimmed, delimiters removed); empty values ignored.
|
|
156
|
+
* - `ignoreWord` accepts:
|
|
157
|
+
* - a single string,
|
|
158
|
+
* - an array of strings, or
|
|
159
|
+
* - a `Set` of strings.
|
|
160
|
+
* - Multiple delimiters collapse into one; empty segments ignored.
|
|
161
|
+
* - Returns `""` if the input is `null`, `undefined`, or empty.
|
|
162
|
+
*
|
|
163
|
+
* @param {StringLike} input - The string or array to convert. Returns `""` if empty, `null`, or `undefined`.
|
|
164
|
+
* @param {StringCollection} [ignoreWord] - Optional word(s) to leave unchanged in the output.
|
|
165
|
+
* @returns {string} The PascalCaseSpace formatted string.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* // Basic usage
|
|
169
|
+
* toPascalCaseSpace("hello world");
|
|
170
|
+
* // ➔ "Hello World"
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* // Array input is joined before conversion
|
|
174
|
+
* toPascalCaseSpace(["Join", "Words", "Here"]);
|
|
175
|
+
* // ➔ "Join Words Here"
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* // Handles underscores and hyphens
|
|
179
|
+
* toPascalCaseSpace("convert_to-pascal case");
|
|
180
|
+
* // ➔ "Convert To Pascal Case Space"
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* // Trims extra delimiters
|
|
184
|
+
* toPascalCaseSpace("___hello--world__ again!!");
|
|
185
|
+
* // ➔ "Hello World Again"
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* // Supports emojis and symbols
|
|
189
|
+
* toPascalCaseSpace("🔥fire_and-ice❄️");
|
|
190
|
+
* // ➔ "Fire And Ice"
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* // Ignore single word
|
|
194
|
+
* toPascalCaseSpace("this URL path will ignore", "URL");
|
|
195
|
+
* // ➔ "This URL Path Will Ignore"
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* // Ignore multiple words
|
|
199
|
+
* toPascalCaseSpace("ignore API and URL", ["API", "URL"]);
|
|
200
|
+
* // ➔ "Ignore API And URL"
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* // Ignore using Set
|
|
204
|
+
* toPascalCaseSpace("ignore API and URL", new Set(["API", "URL"]));
|
|
205
|
+
* // ➔ "Ignore API And URL"
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* // Null or empty returns empty string
|
|
209
|
+
* toPascalCaseSpace(undefined);
|
|
210
|
+
* // ➔ ""
|
|
211
|
+
*/
|
|
212
|
+
declare const toPascalCaseSpace:(input:StringLike,ignoreWord?:StringCollection)=>string;
|
|
213
|
+
/** ----------------------------------------------------------
|
|
214
|
+
* * ***Converts a string (or array of strings) into `PascalCase`, with optionally leaving specific words unchanged.***
|
|
215
|
+
* ----------------------------------------------------------
|
|
216
|
+
*
|
|
217
|
+
* @description
|
|
218
|
+
* - Accepts a `string` or an array of `strings`:
|
|
219
|
+
* - If an array is provided, elements are trimmed, empty ones removed,
|
|
220
|
+
* then joined with `"-"` before conversion.
|
|
221
|
+
* - Splits the input by non-alphanumeric characters
|
|
222
|
+
* (spaces, punctuation, symbols, hyphens, underscores, emojis, etc.).
|
|
223
|
+
* - The first word is fully lowercase; subsequent words are capitalized.
|
|
224
|
+
* - Words listed in `ignoreWord` remain unchanged in the output.
|
|
225
|
+
* - `ignoreWord` is normalized (trimmed, delimiters removed); empty values ignored.
|
|
226
|
+
* - `ignoreWord` accepts:
|
|
227
|
+
* - a single string,
|
|
228
|
+
* - an array of strings, or
|
|
229
|
+
* - a `Set` of strings.
|
|
230
|
+
* - Multiple delimiters collapse into one; empty segments ignored.
|
|
231
|
+
* - Returns `""` if the input is `null`, `undefined`, or empty.
|
|
232
|
+
*
|
|
233
|
+
* @param {StringLike} input - The string or array to convert. Returns `""` if empty, `null`, or `undefined`.
|
|
234
|
+
* @param {StringCollection} [ignoreWord] - Optional word(s) to leave unchanged in the output.
|
|
235
|
+
* @returns {string} The PascalCase formatted string.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* // Basic usage
|
|
239
|
+
* toPascalCase("hello world");
|
|
240
|
+
* // ➔ "HelloWorld"
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* // Array input is joined before conversion
|
|
244
|
+
* toPascalCase(["Join", "Words", "Here"]);
|
|
245
|
+
* // ➔ "JoinWordsHere"
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* // Handles underscores and hyphens
|
|
249
|
+
* toPascalCase("convert_to-pascal case");
|
|
250
|
+
* // ➔ "ConvertToPascalCase"
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // Trims extra delimiters
|
|
254
|
+
* toPascalCase("___hello--world__ again!!");
|
|
255
|
+
* // ➔ "HelloWorldAgain"
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* // Supports emojis and symbols
|
|
259
|
+
* toPascalCase("🔥fire_and-ice❄️");
|
|
260
|
+
* // ➔ "FireAndIce"
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* // Ignore single word
|
|
264
|
+
* toPascalCase("this URL path will ignore", "URL");
|
|
265
|
+
* // ➔ "ThisURLPathWillIgnore"
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* // Ignore multiple words
|
|
269
|
+
* toPascalCase("ignore API and URL", ["API", "URL"]);
|
|
270
|
+
* // ➔ "IgnoreAPIAndURL"
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* // Ignore using Set
|
|
274
|
+
* toPascalCase("ignore API and URL", new Set(["API", "URL"]));
|
|
275
|
+
* // ➔ "IgnoreAPIAndURL"
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* // Null or empty returns empty string
|
|
279
|
+
* toPascalCase(undefined);
|
|
280
|
+
* // ➔ ""
|
|
281
|
+
*/
|
|
282
|
+
declare const toPascalCase:(input:StringLike,ignoreWord?:StringCollection)=>string;
|
|
283
|
+
/** ----------------------------------------------------------
|
|
284
|
+
* * ***Converts a string (or array of strings) into `LowerCase`, with optionally leaving specific words unchanged.***
|
|
285
|
+
* ----------------------------------------------------------
|
|
286
|
+
*
|
|
287
|
+
* @description
|
|
288
|
+
* - Accepts a `string` or an array of `strings`:
|
|
289
|
+
* - If an array is provided, elements are trimmed, empty ones removed,
|
|
290
|
+
* then joined with `"-"` before conversion.
|
|
291
|
+
* - Splits the input by non-alphanumeric characters
|
|
292
|
+
* (spaces, punctuation, symbols, hyphens, underscores, emojis, etc.).
|
|
293
|
+
* - The first word is fully lowercase; subsequent words are capitalized.
|
|
294
|
+
* - Words listed in `ignoreWord` remain unchanged in the output.
|
|
295
|
+
* - `ignoreWord` is normalized (trimmed, delimiters removed); empty values ignored.
|
|
296
|
+
* - `ignoreWord` accepts:
|
|
297
|
+
* - a single string,
|
|
298
|
+
* - an array of strings, or
|
|
299
|
+
* - a `Set` of strings.
|
|
300
|
+
* - Multiple delimiters collapse into one; empty segments ignored.
|
|
301
|
+
* - Returns `""` if the input is `null`, `undefined`, or empty.
|
|
302
|
+
*
|
|
303
|
+
* @param {StringLike} input - The string or array to convert. Returns `""` if empty, `null`, or `undefined`.
|
|
304
|
+
* @param {StringCollection} [ignoreWord] - Optional word(s) to leave unchanged in the output.
|
|
305
|
+
* @returns {string} The LowerCase formatted string.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* // Basic usage
|
|
309
|
+
* toLowerCase("Hello World");
|
|
310
|
+
* // ➔ "hello world"
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* // Array input is joined before conversion
|
|
314
|
+
* toLowerCase(["Join", "WORLD", "Here"]);
|
|
315
|
+
* // ➔ "join words here"
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* // Handles underscores and hyphens
|
|
319
|
+
* toLowerCase("convert_to-pascal case");
|
|
320
|
+
* // ➔ "convert to lower case"
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* // Trims extra delimiters
|
|
324
|
+
* toLowerCase("___hello--world__ again!!");
|
|
325
|
+
* // ➔ "hello world again"
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* // Supports emojis and symbols
|
|
329
|
+
* toLowerCase("🔥fire_and-ice❄️");
|
|
330
|
+
* // ➔ "fire and ice"
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* // Ignore single word
|
|
334
|
+
* toLowerCase("this URL path will ignore", "URL");
|
|
335
|
+
* // ➔ "this URL path will ignore"
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* // Ignore multiple words
|
|
339
|
+
* toLowerCase("ignore API and URL", ["API", "URL"]);
|
|
340
|
+
* // ➔ "ignore API and URL"
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* // Ignore using Set
|
|
344
|
+
* toLowerCase("ignore API and URL", new Set(["API", "URL"]));
|
|
345
|
+
* // ➔ "ignore API and URL"
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* // Null or empty returns empty string
|
|
349
|
+
* toLowerCase(undefined);
|
|
350
|
+
* // ➔ ""
|
|
351
|
+
*/
|
|
352
|
+
declare const toLowerCase:(input:StringLike,ignoreWord?:StringCollection)=>string;
|
|
353
|
+
/** ----------------------------------------------------------
|
|
354
|
+
* * ***Converts a string (or array of strings) into `kebab-case`, with optionally leaving specific words unchanged.***
|
|
355
|
+
* ----------------------------------------------------------
|
|
356
|
+
*
|
|
357
|
+
* @description
|
|
358
|
+
* - Accepts a `string` or an array of `strings`:
|
|
359
|
+
* - If an array is provided, elements are trimmed, empty ones removed,
|
|
360
|
+
* then joined with `"-"` before conversion.
|
|
361
|
+
* - Splits the input by non-alphanumeric characters
|
|
362
|
+
* (spaces, punctuation, symbols, hyphens, underscores, emojis, etc.).
|
|
363
|
+
* - The first word is fully lowercase; subsequent words are capitalized.
|
|
364
|
+
* - Words listed in `ignoreWord` remain unchanged in the output.
|
|
365
|
+
* - `ignoreWord` is normalized (trimmed, delimiters removed); empty values ignored.
|
|
366
|
+
* - `ignoreWord` accepts:
|
|
367
|
+
* - a single string,
|
|
368
|
+
* - an array of strings, or
|
|
369
|
+
* - a `Set` of strings.
|
|
370
|
+
* - Multiple delimiters collapse into one; empty segments ignored.
|
|
371
|
+
* - Returns `""` if the input is `null`, `undefined`, or empty.
|
|
372
|
+
*
|
|
373
|
+
* @param {StringLike} input - The string or array to convert. Returns `""` if empty, `null`, or `undefined`.
|
|
374
|
+
* @param {StringCollection} [ignoreWord] - Optional word(s) to leave unchanged in the output.
|
|
375
|
+
* @returns {string} The kebab-case formatted string.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* // Basic usage
|
|
379
|
+
* toKebabCase("Hello World");
|
|
380
|
+
* // ➔ "hello-world"
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* // Array input is joined before conversion
|
|
384
|
+
* toKebabCase(["Join", "Words", "Here"]);
|
|
385
|
+
* // ➔ "join-words-here"
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* // Handles underscores and hyphens
|
|
389
|
+
* toKebabCase("convert_to-kebab case");
|
|
390
|
+
* // ➔ "convert-to-kebab-case"
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* // Handles emojis and symbols
|
|
394
|
+
* toKebabCase("🔥fire___and--ice❄️");
|
|
395
|
+
* // ➔ "fire-and-ice"
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* // Ignore specific word
|
|
399
|
+
* toKebabCase("ignore URL case", "URL");
|
|
400
|
+
* // ➔ "ignore-URL-case"
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* // Ignore multiple words
|
|
404
|
+
* toKebabCase("ignore API and URL", ["API", "URL"]);
|
|
405
|
+
* // ➔ "ignore-API-and-URL"
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* // Ignore with Set
|
|
409
|
+
* toKebabCase("ignore API and URL", new Set(["API", "URL"]));
|
|
410
|
+
* // ➔ "ignore-API-and-URL"
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* // Null or empty input
|
|
414
|
+
* toKebabCase(null);
|
|
415
|
+
* // ➔ ""
|
|
416
|
+
*/
|
|
417
|
+
declare const toKebabCase:(input:StringLike,ignoreWord?:StringCollection)=>string;
|
|
418
|
+
/** ----------------------------------------------------------
|
|
419
|
+
* * ***Converts a string (or array of strings) into `snake_case`, with optionally leaving specific words unchanged.***
|
|
420
|
+
* ----------------------------------------------------------
|
|
421
|
+
*
|
|
422
|
+
* @description
|
|
423
|
+
* - Accepts a `string` or an array of `strings`:
|
|
424
|
+
* - If an array is provided, elements are trimmed, empty ones removed,
|
|
425
|
+
* then joined with `"-"` before conversion.
|
|
426
|
+
* - Splits the input by non-alphanumeric characters
|
|
427
|
+
* (spaces, punctuation, symbols, hyphens, underscores, emojis, etc.).
|
|
428
|
+
* - The first word is fully lowercase; subsequent words are capitalized.
|
|
429
|
+
* - Words listed in `ignoreWord` remain unchanged in the output.
|
|
430
|
+
* - `ignoreWord` is normalized (trimmed, delimiters removed); empty values ignored.
|
|
431
|
+
* - `ignoreWord` accepts:
|
|
432
|
+
* - a single string,
|
|
433
|
+
* - an array of strings, or
|
|
434
|
+
* - a `Set` of strings.
|
|
435
|
+
* - Multiple delimiters collapse into one; empty segments ignored.
|
|
436
|
+
* - Returns `""` if the input is `null`, `undefined`, or empty.
|
|
437
|
+
*
|
|
438
|
+
* @param {StringLike} input - The string or array to convert. Returns `""` if empty, `null`, or `undefined`.
|
|
439
|
+
* @param {StringCollection} [ignoreWord] - Optional word(s) to leave unchanged in the output.
|
|
440
|
+
* @returns {string} The snake_case formatted string.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* // Basic usage
|
|
444
|
+
* toSnakeCase("Hello World");
|
|
445
|
+
* // ➔ "hello_world"
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* // Array input is joined before conversion
|
|
449
|
+
* toSnakeCase(["Join", "Words", "Here"]);
|
|
450
|
+
* // ➔ "join_words_here"
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* // Handles underscores, hyphens, spaces
|
|
454
|
+
* toSnakeCase("convert-to_snake case");
|
|
455
|
+
* // ➔ "convert_to_snake_case"
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* // Handles emojis and symbols
|
|
459
|
+
* toSnakeCase("🔥fire___and--ice❄️");
|
|
460
|
+
* // ➔ "fire_and_ice"
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* // Ignore specific word
|
|
464
|
+
* toSnakeCase("ignore URL case", "URL");
|
|
465
|
+
* // ➔ "ignore_URL_case"
|
|
466
|
+
*
|
|
467
|
+
* @example
|
|
468
|
+
* // Ignore multiple words
|
|
469
|
+
* toSnakeCase("ignore API and URL", ["API", "URL"]);
|
|
470
|
+
* // ➔ "ignore_API_and_URL"
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* // Ignore with Set
|
|
474
|
+
* toSnakeCase("ignore API and URL", new Set(["API", "URL"]));
|
|
475
|
+
* // ➔ "ignore_API_and_URL"
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* // Null or empty input
|
|
479
|
+
* toSnakeCase(null);
|
|
480
|
+
* // ➔ ""
|
|
481
|
+
*/
|
|
482
|
+
declare const toSnakeCase:(input:StringLike,ignoreWord?:StringCollection)=>string;
|
|
483
|
+
/** ----------------------------------------------------------
|
|
484
|
+
* * ***Converts a string (or array of strings) into `dot.case`, with optionally leaving specific words unchanged.***
|
|
485
|
+
* ----------------------------------------------------------
|
|
486
|
+
*
|
|
487
|
+
* @description
|
|
488
|
+
* - Accepts a `string` or an array of `strings`:
|
|
489
|
+
* - If an array is provided, elements are trimmed, empty ones removed,
|
|
490
|
+
* then joined with `"-"` before conversion.
|
|
491
|
+
* - Splits the input by non-alphanumeric characters
|
|
492
|
+
* (spaces, punctuation, symbols, hyphens, underscores, emojis, etc.).
|
|
493
|
+
* - The first word is fully lowercase; subsequent words are capitalized.
|
|
494
|
+
* - Words listed in `ignoreWord` remain unchanged in the output.
|
|
495
|
+
* - `ignoreWord` is normalized (trimmed, delimiters removed); empty values ignored.
|
|
496
|
+
* - `ignoreWord` accepts:
|
|
497
|
+
* - a single string,
|
|
498
|
+
* - an array of strings, or
|
|
499
|
+
* - a `Set` of strings.
|
|
500
|
+
* - Multiple delimiters collapse into one; empty segments ignored.
|
|
501
|
+
* - Returns `""` if the input is `null`, `undefined`, or empty.
|
|
502
|
+
*
|
|
503
|
+
* @param {StringLike} input - The string or array to convert. Returns `""` if empty, `null`, or `undefined`.
|
|
504
|
+
* @param {StringCollection} [ignoreWord] - Optional word(s) to leave unchanged in the output.
|
|
505
|
+
* @returns {string} The dot.case formatted string.
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* // Basic usage
|
|
509
|
+
* toDotCase("Hello World");
|
|
510
|
+
* // ➔ "hello.world"
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* // Array input is joined before conversion
|
|
514
|
+
* toDotCase(["Join", "Words", "Here"]);
|
|
515
|
+
* // ➔ "join.words.here"
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* // Handles underscores and hyphens
|
|
519
|
+
* toDotCase("convert-to_dot case");
|
|
520
|
+
* // ➔ "convert.to.dot.case"
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* // Multiple delimiters and trimming
|
|
524
|
+
* toDotCase("___Hello--World__ again!!");
|
|
525
|
+
* // ➔ "hello.world.again"
|
|
526
|
+
*
|
|
527
|
+
* @example
|
|
528
|
+
* // Supports emojis and symbols
|
|
529
|
+
* toDotCase("🔥Fire_and-ice❄️");
|
|
530
|
+
* // ➔ "fire.and.ice"
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* // Ignore single word
|
|
534
|
+
* toDotCase("this URL path", "URL");
|
|
535
|
+
* // ➔ "this.URL.path"
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* // Ignore multiple words
|
|
539
|
+
* toDotCase("ignore API and URL", ["API", "URL"]);
|
|
540
|
+
* // ➔ "ignore.API.and.URL"
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* // Ignore using Set
|
|
544
|
+
* toDotCase("ignore API and URL", new Set(["API", "URL"]));
|
|
545
|
+
* // ➔ "ignore.API.and.URL"
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* // Null or empty returns empty string
|
|
549
|
+
* toDotCase(undefined);
|
|
550
|
+
* // ➔ ""
|
|
551
|
+
*/
|
|
552
|
+
declare const toDotCase:(input:StringLike,ignoreWord?:StringCollection)=>string;
|
|
553
|
+
/** ----------------------------------------------------------
|
|
554
|
+
* * ***Slugifies a string (or array of strings) for safe use in URLs, with optionally leaving specific words unchanged.***
|
|
555
|
+
* ----------------------------------------------------------
|
|
556
|
+
*
|
|
557
|
+
* @description
|
|
558
|
+
* - Accepts a `string` or an array of `strings`:
|
|
559
|
+
* - If an array is provided, elements are trimmed, empty ones removed,
|
|
560
|
+
* then joined with `"-"` before conversion.
|
|
561
|
+
* - Splits the input by non-alphanumeric characters
|
|
562
|
+
* (spaces, punctuation, symbols, hyphens, underscores, emojis, etc.).
|
|
563
|
+
* - The first word is fully lowercase; subsequent words are capitalized.
|
|
564
|
+
* - Words listed in `ignoreWord` remain unchanged in the output.
|
|
565
|
+
* - `ignoreWord` is normalized (trimmed, delimiters removed); empty values ignored.
|
|
566
|
+
* - `ignoreWord` accepts:
|
|
567
|
+
* - a single string,
|
|
568
|
+
* - an array of strings, or
|
|
569
|
+
* - a `Set` of strings.
|
|
570
|
+
* - Multiple delimiters collapse into one; empty segments ignored.
|
|
571
|
+
* - Returns `""` if the input is `null`, `undefined`, or empty.
|
|
572
|
+
*
|
|
573
|
+
* @param {StringLike} input - The string or array to convert. Returns `""` if empty, `null`, or `undefined`.
|
|
574
|
+
* @param {StringCollection} [ignoreWord] - Optional word(s) to leave unchanged in the output.
|
|
575
|
+
* @returns {string} The slugified string.
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* // Basic usage
|
|
579
|
+
* slugify("Hello World!");
|
|
580
|
+
* // ➔ "hello-world"
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* // Array input is joined before conversion
|
|
584
|
+
* slugify(["Join", "Words", "Here"]);
|
|
585
|
+
* // ➔ "join-words-here"
|
|
586
|
+
*
|
|
587
|
+
* @example
|
|
588
|
+
* // Trims and cleans input
|
|
589
|
+
* slugify(" --- Convert to Slug? --- ");
|
|
590
|
+
* // ➔ "convert-to-slug"
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
* // Ignore single word
|
|
594
|
+
* slugify("This URL path", "URL");
|
|
595
|
+
* // ➔ "this-URL-path"
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* // Ignore multiple words
|
|
599
|
+
* slugify("ignore API and URL", ["API", "URL"]);
|
|
600
|
+
* // ➔ "ignore-API-and-URL"
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* // Ignore using Set
|
|
604
|
+
* slugify("ignore API and URL", new Set(["API", "URL"]));
|
|
605
|
+
* // ➔ "ignore-API-and-URL"
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* // Supports emojis and symbols
|
|
609
|
+
* slugify("🔥 Fire_and_ice ❄️");
|
|
610
|
+
* // ➔ "fire-and-ice"
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* // Null or empty returns empty string
|
|
614
|
+
* slugify(undefined);
|
|
615
|
+
* // ➔ ""
|
|
616
|
+
*/
|
|
617
|
+
declare const slugify:(input:StringLike,ignoreWord?:StringCollection)=>string;
|
|
618
|
+
/** ----------------------------------------------------------
|
|
619
|
+
* * ***Normalizes whitespace in a string by reducing multiple spaces
|
|
620
|
+
* to a single space, optionally trims, or only trims based on options.***
|
|
621
|
+
* ----------------------------------------------------------
|
|
622
|
+
*
|
|
623
|
+
* - ✅ Collapses all consecutive whitespace (spaces, tabs, newlines) into a single space.
|
|
624
|
+
* - ✅ Can trim leading/trailing spaces (default behavior), or preserve them with `withTrim: false`.
|
|
625
|
+
* - ✅ Can skip normalization entirely and only trim using `trimOnly: true`.
|
|
626
|
+
* - ✅ Returns an empty string if input is `null` or `undefined`.
|
|
627
|
+
*
|
|
628
|
+
* @param {string} [value] - The input string to be processed. If `null` or `undefined`, returns an empty string.
|
|
629
|
+
* @param {object} [options] - Configuration options.
|
|
630
|
+
* @param {boolean} [options.trimOnly=false] - If `true`, skips normalization and only trims the string.
|
|
631
|
+
* @param {boolean} [options.withTrim=true] - If `false`, preserves leading/trailing whitespace.
|
|
632
|
+
*
|
|
633
|
+
* @returns {string} The processed string.
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* normalizeSpaces(" Hello World\tthis is\n\nok ");
|
|
637
|
+
* // ➔ "Hello World this is ok"
|
|
638
|
+
*
|
|
639
|
+
* normalizeSpaces(" Hello World\tthis is\n\nok ", { trimOnly: true });
|
|
640
|
+
* // ➔ "Hello World this is\n\nok"
|
|
641
|
+
*
|
|
642
|
+
* normalizeSpaces(" Hello World ", { withTrim: false });
|
|
643
|
+
* // ➔ " Hello World "
|
|
644
|
+
*
|
|
645
|
+
* normalizeSpaces(null);
|
|
646
|
+
* // ➔ ""
|
|
647
|
+
*/
|
|
648
|
+
declare const normalizeSpaces:(value?:string|null,options?:{
|
|
649
|
+
/**
|
|
650
|
+
* If `true`, skips normalization and only trims whitespace from start & end.
|
|
651
|
+
* @default false */
|
|
652
|
+
trimOnly?:boolean;
|
|
653
|
+
/**
|
|
654
|
+
* If `false`, skips trimming value.
|
|
655
|
+
* @default true */
|
|
656
|
+
withTrim?:boolean;})=>string;
|
|
657
|
+
/** ----------------------------------------------------------
|
|
658
|
+
* * ***Normalizes a string by ensuring it is a valid string and trimming whitespace.***
|
|
659
|
+
* ----------------------------------------------------------
|
|
660
|
+
*
|
|
661
|
+
* @description
|
|
662
|
+
* If the input is `undefined`, `null`, or an `empty string` after trimming,
|
|
663
|
+
* it returns an empty string `("")`.
|
|
664
|
+
*
|
|
665
|
+
* @param {string | undefined | null} input - The input string to be normalize. If `null` or `undefined`, returns an empty string.
|
|
666
|
+
* @returns {string} A trimmed string or an empty string if the input is invalid.
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* normalizeString(" Hello World ");
|
|
670
|
+
* // ➔ "Hello World"
|
|
671
|
+
* normalizeString(" Hello World ");
|
|
672
|
+
* // ➔ "Hello World"
|
|
673
|
+
* normalizeString("");
|
|
674
|
+
* // ➔ ""
|
|
675
|
+
* normalizeString(null);
|
|
676
|
+
* // ➔ ""
|
|
677
|
+
* normalizeString(undefined);
|
|
678
|
+
* // ➔ ""
|
|
679
|
+
*/
|
|
680
|
+
declare const normalizeString:(input?:string|null)=>string;
|
|
681
|
+
/** ----------------------------------------------------------
|
|
682
|
+
* * ***Removes all spaces from a string or trims only, based on the options provided.***
|
|
683
|
+
* ----------------------------------------------------------
|
|
684
|
+
*
|
|
685
|
+
* @description
|
|
686
|
+
* - If `trimOnly` is `true`, the string is simply trimmed.
|
|
687
|
+
* - Otherwise, removes **all spaces**, tabs, newlines, etc.
|
|
688
|
+
* - If the input is `null` or `undefined`, returns an empty string `("")`.
|
|
689
|
+
*
|
|
690
|
+
* @param {string | null | undefined} value - The input string to be processed. If `null` or `undefined`, returns an empty string.
|
|
691
|
+
* @param {object} [options] - The options object.
|
|
692
|
+
* @param {boolean} [options.trimOnly=false] - If `true`, only trims the string without removing spaces inside.
|
|
693
|
+
* @returns {string} The processed string.
|
|
694
|
+
*
|
|
695
|
+
* @example
|
|
696
|
+
* removeSpaces(" Hello World ");
|
|
697
|
+
* // ➔ "HelloWorld"
|
|
698
|
+
*
|
|
699
|
+
* removeSpaces(" Hello World ", { trimOnly: true });
|
|
700
|
+
* // ➔ "Hello World"
|
|
701
|
+
*
|
|
702
|
+
* removeSpaces(null);
|
|
703
|
+
* // ➔ ""
|
|
704
|
+
*/
|
|
705
|
+
declare const removeSpaces:(value?:string|null,options?:{
|
|
706
|
+
/**
|
|
707
|
+
* @description If true, only trims the string.
|
|
708
|
+
*
|
|
709
|
+
* @default false */
|
|
710
|
+
trimOnly?:boolean;})=>string;
|
|
711
|
+
/** ----------------------------------------------------------
|
|
712
|
+
* * ***Removes all HTML tags from a given string.***
|
|
713
|
+
* ----------------------------------------------------------
|
|
714
|
+
*
|
|
715
|
+
* This function removes valid HTML tags (including nested and self-closing ones)
|
|
716
|
+
* by replacing them with spaces, then collapses multiple whitespaces into a single space.
|
|
717
|
+
*
|
|
718
|
+
* It handles the following cases:
|
|
719
|
+
* - If the input is not a string (`null`, `undefined`, or any non-string), it is returned as undefined.
|
|
720
|
+
* - If the input is an empty or whitespace-only string, it returns an empty string (`""`).
|
|
721
|
+
* - Otherwise, it returns the cleaned string with tags removed and normalized whitespace.
|
|
722
|
+
*
|
|
723
|
+
* @template T - Input string type (string | null | undefined).
|
|
724
|
+
* @param {T} [input] - A string potentially containing HTML tags.
|
|
725
|
+
* @returns {T extends string ? string : T} - Cleaned string if input is string, or original input otherwise.
|
|
726
|
+
*
|
|
727
|
+
* @example
|
|
728
|
+
* stripHtmlTags("<p>Hello</p>");
|
|
729
|
+
* // ➔ "Hello"
|
|
730
|
+
* stripHtmlTags("<div><b>Bold</b> text</div>");
|
|
731
|
+
* // ➔ "Bold text"
|
|
732
|
+
* stripHtmlTags("Line<br/>Break");
|
|
733
|
+
* // ➔ "Line Break"
|
|
734
|
+
* stripHtmlTags("2 < 5 and 5 > 2");
|
|
735
|
+
* // ➔ "2 < 5 and 5 > 2"
|
|
736
|
+
* stripHtmlTags("");
|
|
737
|
+
* // ➔ ""
|
|
738
|
+
* stripHtmlTags(" ");
|
|
739
|
+
* // ➔ ""
|
|
740
|
+
* stripHtmlTags(null);
|
|
741
|
+
* // ➔ undefined
|
|
742
|
+
* stripHtmlTags(undefined);
|
|
743
|
+
* // ➔ undefined
|
|
744
|
+
*/
|
|
745
|
+
declare const stripHtmlTags:<T extends string|null|undefined=undefined>(input?:T)=>T extends string?string:undefined;
|
|
746
|
+
/** ----------------------------------------------------------
|
|
747
|
+
* * ***Replaces a substring at a specified index within a string.***
|
|
748
|
+
* ----------------------------------------------------------
|
|
749
|
+
*
|
|
750
|
+
* @description
|
|
751
|
+
* Replaces exactly one character at the specified index in the original string
|
|
752
|
+
* with the provided `replaceTo` string. If `replaceTo` has more than one character,
|
|
753
|
+
* the result will expand accordingly.
|
|
754
|
+
*
|
|
755
|
+
* @param {number} index - The starting index where the replacement should occur.
|
|
756
|
+
* @param {string} originalString - The original string to modify.
|
|
757
|
+
* @param {string} replaceTo - The string to insert at the specified index.
|
|
758
|
+
* @returns {string} - The modified string with the replacement applied.
|
|
759
|
+
*
|
|
760
|
+
* @example
|
|
761
|
+
* replaceAt(3, "hello", "X");
|
|
762
|
+
* // ➔ "helXo"
|
|
763
|
+
*
|
|
764
|
+
* replaceAt(1, "world", "AB");
|
|
765
|
+
* // ➔ "wABrld"
|
|
766
|
+
*
|
|
767
|
+
* replaceAt(0, "cat", "br");
|
|
768
|
+
* // ➔ "brat"
|
|
769
|
+
*
|
|
770
|
+
* replaceAt(2, "12345", "-");
|
|
771
|
+
* // ➔ "12-45"
|
|
772
|
+
*
|
|
773
|
+
* replaceAt(4, "ABCDE", "Z");
|
|
774
|
+
* // ➔ "ABCDZ"
|
|
775
|
+
*
|
|
776
|
+
* // ❌ Examples that throw:
|
|
777
|
+
* replaceAt(10, "short", "X");
|
|
778
|
+
* // ➔ ❌ RangeError: Index parameter is out of range at function `replaceAt`
|
|
779
|
+
*
|
|
780
|
+
* replaceAt(-1, "test", "X");
|
|
781
|
+
* // ➔ ❌ RangeError: Index parameter is out of range at function `replaceAt`
|
|
782
|
+
*
|
|
783
|
+
* replaceAt("1", "test", "X");
|
|
784
|
+
* // ➔ ❌ TypeError: Expected 'index' to be a number, and 'replaceTo' and 'originalString' to be strings
|
|
785
|
+
*
|
|
786
|
+
* replaceAt(2, null, "X");
|
|
787
|
+
* // ➔ ❌ TypeError: Expected 'index' to be a number, and 'replaceTo' and 'originalString' to be strings
|
|
788
|
+
*/
|
|
789
|
+
declare const replaceAt:(index:number,originalString:string,replaceTo:string)=>string;
|
|
790
|
+
/** ----------------------------------------------------------
|
|
791
|
+
* * ***Extracts initials from a given name.***
|
|
792
|
+
* ----------------------------------------------------------
|
|
793
|
+
*
|
|
794
|
+
* @description
|
|
795
|
+
* Extracts initials from the given name string.
|
|
796
|
+
* - For names with two or more words, returns the first letter of the first and second words.
|
|
797
|
+
* - For a single word with 2+ characters, returns the first two letters.
|
|
798
|
+
* - For a single character, returns that character.
|
|
799
|
+
* - For empty, null, or whitespace-only input, returns an empty string.
|
|
800
|
+
*
|
|
801
|
+
* @param {string} [name=""] - The name to extract initials from.
|
|
802
|
+
* @returns {string} The extracted initials (e.g., "JD" for "John Doe").
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* getInitialsName("Alice"); // ➔ "AL"
|
|
806
|
+
* getInitialsName("John Doe"); // ➔ "JD"
|
|
807
|
+
* getInitialsName(" Bob Marley "); // ➔ "BM"
|
|
808
|
+
* getInitialsName("John Ronald Donal"); // ➔ "JR"
|
|
809
|
+
* getInitialsName("Lord John Doe Moe"); // ➔ "LJ"
|
|
810
|
+
* getInitialsName("X"); // ➔ "X"
|
|
811
|
+
* getInitialsName(" "); // ➔ "" (empty string)
|
|
812
|
+
* getInitialsName(""); // ➔ "" (empty string)
|
|
813
|
+
* getInitialsName(null); // ➔ "" (null input)
|
|
814
|
+
* getInitialsName(undefined); // ➔ "" (undefined input)
|
|
815
|
+
*/
|
|
816
|
+
declare const getInitialsName:(name?:string|null)=>string;export{capitalizeFirst,capitalizeWords,getInitialsName,normalizeSpaces,normalizeString,removeSpaces,replaceAt,slugify,stripHtmlTags,toCamelCase,toDotCase,toKebabCase,toLowerCase,toPascalCase,toPascalCaseSpace,toSnakeCase};
|