@rzl-zone/utils-js 3.2.5-beta.0 → 3.3.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/README.md +16 -20
- package/dist/NumberRangeUnion-B6bhM2s7.d.ts +33 -0
- package/dist/{any-BmdI8UbK.d.ts → any-v4TsK9ES.d.ts} +25 -26
- package/dist/{arrays-normalize-recursive-CnjYJ9xg.d.ts → arrays-normalize-recursive-BqmVuFlD.d.ts} +20 -20
- package/dist/assertions/index.cjs +1 -1
- package/dist/assertions/index.d.ts +96 -70
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-2CQX5CBG.js +1 -0
- package/dist/chunk-2IOOEY45.cjs +1 -0
- package/dist/chunk-3IBQ5MOM.js +1 -0
- package/dist/{chunk-OGPPP2S3.js → chunk-3VA554KW.js} +1 -1
- package/dist/{chunk-FV7SEBKD.cjs → chunk-5757UBXJ.cjs} +1 -1
- package/dist/{chunk-MTUBDVJ2.js → chunk-5IGC6PBH.js} +1 -1
- package/dist/{chunk-O7UT5AN3.cjs → chunk-5KJFVIQT.cjs} +1 -1
- package/dist/chunk-6JFCSH7J.js +1 -0
- package/dist/{chunk-VHAPTHEA.cjs → chunk-6JFZL7YE.cjs} +1 -1
- package/dist/chunk-7ODAAXX5.cjs +1 -0
- package/dist/{chunk-6C3ATUGM.cjs → chunk-CAH33WOQ.cjs} +1 -1
- package/dist/{chunk-ECRNH4FW.js → chunk-CKTLUNWX.js} +1 -1
- package/dist/chunk-CMW2TBOQ.js +1 -0
- package/dist/chunk-D3ENH7H6.cjs +1 -0
- package/dist/{chunk-3YCFMGRB.js → chunk-DEZZUYE2.js} +1 -1
- package/dist/chunk-DWF2R5GD.cjs +1 -0
- package/dist/chunk-E55EQK2U.cjs +1 -0
- package/dist/chunk-E74U6CYP.cjs +1 -0
- package/dist/{chunk-XC3QHAK2.cjs → chunk-EL6A35UR.cjs} +1 -1
- package/dist/chunk-F6IPNNSJ.cjs +1 -0
- package/dist/chunk-FJZGG54N.cjs +1 -0
- package/dist/chunk-FWCKOJZM.js +1 -0
- package/dist/{chunk-IMCLPT5V.cjs → chunk-FWHNWL2P.cjs} +1 -1
- package/dist/chunk-GGEADHZO.js +1 -0
- package/dist/{chunk-IRGE5W7L.js → chunk-GQR4R5WY.js} +1 -1
- package/dist/chunk-H66AC7GK.cjs +1 -0
- package/dist/{chunk-M47QIBXI.cjs → chunk-HQWOFR56.cjs} +1 -1
- package/dist/{chunk-VCFXNV3Q.cjs → chunk-HYRQMTRH.cjs} +1 -1
- package/dist/{chunk-EUANTHVN.js → chunk-IRFL4MAX.js} +1 -1
- package/dist/{chunk-GGWPB23G.cjs → chunk-IVL7CKVH.cjs} +1 -1
- package/dist/chunk-IZPBKKPO.js +1 -0
- package/dist/chunk-JBQMXC5I.cjs +1 -0
- package/dist/chunk-JEQEF5WD.js +1 -0
- package/dist/chunk-JMJQCN74.js +1 -0
- package/dist/chunk-JYQTCICM.js +1 -0
- package/dist/chunk-KVAL5PAG.cjs +1 -0
- package/dist/chunk-LS6U7FAY.cjs +1 -0
- package/dist/chunk-NBZWMBO6.js +1 -0
- package/dist/chunk-NRF6LWBC.cjs +1 -0
- package/dist/chunk-OI5XKNZO.js +1 -0
- package/dist/chunk-OYTYSY7G.js +1 -0
- package/dist/chunk-PET42Z7W.js +1 -0
- package/dist/chunk-PZQ6I4JJ.cjs +1 -0
- package/dist/chunk-QBKAEVYG.js +1 -0
- package/dist/{chunk-YV3K2EKJ.js → chunk-RIPKY4RU.js} +1 -1
- package/dist/chunk-RZW35UN5.cjs +1 -0
- package/dist/chunk-SBFNXGTJ.js +1 -0
- package/dist/{chunk-T4CIAKEK.js → chunk-SBKGWRS5.js} +1 -1
- package/dist/{chunk-5Z2G23WP.js → chunk-SIM77PU4.js} +1 -1
- package/dist/chunk-T2T7K3KR.js +1 -0
- package/dist/chunk-T7PU2V7X.cjs +1 -0
- package/dist/chunk-V45XJKHW.cjs +1 -0
- package/dist/chunk-W2WNBUDE.js +1 -0
- package/dist/chunk-XABCB3Y7.cjs +1 -0
- package/dist/chunk-XEDXFSGI.js +1 -0
- package/dist/chunk-YKPSRP5G.js +1 -0
- package/dist/chunk-YLA3DURS.cjs +1 -0
- package/dist/chunk-ZETAZZLD.cjs +1 -0
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +515 -321
- package/dist/conversions/index.js +1 -1
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +25 -20
- package/dist/events/index.js +1 -1
- package/dist/{extends-Bk_SBGdT.d.ts → extends-DtdRjDyU.d.ts} +63 -87
- package/dist/{formatting → formatters}/index.cjs +1 -1
- package/dist/formatters/index.d.ts +2106 -0
- package/dist/formatters/index.js +1 -0
- package/dist/generators/index.cjs +1 -0
- package/dist/{generator → generators}/index.d.ts +57 -59
- package/dist/generators/index.js +1 -0
- package/dist/{if-CvT4R7Kh.d.ts → if-ChM35c_q.d.ts} +6 -5
- package/dist/index.d.ts +14 -0
- package/dist/{is-array--YjXV-Wx.d.ts → is-array-BJeHxPM3.d.ts} +287 -542
- package/dist/{isPlainObject-BVhBAPHX.d.ts → isPlainObject-DGJkcFYw.d.ts} +6 -6
- package/dist/{never-BfayMBF9.d.ts → never-D89PbPh5.d.ts} +10 -19
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.d.ts +15 -12
- package/dist/next/index.js +1 -1
- package/dist/next/server/index.cjs +1 -1
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +1 -1
- package/dist/{nils-DMz3kU7M.d.ts → nils-CO8zLHSB.d.ts} +39 -65
- package/dist/operations/index.cjs +1 -1
- package/dist/operations/index.d.ts +4 -4
- package/dist/operations/index.js +1 -1
- package/dist/or-C6qzKt2I.d.ts +82 -0
- package/dist/override-CL2olHE5.d.ts +59 -0
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.js +1 -1
- package/dist/pick-BSMX6Xe2.d.ts +15 -0
- package/dist/predicates/index.cjs +1 -1
- package/dist/predicates/index.d.ts +425 -106
- package/dist/predicates/index.js +1 -1
- package/dist/prettify-3o8_Kw6b.d.ts +564 -0
- package/dist/promises/index.cjs +1 -0
- package/dist/promises/index.d.ts +107 -0
- package/dist/promises/index.js +1 -0
- package/dist/promises-LU7K00H0.d.ts +72 -0
- package/dist/rzl-utils.global.js +1 -1
- package/dist/{string-XA-til3C.d.ts → string-B1jlOnws.d.ts} +82 -121
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +209 -210
- package/dist/strings/index.js +1 -1
- package/dist/tailwind/index.cjs +1 -1
- package/dist/tailwind/index.d.ts +23 -17
- package/dist/tailwind/index.js +1 -1
- package/dist/types/index.d.ts +899 -1181
- package/dist/urls/index.cjs +1 -1
- package/dist/urls/index.d.ts +113 -108
- package/dist/urls/index.js +1 -1
- package/package.json +33 -40
- package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +0 -26
- package/dist/chunk-2HSNUPEO.cjs +0 -1
- package/dist/chunk-4Z75R3IT.cjs +0 -1
- package/dist/chunk-AJ25PWXX.cjs +0 -1
- package/dist/chunk-BHIBDDQF.js +0 -1
- package/dist/chunk-CE4JI2YB.js +0 -1
- package/dist/chunk-CMJ6UYWW.cjs +0 -1
- package/dist/chunk-D3VSHABU.cjs +0 -1
- package/dist/chunk-DG2GWBTS.cjs +0 -1
- package/dist/chunk-EKS4IZJR.cjs +0 -1
- package/dist/chunk-EOZKYR5S.cjs +0 -1
- package/dist/chunk-EW3I4O7X.js +0 -1
- package/dist/chunk-F3E77L46.js +0 -1
- package/dist/chunk-G5LXIEFO.js +0 -0
- package/dist/chunk-GVWGQNLF.js +0 -1
- package/dist/chunk-H3FXL4DU.cjs +0 -1
- package/dist/chunk-HHPDLSX2.cjs +0 -1
- package/dist/chunk-JARPXKBM.cjs +0 -1
- package/dist/chunk-JFJUPYDT.cjs +0 -1
- package/dist/chunk-JLP56WSM.js +0 -1
- package/dist/chunk-K3MV4AIN.cjs +0 -1
- package/dist/chunk-KOVO72OM.js +0 -1
- package/dist/chunk-LJ4M3VGE.js +0 -1
- package/dist/chunk-LJVGJLP4.js +0 -1
- package/dist/chunk-MISCBZJC.js +0 -1
- package/dist/chunk-MMSYCIJ2.cjs +0 -1
- package/dist/chunk-OLPKAX7F.cjs +0 -1
- package/dist/chunk-ORZFHBEY.js +0 -1
- package/dist/chunk-OWV2P376.js +0 -1
- package/dist/chunk-RV2WK5E6.js +0 -1
- package/dist/chunk-SBF43G3B.cjs +0 -1
- package/dist/chunk-X74TUJSE.cjs +0 -1
- package/dist/chunk-XLDAIZRK.js +0 -1
- package/dist/chunk-XZJ7C4N6.js +0 -1
- package/dist/chunk-ZHV5ZYVN.cjs +0 -1
- package/dist/chunk-ZL7J6GTP.js +0 -1
- package/dist/chunk-ZTCLKKMB.js +0 -1
- package/dist/env/index.cjs +0 -1
- package/dist/env/index.d.ts +0 -16
- package/dist/env/index.js +0 -1
- package/dist/formatting/index.d.ts +0 -950
- package/dist/formatting/index.js +0 -1
- package/dist/generator/index.cjs +0 -1
- package/dist/generator/index.js +0 -1
- package/dist/omit-VvmIsZmX.d.ts +0 -28
- package/dist/prettify-C4xLcYOP.d.ts +0 -353
- package/dist/promise/index.cjs +0 -1
- package/dist/promise/index.d.ts +0 -31
- package/dist/promise/index.js +0 -1
- package/dist/type-data-DDs-u2kq.d.ts +0 -261
- /package/dist/{chunk-5C2SMIGX.cjs → chunk-BAV5T2E3.cjs} +0 -0
- /package/dist/{chunk-MC3LXMCQ.js → chunk-L5RDAVVH.js} +0 -0
- /package/dist/{chunk-J2RGTPGK.cjs → chunk-VJDDGRIK.cjs} +0 -0
- /package/dist/{chunk-FIAAX3UE.js → chunk-YWHHVDT4.js} +0 -0
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import{I as If}from'./if-
|
|
1
|
+
import{I as If}from'./if-ChM35c_q.js';import{I as IsNever}from'./never-D89PbPh5.js';
|
|
2
2
|
/** -------------------------------------------------------
|
|
3
|
-
* * ***IfNot
|
|
3
|
+
* * ***Utility Type: `IfNot`.***
|
|
4
4
|
* -------------------------------------------------------
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* - **Conditional:**
|
|
6
|
+
* - Returns the second argument if the first argument is `false`, otherwise returns the third argument.
|
|
7
7
|
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
8
|
-
*
|
|
9
8
|
* @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
|
|
9
|
+
* @template IfTrue - The branch type if condition is `false`. (default: `true`).
|
|
10
|
+
* @template IfFalse - The branch type if condition is `true`. (default: `false`).
|
|
11
|
+
* @example
|
|
14
12
|
* ```ts
|
|
15
13
|
* type A = IfNot<false, "valid">;
|
|
16
14
|
* // ➔ "valid"
|
|
@@ -20,144 +18,117 @@ import{I as If}from'./if-CvT4R7Kh.js';import{I as IsNever}from'./never-BfayMBF9.
|
|
|
20
18
|
*/
|
|
21
19
|
type IfNot<Condition,IfTrue=true,IfFalse=false>=If<Condition,IfFalse,IfTrue>;
|
|
22
20
|
/** -------------------------------------------------------
|
|
23
|
-
* * ***WordSeparator
|
|
21
|
+
* * ***Utility Type: `WordSeparator`.***
|
|
24
22
|
* -------------------------------------------------------
|
|
25
|
-
* A type-level utility that defines all valid ***word separators
|
|
23
|
+
* **A type-level utility that defines all valid ***word separators***.**
|
|
26
24
|
* - Can be a space `" "`, a dash `"-"`, or an underscore `"_"`.
|
|
27
|
-
*
|
|
28
25
|
* @example
|
|
29
|
-
* ```ts
|
|
30
26
|
* type A = WordSeparator; // ➔ " " | "-" | "_"
|
|
31
|
-
* ```
|
|
32
27
|
*/
|
|
33
28
|
type WordSeparator=" "|"-"|"_";
|
|
34
29
|
/** --------------------------------------------------
|
|
35
|
-
* * ***Whitespace
|
|
30
|
+
* * ***Utility Type: `Whitespace`.***
|
|
36
31
|
* --------------------------------------------------
|
|
37
|
-
* Represents common whitespace characters
|
|
38
|
-
*
|
|
39
|
-
* ✅ Used as the default trimming characters in string utility types.
|
|
40
|
-
*
|
|
32
|
+
* **Represents common whitespace characters.**
|
|
33
|
+
* - ✅ Used as the default trimming characters in string utility types.
|
|
41
34
|
* @example
|
|
42
|
-
* type W = Whitespace;
|
|
43
|
-
* // ➔ " " | "\t" | "\r" | "\n"
|
|
35
|
+
* type W = Whitespace; // ➔ " " | "\t" | "\r" | "\n"
|
|
44
36
|
*/
|
|
45
37
|
type Whitespace=" "|"\t"|"\r"|"\n";
|
|
46
|
-
/** **Helper Internal.** */
|
|
38
|
+
/** **Helper Type Internal.** */
|
|
47
39
|
type SafeKeyTrimming<T>=Exclude<T,symbol>;
|
|
48
40
|
/** --------------------------------------------------
|
|
49
|
-
* * ***TrimLeft
|
|
41
|
+
* * ***Utility Type: `TrimLeft`.***
|
|
50
42
|
* --------------------------------------------------
|
|
51
|
-
* Recursively trims specified characters (default: **{@link Whitespace}**)
|
|
52
|
-
* from the **start (left)** of a string.
|
|
53
|
-
*
|
|
43
|
+
* **Recursively trims specified characters (default: **{@link Whitespace | `Whitespace`}**) from the **start (left)** of a string.**
|
|
54
44
|
* @template Text - The string to trim.
|
|
55
45
|
* @template Chars - The characters to remove (default: `Whitespace`).
|
|
56
|
-
*
|
|
57
46
|
* @example
|
|
58
47
|
* type T1 = TrimLeft<"\n hello", " " | "\n">;
|
|
59
48
|
* // ➔ "hello"
|
|
60
|
-
*
|
|
61
49
|
* type T2 = TrimLeft<" world">;
|
|
62
50
|
* // ➔ "world"
|
|
63
|
-
*
|
|
64
51
|
* type T3 = TrimLeft<" world ">;
|
|
65
52
|
* // ➔ "world "
|
|
66
53
|
*/
|
|
67
54
|
type TrimLeft<Text extends PropertyKey,Chars extends PropertyKey=Whitespace>=Text extends`${SafeKeyTrimming<Chars>}${infer Rest}`?TrimLeft<Rest,Chars>:Text;
|
|
68
55
|
/** --------------------------------------------------
|
|
69
|
-
* * ***TrimRight
|
|
56
|
+
* * ***Utility Type: `TrimRight`.***
|
|
70
57
|
* --------------------------------------------------
|
|
71
|
-
* Recursively trims specified characters (default: **{@link Whitespace}**)
|
|
72
|
-
* from the **end (right)** of a string.
|
|
73
|
-
*
|
|
58
|
+
* **Recursively trims specified characters (default: **{@link Whitespace | `Whitespace`}**) from the **end (right)** of a string.**
|
|
74
59
|
* @template Text - The string to trim.
|
|
75
60
|
* @template Chars - The characters to remove (default: `Whitespace`).
|
|
76
|
-
*
|
|
77
61
|
* @example
|
|
78
62
|
* type T1 = TrimRight<"hello \t", " " | "\t">;
|
|
79
63
|
* // ➔ "hello"
|
|
80
|
-
*
|
|
81
64
|
* type T2 = TrimRight<"world ">;
|
|
82
65
|
* // ➔ "world"
|
|
83
|
-
*
|
|
84
66
|
* type T2 = TrimRight<" world ">;
|
|
85
67
|
* // ➔ " world"
|
|
86
68
|
*/
|
|
87
69
|
type TrimRight<Text extends PropertyKey,Chars extends PropertyKey=Whitespace>=Text extends`${infer Rest}${SafeKeyTrimming<Chars>}`?TrimRight<Rest,Chars>:Text;
|
|
88
70
|
/** --------------------------------------------------
|
|
89
|
-
* * ***Trim
|
|
71
|
+
* * ***Utility Type: `Trim`.***
|
|
90
72
|
* --------------------------------------------------
|
|
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.
|
|
73
|
+
* **Trims specified characters (default: **{@link Whitespace | `Whitespace`}**)
|
|
74
|
+
* from **both the start and end** of a string.**
|
|
95
75
|
* @template Chars - The characters to remove (default: `Whitespace`).
|
|
96
|
-
*
|
|
97
76
|
* @example
|
|
98
77
|
* type T1 = Trim<" hello ", " ">;
|
|
99
78
|
* // ➔ "hello"
|
|
100
|
-
*
|
|
101
79
|
* type T2 = Trim<"\n world \t">;
|
|
102
80
|
* // ➔ "world"
|
|
103
81
|
*/
|
|
104
82
|
type Trim<Text extends PropertyKey,Chars extends PropertyKey=Whitespace>=TrimRight<TrimLeft<Text,Chars>,Chars>;
|
|
105
83
|
/** -------------------------------------------------------
|
|
106
|
-
* * ***TrimsLower
|
|
84
|
+
* * ***Utility Type: `TrimsLower`.***
|
|
107
85
|
* -------------------------------------------------------
|
|
108
|
-
* Trims leading & trailing whitespace from a string and
|
|
109
|
-
* converts it to **lowercase
|
|
110
|
-
*
|
|
111
|
-
* Utilizes **{@link Trim}** to remove whitespace and
|
|
112
|
-
*
|
|
86
|
+
* **Trims leading & trailing whitespace from a string and
|
|
87
|
+
* converts it to **lowercase**.**
|
|
88
|
+
* @description
|
|
89
|
+
* Utilizes **{@link Trim | `Trim`}** to remove whitespace and
|
|
90
|
+
* **{@link Lowercase | `Lowercase`}** to convert the string to lowercase.
|
|
113
91
|
* @template S - The input string to transform.
|
|
114
|
-
*
|
|
115
92
|
* @example
|
|
116
93
|
* ```ts
|
|
117
94
|
* type T1 = TrimsLower<" HeLLo \n">;
|
|
118
95
|
* // ➔ "hello"
|
|
119
|
-
*
|
|
120
96
|
* type T2 = TrimsLower<" WoRLD ">;
|
|
121
97
|
* // ➔ "world"
|
|
122
98
|
* ```
|
|
123
99
|
*/
|
|
124
100
|
type TrimsLower<S extends string>=Lowercase<Trim<S>>;
|
|
125
101
|
/** -------------------------------------------------------
|
|
126
|
-
* * ***TrimsUpper
|
|
102
|
+
* * ***Utility Type: `TrimsUpper`.***
|
|
127
103
|
* -------------------------------------------------------
|
|
128
|
-
* Trims leading & trailing whitespace from a string and
|
|
129
|
-
* converts it to **uppercase
|
|
130
|
-
*
|
|
131
|
-
* Utilizes **{@link Trim}** to remove whitespace and
|
|
132
|
-
*
|
|
104
|
+
* **Trims leading & trailing whitespace from a string and
|
|
105
|
+
* converts it to **uppercase**.**
|
|
106
|
+
* @description
|
|
107
|
+
* Utilizes **{@link Trim | `Trim`}** to remove whitespace and
|
|
108
|
+
* **{@link Uppercase | `Uppercase`}** to convert the string to uppercase.
|
|
133
109
|
* @template S - The input string to transform.
|
|
134
|
-
*
|
|
135
110
|
* @example
|
|
136
111
|
* ```ts
|
|
137
112
|
* type T1 = TrimsUpper<" HeLLo \n">;
|
|
138
113
|
* // ➔ "HELLO"
|
|
139
|
-
*
|
|
140
114
|
* type T2 = TrimsUpper<" WoRLD ">;
|
|
141
115
|
* // ➔ "WORLD"
|
|
142
116
|
* ```
|
|
143
117
|
*/
|
|
144
118
|
type TrimsUpper<S extends string>=Uppercase<Trim<S>>;
|
|
145
119
|
/** -------------------------------------------------------
|
|
146
|
-
* * ***AnyString
|
|
120
|
+
* * ***Utility Type: `AnyString`.***
|
|
147
121
|
* -------------------------------------------------------
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* 🔹 This is achieved by intersecting `string` with `{}`,
|
|
122
|
+
* **A utility type that represents **any string value** while
|
|
123
|
+
* preventing unwanted widening of string literals to `string`.**
|
|
124
|
+
* @description
|
|
125
|
+
* This is achieved by intersecting `string` with `{}`,
|
|
153
126
|
* ensuring that the type remains assignable to `string`
|
|
154
127
|
* but is treated as a unique type in generic constraints.
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* - You need stricter typing than just `string`.
|
|
160
|
-
*
|
|
128
|
+
* - **Useful in scenarios where:**
|
|
129
|
+
* - You want to accept **any string**, but still preserve
|
|
130
|
+
* literal types in inference.
|
|
131
|
+
* - You need stricter typing than just `string`.
|
|
161
132
|
* @example
|
|
162
133
|
* ```ts
|
|
163
134
|
* declare function acceptsAnyString<T extends AnyString>(value: T): T;
|
|
@@ -173,19 +144,17 @@ type TrimsUpper<S extends string>=Uppercase<Trim<S>>;
|
|
|
173
144
|
*/
|
|
174
145
|
type AnyString={}& string;
|
|
175
146
|
/** -------------------------------------------------------
|
|
176
|
-
* * ***EmptyString
|
|
147
|
+
* * ***Utility Type: `EmptyString`.***
|
|
177
148
|
* -------------------------------------------------------
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* Behavior
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
149
|
+
* - **Conditional type:**
|
|
150
|
+
* - Returns the type `T` only if it is the empty string `""`.
|
|
151
|
+
* - Optionally trims whitespace before checking.
|
|
152
|
+
* - **Behavior:**
|
|
153
|
+
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
154
|
+
* - If `T` is the general `string` type, returns `never`.
|
|
155
|
+
* - If `T` is empty (after optional trimming), returns `T` or `Trim<T>`.
|
|
186
156
|
* @template T - The string type to check.
|
|
187
157
|
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
188
|
-
*
|
|
189
158
|
* @example
|
|
190
159
|
* ```ts
|
|
191
160
|
* // Basic empty string
|
|
@@ -209,19 +178,17 @@ type AnyString={}& string;
|
|
|
209
178
|
*/
|
|
210
179
|
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
180
|
/** -------------------------------------------------------
|
|
212
|
-
* * ***NonEmptyString
|
|
181
|
+
* * ***Utility Type: `NonEmptyString`.***
|
|
213
182
|
* -------------------------------------------------------
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* Behavior
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
183
|
+
* - **Conditional type:**
|
|
184
|
+
* - Returns the type `T` only if it is a non-empty string.
|
|
185
|
+
* - Optionally trims whitespace before checking.
|
|
186
|
+
* - **Behavior:**
|
|
187
|
+
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
188
|
+
* - If `T` is the general `string` type, returns `string`.
|
|
189
|
+
* - If `T` is empty (after optional trimming), returns `never`.
|
|
222
190
|
* @template T - The string type to check.
|
|
223
191
|
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
224
|
-
*
|
|
225
192
|
* @example
|
|
226
193
|
* ```ts
|
|
227
194
|
* // Non-empty string
|
|
@@ -240,19 +207,17 @@ type EmptyString<T extends string,WithTrim extends boolean=true>=""extends(WithT
|
|
|
240
207
|
*/
|
|
241
208
|
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
209
|
/** -------------------------------------------------------
|
|
243
|
-
* * ***IsEmptyString
|
|
210
|
+
* * ***Utility Type: `IsEmptyString`.***
|
|
244
211
|
* -------------------------------------------------------
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* Behavior
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
212
|
+
* - **Conditional type:**
|
|
213
|
+
* - Returns `true` if `T` is exactly the empty string `""`.
|
|
214
|
+
* - Optionally trims whitespace before checking.
|
|
215
|
+
* - **Behavior:**
|
|
216
|
+
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
217
|
+
* - If `T` is empty after optional trimming, returns `true`.
|
|
218
|
+
* - Otherwise, returns `false`.
|
|
253
219
|
* @template T - The string type to check.
|
|
254
220
|
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
255
|
-
*
|
|
256
221
|
* @example
|
|
257
222
|
* ```ts
|
|
258
223
|
* type Case1 = IsEmptyString<"">;
|
|
@@ -267,19 +232,17 @@ type NonEmptyString<T extends string,WithTrim extends boolean=true>=string exten
|
|
|
267
232
|
*/
|
|
268
233
|
type IsEmptyString<T extends string,WithTrim extends boolean=true>=IfNot<IsNever<EmptyString<T,WithTrim>>>;
|
|
269
234
|
/** -------------------------------------------------------
|
|
270
|
-
* * ***IsNonEmptyString
|
|
235
|
+
* * ***Utility Type: `IsNonEmptyString`.***
|
|
271
236
|
* -------------------------------------------------------
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* Behavior
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
237
|
+
* - **Conditional type:**
|
|
238
|
+
* - Returns `true` if `T` is a non-empty string.
|
|
239
|
+
* - Optionally trims whitespace before checking.
|
|
240
|
+
* - **Behavior:**
|
|
241
|
+
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
242
|
+
* - Returns `true` if `T` is non-empty after optional trimming.
|
|
243
|
+
* - Returns `false` if `T` is empty (after trimming if `WithTrim=true`).
|
|
280
244
|
* @template T - The string type to check.
|
|
281
245
|
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
282
|
-
*
|
|
283
246
|
* @example
|
|
284
247
|
* ```ts
|
|
285
248
|
* type Case1 = IsNonEmptyString<"abc">;
|
|
@@ -294,16 +257,15 @@ type IsEmptyString<T extends string,WithTrim extends boolean=true>=IfNot<IsNever
|
|
|
294
257
|
*/
|
|
295
258
|
type IsNonEmptyString<T extends string,WithTrim extends boolean=true>=IfNot<IsNever<NonEmptyString<T,WithTrim>>>;
|
|
296
259
|
/** -------------------------------------------------------
|
|
297
|
-
* * ***IfEmptyString
|
|
260
|
+
* * ***Utility Type: `IfEmptyString`.***
|
|
298
261
|
* -------------------------------------------------------
|
|
299
|
-
* Conditional type
|
|
300
|
-
*
|
|
301
|
-
*
|
|
262
|
+
* - **Conditional type:**
|
|
263
|
+
* - Returns `IfTrue` if `T` is an empty string `""`, otherwise returns `IfFalse`.
|
|
264
|
+
* - Optionally trims whitespace before checking.
|
|
302
265
|
* @template T - The string type to check.
|
|
303
266
|
* @template IfTrue - Type returned if `T` is empty (default `true`).
|
|
304
267
|
* @template IfFalse - Type returned if `T` is not empty (default `false`).
|
|
305
268
|
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
306
|
-
*
|
|
307
269
|
* @example
|
|
308
270
|
* ```ts
|
|
309
271
|
* type Case1 = IfEmptyString<"">;
|
|
@@ -322,16 +284,15 @@ type IsNonEmptyString<T extends string,WithTrim extends boolean=true>=IfNot<IsNe
|
|
|
322
284
|
*/
|
|
323
285
|
type IfEmptyString<T extends string,IfTrue=true,IfFalse=false,WithTrim extends boolean=true>=IfNot<IsNever<EmptyString<T,WithTrim>>,IfTrue,IfFalse>;
|
|
324
286
|
/** -------------------------------------------------------
|
|
325
|
-
* * ***IfNonEmptyString
|
|
287
|
+
* * ***Utility Type: `IfNonEmptyString`.***
|
|
326
288
|
* -------------------------------------------------------
|
|
327
|
-
* Conditional type
|
|
328
|
-
*
|
|
329
|
-
*
|
|
289
|
+
* - **Conditional type:**
|
|
290
|
+
* - Returns `IfTrue` if `T` is a non-empty string, otherwise returns `IfFalse`.
|
|
291
|
+
* - Optionally trims whitespace before checking.
|
|
330
292
|
* @template T - The string type to check.
|
|
331
293
|
* @template IfTrue - Type returned if `T` is non-empty (default `true`).
|
|
332
294
|
* @template IfFalse - Type returned if `T` is empty (default `false`).
|
|
333
295
|
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
334
|
-
*
|
|
335
296
|
* @example
|
|
336
297
|
* ```ts
|
|
337
298
|
* type Case1 = IfNonEmptyString<"abc">;
|
package/dist/strings/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../chunk-
|
|
1
|
+
"use strict";var e=require("../chunk-D3ENH7H6.cjs"),t=require("../chunk-E74U6CYP.cjs"),r=require("../chunk-2IOOEY45.cjs"),n=require("../chunk-KVAL5PAG.cjs");require("../chunk-E55EQK2U.cjs");var o=require("../chunk-PZQ6I4JJ.cjs");Object.defineProperty(exports,"capitalizeFirst",{enumerable:!0,get:function(){return e.capitalizeFirst}}),Object.defineProperty(exports,"capitalizeWords",{enumerable:!0,get:function(){return e.capitalizeWords}}),Object.defineProperty(exports,"getInitialsName",{enumerable:!0,get:function(){return e.getInitialsName}}),Object.defineProperty(exports,"replaceAt",{enumerable:!0,get:function(){return e.replaceAt}}),Object.defineProperty(exports,"stripHtmlTags",{enumerable:!0,get:function(){return e.stripHtmlTags}}),Object.defineProperty(exports,"normalizeString",{enumerable:!0,get:function(){return t.normalizeString}}),Object.defineProperty(exports,"normalizeSpaces",{enumerable:!0,get:function(){return r.normalizeSpaces}}),Object.defineProperty(exports,"removeSpaces",{enumerable:!0,get:function(){return n.removeSpaces}}),Object.defineProperty(exports,"slugify",{enumerable:!0,get:function(){return o.slugify}}),Object.defineProperty(exports,"toCamelCase",{enumerable:!0,get:function(){return o.toCamelCase}}),Object.defineProperty(exports,"toDotCase",{enumerable:!0,get:function(){return o.toDotCase}}),Object.defineProperty(exports,"toKebabCase",{enumerable:!0,get:function(){return o.toKebabCase}}),Object.defineProperty(exports,"toLowerCase",{enumerable:!0,get:function(){return o.toLowerCase}}),Object.defineProperty(exports,"toPascalCase",{enumerable:!0,get:function(){return o.toPascalCase}}),Object.defineProperty(exports,"toPascalCaseSpace",{enumerable:!0,get:function(){return o.toPascalCaseSpace}}),Object.defineProperty(exports,"toSnakeCase",{enumerable:!0,get:function(){return o.toSnakeCase}});
|