@rzl-zone/utils-js 3.0.2-beta.2 → 3.1.1-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 +23 -23
- package/dist/any-BmdI8UbK.d.ts +56 -56
- package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +66 -66
- package/dist/assertions/index.cjs +1 -1
- package/dist/assertions/index.d.ts +398 -418
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-26W3VZIK.cjs +1 -0
- package/dist/chunk-2KRCHXFG.cjs +2 -0
- package/dist/chunk-33ZLH266.js +1 -0
- package/dist/{chunk-EXZ47NOW.js → chunk-4L4EJTNZ.js} +1 -1
- package/dist/chunk-5Q37AP7P.js +1 -0
- package/dist/chunk-7CHFAMS2.js +1 -0
- package/dist/chunk-7MMJZ6HS.js +1 -0
- package/dist/chunk-7TC6DE3J.cjs +1 -0
- package/dist/{chunk-XH6MCRLP.js → chunk-7VX33E3V.js} +1 -1
- package/dist/chunk-BEZPD44N.cjs +1 -0
- package/dist/chunk-BI263OHW.js +1 -0
- package/dist/chunk-CII6WWLO.cjs +1 -0
- package/dist/chunk-D5TYPCWU.cjs +1 -0
- package/dist/chunk-EEQY5QUG.js +1 -0
- package/dist/chunk-ESJYBIYH.js +1 -0
- package/dist/chunk-EWYPSKKM.js +1 -0
- package/dist/chunk-EXCOQLWX.cjs +1 -0
- package/dist/chunk-FWQVTMYA.cjs +1 -0
- package/dist/chunk-G4EWCRKS.js +1 -0
- package/dist/chunk-G7R5XZRM.cjs +1 -0
- package/dist/chunk-GGEV7LXX.cjs +1 -0
- package/dist/chunk-HJOZOENU.cjs +1 -0
- package/dist/{chunk-BYZAD3XN.cjs → chunk-IRDZVLNZ.cjs} +1 -1
- package/dist/chunk-IW73G523.cjs +1 -0
- package/dist/chunk-IY5OZAB3.cjs +1 -0
- package/dist/chunk-J4NCYYGS.js +1 -0
- package/dist/chunk-J7JAZAJD.js +1 -0
- package/dist/{chunk-FF76ISQ2.js → chunk-JYNSO7ZY.js} +1 -1
- package/dist/chunk-K3UVKYEU.js +1 -0
- package/dist/chunk-LQ76EDZG.js +1 -0
- package/dist/chunk-MROH35V3.cjs +1 -0
- package/dist/chunk-NJSAV73S.js +1 -0
- package/dist/chunk-NR44SNYE.js +1 -0
- package/dist/chunk-NXMTWY77.js +1 -0
- package/dist/chunk-OZCQZO2V.cjs +4 -0
- package/dist/chunk-Q3NTKN5I.cjs +1 -0
- package/dist/chunk-QDNSC57Z.js +4 -0
- package/dist/chunk-QGXTL5ZH.js +2 -0
- package/dist/{chunk-JWHM3WZQ.cjs → chunk-QSQDP7L2.cjs} +1 -1
- package/dist/{chunk-RN3TP3S3.js → chunk-S5M33A4O.js} +1 -1
- package/dist/chunk-SGTHOQQ2.js +1 -0
- package/dist/chunk-SL3RQOWA.js +1 -0
- package/dist/chunk-SZPWZZYG.cjs +1 -0
- package/dist/chunk-UA4B7JBO.cjs +1 -0
- package/dist/chunk-UQDJF5RR.cjs +1 -0
- package/dist/chunk-UTQUYABU.cjs +1 -0
- package/dist/chunk-VPW3DRV5.js +1 -0
- package/dist/chunk-W32WALNU.js +1 -0
- package/dist/chunk-XGZ6K753.cjs +1 -0
- package/dist/chunk-YFTR64N5.cjs +1 -0
- package/dist/chunk-ZFDS7W6B.cjs +1 -0
- package/dist/chunk-ZQOLZE6Z.cjs +1 -0
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +1307 -1504
- package/dist/conversions/index.js +1 -1
- package/dist/env/index.d.ts +14 -17
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +111 -108
- package/dist/events/index.js +1 -1
- package/dist/extends-Bk_SBGdT.d.ts +367 -0
- package/dist/formatting/index.cjs +1 -1
- package/dist/formatting/index.d.ts +878 -840
- package/dist/formatting/index.js +1 -1
- package/dist/generator/index.cjs +1 -1
- package/dist/generator/index.d.ts +173 -150
- package/dist/generator/index.js +1 -1
- package/dist/if-CvT4R7Kh.d.ts +16 -16
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/is-array--YjXV-Wx.d.ts +1207 -0
- package/dist/isPlainObject-BVhBAPHX.d.ts +169 -0
- package/dist/never-BfayMBF9.d.ts +64 -64
- package/dist/next/index.cjs +6 -6
- package/dist/next/index.d.ts +196 -176
- package/dist/next/index.js +5 -5
- package/dist/next/server/index.cjs +1 -1
- package/dist/next/server/index.d.ts +26 -40
- package/dist/next/server/index.js +1 -1
- package/dist/nils-DMz3kU7M.d.ts +155 -155
- package/dist/omit-VvmIsZmX.d.ts +25 -25
- package/dist/operations/index.cjs +1 -1
- package/dist/operations/index.d.ts +121 -176
- package/dist/operations/index.js +1 -1
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.d.ts +35 -36
- package/dist/parsers/index.js +1 -1
- package/dist/predicates/index.cjs +1 -1
- package/dist/predicates/index.d.ts +1701 -1675
- package/dist/predicates/index.js +1 -1
- package/dist/prettify-C4xLcYOP.d.ts +328 -328
- package/dist/promise/index.cjs +1 -1
- package/dist/promise/index.d.ts +29 -38
- package/dist/promise/index.js +1 -1
- package/dist/rzl-utils.global.js +3 -3
- package/dist/string-XA-til3C.d.ts +351 -0
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +712 -787
- package/dist/strings/index.js +1 -1
- package/dist/stylings/index.cjs +1 -1
- package/dist/stylings/index.d.ts +37 -45
- package/dist/stylings/index.js +1 -1
- package/dist/type-data-DDs-u2kq.d.ts +241 -241
- package/dist/types/index.d.ts +3266 -3266
- package/dist/urls/index.cjs +1 -1
- package/dist/urls/index.d.ts +384 -409
- package/dist/urls/index.js +1 -1
- package/package.json +53 -11
- package/dist/array-CIZRbqTF.d.ts +0 -223
- package/dist/chunk-2TRAPBZ7.cjs +0 -1
- package/dist/chunk-3D74QO5D.cjs +0 -1
- package/dist/chunk-4DK3RCC4.js +0 -2
- package/dist/chunk-4JOQ45HL.js +0 -1
- package/dist/chunk-55CZALRS.js +0 -1
- package/dist/chunk-5JFV3GDE.cjs +0 -4
- package/dist/chunk-62HX5Z45.cjs +0 -1
- package/dist/chunk-7NA6DUHR.cjs +0 -2
- package/dist/chunk-BVPMMWDL.cjs +0 -1
- package/dist/chunk-CEFYHEM4.cjs +0 -1
- package/dist/chunk-CN53M4QZ.cjs +0 -1
- package/dist/chunk-D47MHBSD.cjs +0 -1
- package/dist/chunk-DGH75GJD.js +0 -1
- package/dist/chunk-E5NUI7PN.js +0 -1
- package/dist/chunk-FDITZ5C6.cjs +0 -1
- package/dist/chunk-FSSV24W7.cjs +0 -1
- package/dist/chunk-GCGU2WB7.js +0 -1
- package/dist/chunk-GECI2YBP.js +0 -1
- package/dist/chunk-GQE4OVHC.cjs +0 -1
- package/dist/chunk-GRVZXQXL.cjs +0 -1
- package/dist/chunk-I4AVNHPA.cjs +0 -1
- package/dist/chunk-JFRL7NKU.js +0 -4
- package/dist/chunk-KCQDDZJE.cjs +0 -1
- package/dist/chunk-L54ZPSYJ.js +0 -1
- package/dist/chunk-LVKAYEZ4.js +0 -1
- package/dist/chunk-MBDWTK54.cjs +0 -1
- package/dist/chunk-MNGGDB2G.js +0 -1
- package/dist/chunk-MY7BA4GI.cjs +0 -1
- package/dist/chunk-N2IJPIND.cjs +0 -1
- package/dist/chunk-NIMNTEGV.js +0 -1
- package/dist/chunk-PVJF2JHM.js +0 -1
- package/dist/chunk-QCFXEUKL.js +0 -1
- package/dist/chunk-QFCGBBSY.js +0 -1
- package/dist/chunk-QQYAUPSK.cjs +0 -1
- package/dist/chunk-TC4VBE4Y.cjs +0 -1
- package/dist/chunk-TUXDINHF.cjs +0 -1
- package/dist/chunk-U5Y2FXMN.cjs +0 -1
- package/dist/chunk-UUPQI6ND.cjs +0 -1
- package/dist/chunk-VYCGZ2S6.js +0 -1
- package/dist/chunk-W5EDKJK3.js +0 -1
- package/dist/chunk-WHAVUFEU.js +0 -1
- package/dist/chunk-XCFIOTCV.js +0 -1
- package/dist/chunk-XE27XPJR.js +0 -1
- package/dist/chunk-XVB3ZZEB.js +0 -1
- package/dist/chunk-ZBSIGJFO.cjs +0 -1
- package/dist/chunk-ZYAML74V.js +0 -1
- package/dist/extends-Mp81Hq9-.d.ts +0 -145
- package/dist/is-array-Ckm_47hw.d.ts +0 -1557
- package/dist/isPlainObject-BKYaI6a8.d.ts +0 -182
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import{I as If}from'./if-CvT4R7Kh.js';import{I as IsNever}from'./never-BfayMBF9.js';
|
|
2
|
+
/** -------------------------------------------------------
|
|
3
|
+
* * ***IfNot.***
|
|
4
|
+
* -------------------------------------------------------
|
|
5
|
+
*
|
|
6
|
+
* Conditional: returns the second argument if the first argument is `false`, otherwise returns the third argument.
|
|
7
|
+
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
8
|
+
*
|
|
9
|
+
* @template Condition - The boolean condition to check.
|
|
10
|
+
* @template IfTrue - The branch type if condition is `false`. (default: `true`)
|
|
11
|
+
* @template IfFalse - The branch type if condition is `true`. (default: `false`)
|
|
12
|
+
*
|
|
13
|
+
* ### Examples
|
|
14
|
+
* ```ts
|
|
15
|
+
* type A = IfNot<false, "valid">;
|
|
16
|
+
* // ➔ "valid"
|
|
17
|
+
* type B = IfNot<false, "valid", "invalid">;
|
|
18
|
+
* // ➔ "invalid"
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
type IfNot<Condition,IfTrue=true,IfFalse=false>=If<Condition,IfFalse,IfTrue>;
|
|
22
|
+
/** -------------------------------------------------------
|
|
23
|
+
* * ***WordSeparator.***
|
|
24
|
+
* -------------------------------------------------------
|
|
25
|
+
* A type-level utility that defines all valid ***word separators***.
|
|
26
|
+
* - Can be a space `" "`, a dash `"-"`, or an underscore `"_"`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* type A = WordSeparator; // ➔ " " | "-" | "_"
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
type WordSeparator=" "|"-"|"_";
|
|
34
|
+
/** --------------------------------------------------
|
|
35
|
+
* * ***Whitespace.***
|
|
36
|
+
* --------------------------------------------------
|
|
37
|
+
* Represents common whitespace characters.
|
|
38
|
+
*
|
|
39
|
+
* ✅ Used as the default trimming characters in string utility types.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* type W = Whitespace;
|
|
43
|
+
* // ➔ " " | "\t" | "\r" | "\n"
|
|
44
|
+
*/
|
|
45
|
+
type Whitespace=" "|"\t"|"\r"|"\n";
|
|
46
|
+
/** **Helper Internal.** */
|
|
47
|
+
type SafeKeyTrimming<T>=Exclude<T,symbol>;
|
|
48
|
+
/** --------------------------------------------------
|
|
49
|
+
* * ***TrimLeft.***
|
|
50
|
+
* --------------------------------------------------
|
|
51
|
+
* Recursively trims specified characters (default: **{@link Whitespace}**)
|
|
52
|
+
* from the **start (left)** of a string.
|
|
53
|
+
*
|
|
54
|
+
* @template Text - The string to trim.
|
|
55
|
+
* @template Chars - The characters to remove (default: `Whitespace`).
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* type T1 = TrimLeft<"\n hello", " " | "\n">;
|
|
59
|
+
* // ➔ "hello"
|
|
60
|
+
*
|
|
61
|
+
* type T2 = TrimLeft<" world">;
|
|
62
|
+
* // ➔ "world"
|
|
63
|
+
*
|
|
64
|
+
* type T3 = TrimLeft<" world ">;
|
|
65
|
+
* // ➔ "world "
|
|
66
|
+
*/
|
|
67
|
+
type TrimLeft<Text extends PropertyKey,Chars extends PropertyKey=Whitespace>=Text extends`${SafeKeyTrimming<Chars>}${infer Rest}`?TrimLeft<Rest,Chars>:Text;
|
|
68
|
+
/** --------------------------------------------------
|
|
69
|
+
* * ***TrimRight.***
|
|
70
|
+
* --------------------------------------------------
|
|
71
|
+
* Recursively trims specified characters (default: **{@link Whitespace}**)
|
|
72
|
+
* from the **end (right)** of a string.
|
|
73
|
+
*
|
|
74
|
+
* @template Text - The string to trim.
|
|
75
|
+
* @template Chars - The characters to remove (default: `Whitespace`).
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* type T1 = TrimRight<"hello \t", " " | "\t">;
|
|
79
|
+
* // ➔ "hello"
|
|
80
|
+
*
|
|
81
|
+
* type T2 = TrimRight<"world ">;
|
|
82
|
+
* // ➔ "world"
|
|
83
|
+
*
|
|
84
|
+
* type T2 = TrimRight<" world ">;
|
|
85
|
+
* // ➔ " world"
|
|
86
|
+
*/
|
|
87
|
+
type TrimRight<Text extends PropertyKey,Chars extends PropertyKey=Whitespace>=Text extends`${infer Rest}${SafeKeyTrimming<Chars>}`?TrimRight<Rest,Chars>:Text;
|
|
88
|
+
/** --------------------------------------------------
|
|
89
|
+
* * ***Trim.***
|
|
90
|
+
* --------------------------------------------------
|
|
91
|
+
* Trims specified characters (default: **{@link Whitespace}**)
|
|
92
|
+
* from **both the start and end** of a string.
|
|
93
|
+
*
|
|
94
|
+
* @template Text - The string to trim.
|
|
95
|
+
* @template Chars - The characters to remove (default: `Whitespace`).
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* type T1 = Trim<" hello ", " ">;
|
|
99
|
+
* // ➔ "hello"
|
|
100
|
+
*
|
|
101
|
+
* type T2 = Trim<"\n world \t">;
|
|
102
|
+
* // ➔ "world"
|
|
103
|
+
*/
|
|
104
|
+
type Trim<Text extends PropertyKey,Chars extends PropertyKey=Whitespace>=TrimRight<TrimLeft<Text,Chars>,Chars>;
|
|
105
|
+
/** -------------------------------------------------------
|
|
106
|
+
* * ***TrimsLower***
|
|
107
|
+
* -------------------------------------------------------
|
|
108
|
+
* Trims leading & trailing whitespace from a string and
|
|
109
|
+
* converts it to **lowercase**.
|
|
110
|
+
*
|
|
111
|
+
* Utilizes **{@link Trim}** to remove whitespace and **{@link Lowercase}** to convert the string to lowercase.
|
|
112
|
+
*
|
|
113
|
+
* @template S - The input string to transform.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* type T1 = TrimsLower<" HeLLo \n">;
|
|
118
|
+
* // ➔ "hello"
|
|
119
|
+
*
|
|
120
|
+
* type T2 = TrimsLower<" WoRLD ">;
|
|
121
|
+
* // ➔ "world"
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
type TrimsLower<S extends string>=Lowercase<Trim<S>>;
|
|
125
|
+
/** -------------------------------------------------------
|
|
126
|
+
* * ***TrimsUpper***
|
|
127
|
+
* -------------------------------------------------------
|
|
128
|
+
* Trims leading & trailing whitespace from a string and
|
|
129
|
+
* converts it to **uppercase**.
|
|
130
|
+
*
|
|
131
|
+
* Utilizes **{@link Trim}** to remove whitespace and **{@link Uppercase}** to convert the string to uppercase.
|
|
132
|
+
*
|
|
133
|
+
* @template S - The input string to transform.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* type T1 = TrimsUpper<" HeLLo \n">;
|
|
138
|
+
* // ➔ "HELLO"
|
|
139
|
+
*
|
|
140
|
+
* type T2 = TrimsUpper<" WoRLD ">;
|
|
141
|
+
* // ➔ "WORLD"
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
type TrimsUpper<S extends string>=Uppercase<Trim<S>>;
|
|
145
|
+
/** -------------------------------------------------------
|
|
146
|
+
* * ***AnyString.***
|
|
147
|
+
* -------------------------------------------------------
|
|
148
|
+
*
|
|
149
|
+
* A utility type that represents **any string value** while
|
|
150
|
+
* preventing unwanted widening of string literals to `string`.
|
|
151
|
+
*
|
|
152
|
+
* 🔹 This is achieved by intersecting `string` with `{}`,
|
|
153
|
+
* ensuring that the type remains assignable to `string`
|
|
154
|
+
* but is treated as a unique type in generic constraints.
|
|
155
|
+
*
|
|
156
|
+
* 📌 Useful in scenarios where:
|
|
157
|
+
* - You want to accept **any string**, but still preserve
|
|
158
|
+
* literal types in inference.
|
|
159
|
+
* - You need stricter typing than just `string`.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* declare function acceptsAnyString<T extends AnyString>(value: T): T;
|
|
164
|
+
*
|
|
165
|
+
* // Preserves literal
|
|
166
|
+
* const a = acceptsAnyString("hello");
|
|
167
|
+
* // ➔ "hello"
|
|
168
|
+
*
|
|
169
|
+
* // Also allows generic string
|
|
170
|
+
* const b = acceptsAnyString(String("world"));
|
|
171
|
+
* // ➔ string
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
type AnyString={}& string;
|
|
175
|
+
/** -------------------------------------------------------
|
|
176
|
+
* * ***EmptyString.***
|
|
177
|
+
* -------------------------------------------------------
|
|
178
|
+
* Returns the type `T` only if it is the empty string `""`.
|
|
179
|
+
* Optionally trims whitespace before checking.
|
|
180
|
+
*
|
|
181
|
+
* Behavior:
|
|
182
|
+
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
183
|
+
* - If `T` is the general `string` type, returns `never`.
|
|
184
|
+
* - If `T` is empty (after optional trimming), returns `T` or `Trim<T>`.
|
|
185
|
+
*
|
|
186
|
+
* @template T - The string type to check.
|
|
187
|
+
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* // Basic empty string
|
|
192
|
+
* type Case1 = EmptyString<"">;
|
|
193
|
+
* // ➔ ""
|
|
194
|
+
*
|
|
195
|
+
* // Non-empty string
|
|
196
|
+
* type Case2 = EmptyString<"abc">;
|
|
197
|
+
* // ➔ never
|
|
198
|
+
*
|
|
199
|
+
* // General string type
|
|
200
|
+
* type Case3 = EmptyString<string>;
|
|
201
|
+
* // ➔ never
|
|
202
|
+
*
|
|
203
|
+
* // With leading/trailing whitespace
|
|
204
|
+
* type Case4 = EmptyString<" ", true>;
|
|
205
|
+
* // ➔ "" (trimmed)
|
|
206
|
+
* type Case5 = EmptyString<" ", false>;
|
|
207
|
+
* // ➔ never (not trimmed)
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
type EmptyString<T extends string,WithTrim extends boolean=true>=""extends(WithTrim extends true?Trim<T>:T)?string extends(WithTrim extends true?Trim<T>:T)?never:WithTrim extends true?Trim<T>:T:never;
|
|
211
|
+
/** -------------------------------------------------------
|
|
212
|
+
* * ***NonEmptyString.***
|
|
213
|
+
* -------------------------------------------------------
|
|
214
|
+
* Returns the type `T` only if it is a non-empty string.
|
|
215
|
+
* Optionally trims whitespace before checking.
|
|
216
|
+
*
|
|
217
|
+
* Behavior:
|
|
218
|
+
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
219
|
+
* - If `T` is the general `string` type, returns `string`.
|
|
220
|
+
* - If `T` is empty (after optional trimming), returns `never`.
|
|
221
|
+
*
|
|
222
|
+
* @template T - The string type to check.
|
|
223
|
+
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* // Non-empty string
|
|
228
|
+
* type Case1 = NonEmptyString<"abc">; // ➔ "abc"
|
|
229
|
+
*
|
|
230
|
+
* // Empty string
|
|
231
|
+
* type Case2 = NonEmptyString<"">; // ➔ never
|
|
232
|
+
*
|
|
233
|
+
* // General string type
|
|
234
|
+
* type Case3 = NonEmptyString<string>; // ➔ string
|
|
235
|
+
*
|
|
236
|
+
* // String with whitespace
|
|
237
|
+
* type Case4 = NonEmptyString<" ", true>; // ➔ never (trimmed to empty)
|
|
238
|
+
* type Case5 = NonEmptyString<" ", false>; // ➔ " " (not trimmed)
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
type NonEmptyString<T extends string,WithTrim extends boolean=true>=string extends T?string:If<IsNever<EmptyString<T,WithTrim>>,WithTrim extends true?Trim<T>:T,never>;
|
|
242
|
+
/** -------------------------------------------------------
|
|
243
|
+
* * ***IsEmptyString.***
|
|
244
|
+
* -------------------------------------------------------
|
|
245
|
+
* Returns `true` if `T` is exactly the empty string `""`.
|
|
246
|
+
* Optionally trims whitespace before checking.
|
|
247
|
+
*
|
|
248
|
+
* Behavior:
|
|
249
|
+
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
250
|
+
* - If `T` is empty after optional trimming, returns `true`.
|
|
251
|
+
* - Otherwise, returns `false`.
|
|
252
|
+
*
|
|
253
|
+
* @template T - The string type to check.
|
|
254
|
+
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* type Case1 = IsEmptyString<"">;
|
|
259
|
+
* // ➔ true
|
|
260
|
+
* type Case2 = IsEmptyString<"abc">;
|
|
261
|
+
* // ➔ false
|
|
262
|
+
* type Case3 = IsEmptyString<" ", true>;
|
|
263
|
+
* // ➔ true (trimmed)
|
|
264
|
+
* type Case4 = IsEmptyString<" ", false>;
|
|
265
|
+
* // ➔ false (not trimmed)
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
type IsEmptyString<T extends string,WithTrim extends boolean=true>=IfNot<IsNever<EmptyString<T,WithTrim>>>;
|
|
269
|
+
/** -------------------------------------------------------
|
|
270
|
+
* * ***IsNonEmptyString.***
|
|
271
|
+
* -------------------------------------------------------
|
|
272
|
+
* Returns `true` if `T` is a non-empty string.
|
|
273
|
+
* Optionally trims whitespace before checking.
|
|
274
|
+
*
|
|
275
|
+
* Behavior:
|
|
276
|
+
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
277
|
+
* - Returns `true` if `T` is non-empty after optional trimming.
|
|
278
|
+
* - Returns `false` if `T` is empty (after trimming if `WithTrim=true`).
|
|
279
|
+
*
|
|
280
|
+
* @template T - The string type to check.
|
|
281
|
+
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts
|
|
285
|
+
* type Case1 = IsNonEmptyString<"abc">;
|
|
286
|
+
* // ➔ true
|
|
287
|
+
* type Case2 = IsNonEmptyString<"">;
|
|
288
|
+
* // ➔ false
|
|
289
|
+
* type Case3 = IsNonEmptyString<" ", true>;
|
|
290
|
+
* // ➔ false (trimmed)
|
|
291
|
+
* type Case4 = IsNonEmptyString<" ", false>;
|
|
292
|
+
* // ➔ true (not trimmed)
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
type IsNonEmptyString<T extends string,WithTrim extends boolean=true>=IfNot<IsNever<NonEmptyString<T,WithTrim>>>;
|
|
296
|
+
/** -------------------------------------------------------
|
|
297
|
+
* * ***IfEmptyString.***
|
|
298
|
+
* -------------------------------------------------------
|
|
299
|
+
* Conditional type: returns `IfTrue` if `T` is an empty string `""`,
|
|
300
|
+
* otherwise returns `IfFalse`. Optionally trims whitespace before checking.
|
|
301
|
+
*
|
|
302
|
+
* @template T - The string type to check.
|
|
303
|
+
* @template IfTrue - Type returned if `T` is empty (default `true`).
|
|
304
|
+
* @template IfFalse - Type returned if `T` is not empty (default `false`).
|
|
305
|
+
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* type Case1 = IfEmptyString<"">;
|
|
310
|
+
* // ➔ true
|
|
311
|
+
* type Case2 = IfEmptyString<"abc">;
|
|
312
|
+
* // ➔ false
|
|
313
|
+
* type Case3 = IfEmptyString<"", "yes", "no">;
|
|
314
|
+
* // ➔ "yes"
|
|
315
|
+
* type Case4 = IfEmptyString<"abc", "yes", "no">;
|
|
316
|
+
* // ➔ "no"
|
|
317
|
+
* type Case5 = IfEmptyString<" ", "yes", "no", true>;
|
|
318
|
+
* // ➔ "yes" (trimmed)
|
|
319
|
+
* type Case6 = IfEmptyString<" ", "yes", "no", false>;
|
|
320
|
+
* // ➔ "no" (not trimmed)
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
type IfEmptyString<T extends string,IfTrue=true,IfFalse=false,WithTrim extends boolean=true>=IfNot<IsNever<EmptyString<T,WithTrim>>,IfTrue,IfFalse>;
|
|
324
|
+
/** -------------------------------------------------------
|
|
325
|
+
* * ***IfNonEmptyString.***
|
|
326
|
+
* -------------------------------------------------------
|
|
327
|
+
* Conditional type: returns `IfTrue` if `T` is a non-empty string,
|
|
328
|
+
* otherwise returns `IfFalse`. Optionally trims whitespace before checking.
|
|
329
|
+
*
|
|
330
|
+
* @template T - The string type to check.
|
|
331
|
+
* @template IfTrue - Type returned if `T` is non-empty (default `true`).
|
|
332
|
+
* @template IfFalse - Type returned if `T` is empty (default `false`).
|
|
333
|
+
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```ts
|
|
337
|
+
* type Case1 = IfNonEmptyString<"abc">;
|
|
338
|
+
* // ➔ true
|
|
339
|
+
* type Case2 = IfNonEmptyString<"">;
|
|
340
|
+
* // ➔ false
|
|
341
|
+
* type Case3 = IfNonEmptyString<"abc", "yes", "no">;
|
|
342
|
+
* // ➔ "yes"
|
|
343
|
+
* type Case4 = IfNonEmptyString<"", "yes", "no">;
|
|
344
|
+
* // ➔ "no"
|
|
345
|
+
* type Case5 = IfNonEmptyString<" ", "yes", "no", true>;
|
|
346
|
+
* // ➔ "no" (trimmed)
|
|
347
|
+
* type Case6 = IfNonEmptyString<" ", "yes", "no", false>;
|
|
348
|
+
* // ➔ "yes" (not trimmed)
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
type IfNonEmptyString<T extends string,IfTrue=true,IfFalse=false,WithTrim extends boolean=true>=IfNot<IsNever<NonEmptyString<T,WithTrim>>,IfTrue,IfFalse>;export type{AnyString as A,EmptyString as E,IfNot as I,NonEmptyString as N,Trim as T,Whitespace as W,IsEmptyString as a,IfEmptyString as b,WordSeparator as c,IfNonEmptyString as d,IsNonEmptyString as e,TrimLeft as f,TrimRight as g,TrimsLower as h,TrimsUpper as i};
|
package/dist/strings/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkIW73G523_cjs=require('../chunk-IW73G523.cjs'),chunkMROH35V3_cjs=require('../chunk-MROH35V3.cjs');require('../chunk-UTQUYABU.cjs');var chunkCII6WWLO_cjs=require('../chunk-CII6WWLO.cjs');Object.defineProperty(exports,"getInitialsName",{enumerable:true,get:function(){return chunkIW73G523_cjs.b}});Object.defineProperty(exports,"replaceAt",{enumerable:true,get:function(){return chunkIW73G523_cjs.a}});Object.defineProperty(exports,"normalizeSpaces",{enumerable:true,get:function(){return chunkMROH35V3_cjs.a}});Object.defineProperty(exports,"normalizeString",{enumerable:true,get:function(){return chunkMROH35V3_cjs.b}});Object.defineProperty(exports,"removeSpaces",{enumerable:true,get:function(){return chunkMROH35V3_cjs.c}});Object.defineProperty(exports,"stripHtmlTags",{enumerable:true,get:function(){return chunkMROH35V3_cjs.d}});Object.defineProperty(exports,"capitalizeFirst",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.s}});Object.defineProperty(exports,"capitalizeWords",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.t}});Object.defineProperty(exports,"slugify",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.B}});Object.defineProperty(exports,"toCamelCase",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.u}});Object.defineProperty(exports,"toDotCase",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.A}});Object.defineProperty(exports,"toKebabCase",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.y}});Object.defineProperty(exports,"toLowerCase",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.x}});Object.defineProperty(exports,"toPascalCase",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.w}});Object.defineProperty(exports,"toPascalCaseSpace",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.v}});Object.defineProperty(exports,"toSnakeCase",{enumerable:true,get:function(){return chunkCII6WWLO_cjs.z}});
|