toolbox-x 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/Color-B3mgF9Dh.d.cts +486 -0
- package/dist/Color-D38Xrw65.d.mts +486 -0
- package/dist/Stylog-Df7eq3-j.d.cts +519 -0
- package/dist/Stylog-jvlLcMQq.d.mts +519 -0
- package/dist/array-DvW0zIu6.d.mts +130 -0
- package/dist/array-rUnEVisO.d.cts +130 -0
- package/dist/basics-D_eSv0cu.cjs +132 -0
- package/dist/basics-Dp_aEK81.mjs +115 -0
- package/dist/basics-WEYWlnRO.d.cts +95 -0
- package/dist/basics-uBSfkBEI.d.mts +95 -0
- package/dist/case-BWIt8Ash.mjs +449 -0
- package/dist/case-C-S-b5YP.d.cts +327 -0
- package/dist/case-CS8Ii3A7.cjs +526 -0
- package/dist/case-CybASFPD.d.mts +327 -0
- package/dist/change-case.cjs +32 -0
- package/dist/change-case.d.cts +18 -0
- package/dist/change-case.d.mts +18 -0
- package/dist/change-case.mjs +19 -0
- package/dist/colors.cjs +574 -0
- package/dist/colors.d.cts +355 -0
- package/dist/colors.d.mts +355 -0
- package/dist/colors.mjs +547 -0
- package/dist/constants-2gAw23_7.mjs +144 -0
- package/dist/constants-B34K0QPi.d.cts +21 -0
- package/dist/constants-BIBDKY1u.cjs +924 -0
- package/dist/constants-BWT-810U.cjs +158 -0
- package/dist/constants-BwbHnXlM.mjs +662 -0
- package/dist/constants-BxN9l5el.cjs +74 -0
- package/dist/constants-CLS_bgKD.d.mts +847 -0
- package/dist/constants-D73iFu8g.mjs +171 -0
- package/dist/constants-DAfRxaa8.mjs +62 -0
- package/dist/constants-DQYeCjlx.cjs +207 -0
- package/dist/constants-Deeie-iH.d.mts +21 -0
- package/dist/constants-DpTG9RP6.d.mts +29 -0
- package/dist/constants-DqwnkJ_d.cjs +740 -0
- package/dist/constants-DvRUY_FY.cjs +150 -0
- package/dist/constants-VcRtQu0K.d.cts +29 -0
- package/dist/constants-X5hm1UtB.mjs +912 -0
- package/dist/constants-eNd-iYsV.mjs +134 -0
- package/dist/constants-qm8FafmD.d.cts +847 -0
- package/dist/constants.cjs +415 -0
- package/dist/constants.d.cts +184 -0
- package/dist/constants.d.mts +184 -0
- package/dist/constants.mjs +378 -0
- package/dist/convert-BOCgUv2D.cjs +252 -0
- package/dist/convert-Bn4jFomQ.mjs +169 -0
- package/dist/convert-BrzlG-m_.cjs +475 -0
- package/dist/convert-DhaUoPVU.mjs +368 -0
- package/dist/converter-1P90_RcP.d.mts +402 -0
- package/dist/converter-CmkcAppi.d.cts +402 -0
- package/dist/converter.cjs +780 -0
- package/dist/converter.d.cts +29 -0
- package/dist/converter.d.mts +29 -0
- package/dist/converter.mjs +771 -0
- package/dist/countries-CIpmtEzV.cjs +1469 -0
- package/dist/countries-Cy0xiqS3.mjs +1463 -0
- package/dist/css-colors-Bx947Ng3.d.cts +179 -0
- package/dist/css-colors-CXCDqQbG.cjs +186 -0
- package/dist/css-colors-CXTp1vvy.d.mts +179 -0
- package/dist/css-colors-DfUW3nTR.mjs +180 -0
- package/dist/date.cjs +332 -0
- package/dist/date.d.cts +213 -0
- package/dist/date.d.mts +213 -0
- package/dist/date.mjs +298 -0
- package/dist/dom.cjs +461 -0
- package/dist/dom.d.cts +228 -0
- package/dist/dom.d.mts +228 -0
- package/dist/dom.mjs +429 -0
- package/dist/form-BMFVGUrN.d.mts +118 -0
- package/dist/form-DRFbryvK.d.cts +118 -0
- package/dist/guards-3kaUX66g.mjs +157 -0
- package/dist/guards-C8gkvIHb.cjs +240 -0
- package/dist/guards-DdyU4h4o.mjs +110 -0
- package/dist/guards-Efhp1mNy.cjs +151 -0
- package/dist/guards.cjs +172 -0
- package/dist/guards.d.cts +399 -0
- package/dist/guards.d.mts +399 -0
- package/dist/guards.mjs +75 -0
- package/dist/hash-B6JPEyAz.d.mts +131 -0
- package/dist/hash-NTpeKYB_.d.cts +131 -0
- package/dist/hash.cjs +2126 -0
- package/dist/hash.d.cts +1239 -0
- package/dist/hash.d.mts +1239 -0
- package/dist/hash.mjs +2095 -0
- package/dist/http-status-BAZdtr7-.d.mts +65 -0
- package/dist/http-status-U_3MtoGb.d.cts +65 -0
- package/dist/http-status.cjs +173 -0
- package/dist/http-status.d.cts +142 -0
- package/dist/http-status.d.mts +142 -0
- package/dist/http-status.mjs +171 -0
- package/dist/index.cjs +2551 -0
- package/dist/index.d.cts +1493 -0
- package/dist/index.d.mts +1493 -0
- package/dist/index.mjs +2357 -0
- package/dist/object-B0TV3eHx.d.mts +8052 -0
- package/dist/object-Blq0Amdv.d.cts +8052 -0
- package/dist/objectify-CDs0Fbr1.mjs +417 -0
- package/dist/objectify-DIJ-OBmo.cjs +524 -0
- package/dist/paginator.cjs +245 -0
- package/dist/paginator.d.cts +144 -0
- package/dist/paginator.d.mts +144 -0
- package/dist/paginator.mjs +243 -0
- package/dist/parse-2ubxXZRp.cjs +211 -0
- package/dist/parse-N7g942uy.mjs +164 -0
- package/dist/pluralizer-BjMIc6uT.d.mts +42 -0
- package/dist/pluralizer-Cb6ZmrDl.d.cts +42 -0
- package/dist/pluralizer.cjs +678 -0
- package/dist/pluralizer.d.cts +152 -0
- package/dist/pluralizer.d.mts +152 -0
- package/dist/pluralizer.mjs +676 -0
- package/dist/primitives-B26uZolQ.cjs +228 -0
- package/dist/primitives-KsFUp3kQ.mjs +144 -0
- package/dist/specials-D48_IZbd.d.mts +108 -0
- package/dist/specials-DzLr1ZgU.cjs +477 -0
- package/dist/specials-LVONlKbQ.d.cts +108 -0
- package/dist/specials-uhDuRg8H.mjs +292 -0
- package/dist/string-CBAbxaG1.d.mts +258 -0
- package/dist/string-CsNsm_65.d.cts +258 -0
- package/dist/stylog.cjs +621 -0
- package/dist/stylog.d.cts +49 -0
- package/dist/stylog.d.mts +49 -0
- package/dist/stylog.mjs +614 -0
- package/dist/timezone-B2OYK6Fh.mjs +5589 -0
- package/dist/timezone-Beh9IGpw.cjs +5625 -0
- package/dist/types/array.cjs +16 -0
- package/dist/types/array.d.cts +18 -0
- package/dist/types/array.d.mts +18 -0
- package/dist/types/array.mjs +17 -0
- package/dist/types/colors.cjs +16 -0
- package/dist/types/colors.d.cts +18 -0
- package/dist/types/colors.d.mts +18 -0
- package/dist/types/colors.mjs +17 -0
- package/dist/types/converter.cjs +16 -0
- package/dist/types/converter.d.cts +18 -0
- package/dist/types/converter.d.mts +18 -0
- package/dist/types/converter.mjs +17 -0
- package/dist/types/form.cjs +16 -0
- package/dist/types/form.d.cts +18 -0
- package/dist/types/form.d.mts +18 -0
- package/dist/types/form.mjs +17 -0
- package/dist/types/hash.cjs +16 -0
- package/dist/types/hash.d.cts +18 -0
- package/dist/types/hash.d.mts +18 -0
- package/dist/types/hash.mjs +17 -0
- package/dist/types/http-status.cjs +16 -0
- package/dist/types/http-status.d.cts +18 -0
- package/dist/types/http-status.d.mts +18 -0
- package/dist/types/http-status.mjs +17 -0
- package/dist/types/index.cjs +16 -0
- package/dist/types/index.d.cts +18 -0
- package/dist/types/index.d.mts +18 -0
- package/dist/types/index.mjs +17 -0
- package/dist/types/number.cjs +16 -0
- package/dist/types/number.d.cts +18 -0
- package/dist/types/number.d.mts +18 -0
- package/dist/types/number.mjs +17 -0
- package/dist/types/object.cjs +16 -0
- package/dist/types/object.d.cts +18 -0
- package/dist/types/object.d.mts +18 -0
- package/dist/types/object.mjs +17 -0
- package/dist/types/pluralizer.cjs +16 -0
- package/dist/types/pluralizer.d.cts +18 -0
- package/dist/types/pluralizer.d.mts +18 -0
- package/dist/types/pluralizer.mjs +17 -0
- package/dist/types/string.cjs +16 -0
- package/dist/types/string.d.cts +18 -0
- package/dist/types/string.d.mts +18 -0
- package/dist/types/string.mjs +17 -0
- package/dist/types/stylog.cjs +16 -0
- package/dist/types/stylog.d.cts +18 -0
- package/dist/types/stylog.d.mts +18 -0
- package/dist/types/stylog.mjs +17 -0
- package/dist/types/utils.cjs +16 -0
- package/dist/types/utils.d.cts +18 -0
- package/dist/types/utils.d.mts +18 -0
- package/dist/types/utils.mjs +17 -0
- package/dist/types/verbalizer.cjs +16 -0
- package/dist/types/verbalizer.d.cts +30 -0
- package/dist/types/verbalizer.d.mts +30 -0
- package/dist/types/verbalizer.mjs +17 -0
- package/dist/utilities-CLUmdQeV.cjs +140 -0
- package/dist/utilities-m5yFKqLd.mjs +105 -0
- package/dist/utils-ClW9LA6f.mjs +449 -0
- package/dist/utils-DLFRgXUC.cjs +568 -0
- package/dist/verbalizer.cjs +998 -0
- package/dist/verbalizer.d.cts +148 -0
- package/dist/verbalizer.d.mts +148 -0
- package/dist/verbalizer.mjs +996 -0
- package/package.json +249 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
//#region src/guards/primitives.ts
|
|
19
|
+
/**
|
|
20
|
+
* * Type guard to check whether a value is a finite number (excluding `NaN` and `Infinity`).
|
|
21
|
+
* @param value - The value to test.
|
|
22
|
+
* @returns `true` if the value is a finite number; otherwise `false`.
|
|
23
|
+
*/
|
|
24
|
+
function isNumber(value) {
|
|
25
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* * Type guard to check if a value is a string.
|
|
29
|
+
* @param value - The value to check.
|
|
30
|
+
* @returns `true` if the value is a string, otherwise `false`.
|
|
31
|
+
*/
|
|
32
|
+
function isString(value) {
|
|
33
|
+
return typeof value === "string";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* * Type guard to check if a value is an integer.
|
|
37
|
+
* @param value - The value to check.
|
|
38
|
+
* @returns `true` if the value is an integer, otherwise `false`.
|
|
39
|
+
*/
|
|
40
|
+
function isInteger(value) {
|
|
41
|
+
return isNumber(value) && Number.isInteger(value);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* * Type guard to check if a value is a positive integer.
|
|
45
|
+
* @param value - The value to check.
|
|
46
|
+
* @returns `true` if the value is a positive integer, otherwise `false`.
|
|
47
|
+
*/
|
|
48
|
+
function isPositiveInteger(value) {
|
|
49
|
+
return isInteger(value) && value > 0;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* * Type guard to check if a value is a boolean.
|
|
53
|
+
* @param value - The value to check.
|
|
54
|
+
* @returns `true` if the value is a boolean, otherwise `false`.
|
|
55
|
+
*/
|
|
56
|
+
function isBoolean(value) {
|
|
57
|
+
return typeof value === "boolean";
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* * Type guard to check if a value is null.
|
|
61
|
+
* @param value - The value to check.
|
|
62
|
+
* @returns `true` if the value is null, otherwise `false`.
|
|
63
|
+
*/
|
|
64
|
+
function isNull(value) {
|
|
65
|
+
return value === null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* * Type guard to check if a value is undefined.
|
|
69
|
+
* @param value - The value to check.
|
|
70
|
+
* @returns `true` if the value is undefined, otherwise `false`.
|
|
71
|
+
*/
|
|
72
|
+
function isUndefined(value) {
|
|
73
|
+
return value === void 0;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* * Type guard to check if a value is a symbol.
|
|
77
|
+
* @param value - The value to check.
|
|
78
|
+
* @returns `true` if the value is a symbol, otherwise `false`.
|
|
79
|
+
*/
|
|
80
|
+
function isSymbol(value) {
|
|
81
|
+
return typeof value === "symbol";
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* * Type guard to check if a value is a BigInt.
|
|
85
|
+
* @param value - The value to check.
|
|
86
|
+
* @returns `true` if the value is a BigInt, otherwise `false`.
|
|
87
|
+
*/
|
|
88
|
+
function isBigInt(value) {
|
|
89
|
+
return typeof value === "bigint";
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* * Type guard to check if a value is a primitive (i.e. `string | number | boolean | symbol | bigint | null | undefined`).
|
|
93
|
+
* @param value - The value to check.
|
|
94
|
+
* @returns `true` if the value is a primitive, otherwise `false`.
|
|
95
|
+
*/
|
|
96
|
+
function isPrimitive(value) {
|
|
97
|
+
return value === null || [
|
|
98
|
+
"string",
|
|
99
|
+
"number",
|
|
100
|
+
"boolean",
|
|
101
|
+
"symbol",
|
|
102
|
+
"bigint",
|
|
103
|
+
"undefined"
|
|
104
|
+
].includes(typeof value);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* * Type guard to check if a value is a normal primitive (i.e. `string | number | boolean | null | undefined`).
|
|
108
|
+
* @param value - The value to check.
|
|
109
|
+
* @returns `true` if the value is a primitive, otherwise `false`.
|
|
110
|
+
*/
|
|
111
|
+
function isNormalPrimitive(value) {
|
|
112
|
+
return value == null || [
|
|
113
|
+
"string",
|
|
114
|
+
"number",
|
|
115
|
+
"boolean",
|
|
116
|
+
"undefined"
|
|
117
|
+
].includes(typeof value);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* * Type guard to check if a value is a non-empty string.
|
|
121
|
+
* @param value - The value to check.
|
|
122
|
+
* @returns `true` if the value is a non-empty string, otherwise `false`.
|
|
123
|
+
*/
|
|
124
|
+
function isNonEmptyString(value) {
|
|
125
|
+
return isString(value) && value?.length > 0;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* * Type guard to check if a value is falsy.
|
|
129
|
+
* @param value - The value to check.
|
|
130
|
+
* @returns `true` if the value is falsy, otherwise `false`.
|
|
131
|
+
*/
|
|
132
|
+
function isFalsy(value) {
|
|
133
|
+
return !value;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* * Type guard to check if a value is truthy.
|
|
137
|
+
* @param value - The value to check.
|
|
138
|
+
* @returns `true` if the value is truthy (not null or undefined), otherwise `false`.
|
|
139
|
+
*/
|
|
140
|
+
function isTruthy(value) {
|
|
141
|
+
return Boolean(value);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//#endregion
|
|
145
|
+
Object.defineProperty(exports, 'isBigInt', {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function () {
|
|
148
|
+
return isBigInt;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(exports, 'isBoolean', {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function () {
|
|
154
|
+
return isBoolean;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(exports, 'isFalsy', {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function () {
|
|
160
|
+
return isFalsy;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
Object.defineProperty(exports, 'isInteger', {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function () {
|
|
166
|
+
return isInteger;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
Object.defineProperty(exports, 'isNonEmptyString', {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function () {
|
|
172
|
+
return isNonEmptyString;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(exports, 'isNormalPrimitive', {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function () {
|
|
178
|
+
return isNormalPrimitive;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(exports, 'isNull', {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function () {
|
|
184
|
+
return isNull;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(exports, 'isNumber', {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function () {
|
|
190
|
+
return isNumber;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
Object.defineProperty(exports, 'isPositiveInteger', {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
get: function () {
|
|
196
|
+
return isPositiveInteger;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
Object.defineProperty(exports, 'isPrimitive', {
|
|
200
|
+
enumerable: true,
|
|
201
|
+
get: function () {
|
|
202
|
+
return isPrimitive;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
Object.defineProperty(exports, 'isString', {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
get: function () {
|
|
208
|
+
return isString;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(exports, 'isSymbol', {
|
|
212
|
+
enumerable: true,
|
|
213
|
+
get: function () {
|
|
214
|
+
return isSymbol;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
Object.defineProperty(exports, 'isTruthy', {
|
|
218
|
+
enumerable: true,
|
|
219
|
+
get: function () {
|
|
220
|
+
return isTruthy;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
Object.defineProperty(exports, 'isUndefined', {
|
|
224
|
+
enumerable: true,
|
|
225
|
+
get: function () {
|
|
226
|
+
return isUndefined;
|
|
227
|
+
}
|
|
228
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
//#region src/guards/primitives.ts
|
|
18
|
+
/**
|
|
19
|
+
* * Type guard to check whether a value is a finite number (excluding `NaN` and `Infinity`).
|
|
20
|
+
* @param value - The value to test.
|
|
21
|
+
* @returns `true` if the value is a finite number; otherwise `false`.
|
|
22
|
+
*/
|
|
23
|
+
function isNumber(value) {
|
|
24
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* * Type guard to check if a value is a string.
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @returns `true` if the value is a string, otherwise `false`.
|
|
30
|
+
*/
|
|
31
|
+
function isString(value) {
|
|
32
|
+
return typeof value === "string";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* * Type guard to check if a value is an integer.
|
|
36
|
+
* @param value - The value to check.
|
|
37
|
+
* @returns `true` if the value is an integer, otherwise `false`.
|
|
38
|
+
*/
|
|
39
|
+
function isInteger(value) {
|
|
40
|
+
return isNumber(value) && Number.isInteger(value);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* * Type guard to check if a value is a positive integer.
|
|
44
|
+
* @param value - The value to check.
|
|
45
|
+
* @returns `true` if the value is a positive integer, otherwise `false`.
|
|
46
|
+
*/
|
|
47
|
+
function isPositiveInteger(value) {
|
|
48
|
+
return isInteger(value) && value > 0;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* * Type guard to check if a value is a boolean.
|
|
52
|
+
* @param value - The value to check.
|
|
53
|
+
* @returns `true` if the value is a boolean, otherwise `false`.
|
|
54
|
+
*/
|
|
55
|
+
function isBoolean(value) {
|
|
56
|
+
return typeof value === "boolean";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* * Type guard to check if a value is null.
|
|
60
|
+
* @param value - The value to check.
|
|
61
|
+
* @returns `true` if the value is null, otherwise `false`.
|
|
62
|
+
*/
|
|
63
|
+
function isNull(value) {
|
|
64
|
+
return value === null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* * Type guard to check if a value is undefined.
|
|
68
|
+
* @param value - The value to check.
|
|
69
|
+
* @returns `true` if the value is undefined, otherwise `false`.
|
|
70
|
+
*/
|
|
71
|
+
function isUndefined(value) {
|
|
72
|
+
return value === void 0;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* * Type guard to check if a value is a symbol.
|
|
76
|
+
* @param value - The value to check.
|
|
77
|
+
* @returns `true` if the value is a symbol, otherwise `false`.
|
|
78
|
+
*/
|
|
79
|
+
function isSymbol(value) {
|
|
80
|
+
return typeof value === "symbol";
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* * Type guard to check if a value is a BigInt.
|
|
84
|
+
* @param value - The value to check.
|
|
85
|
+
* @returns `true` if the value is a BigInt, otherwise `false`.
|
|
86
|
+
*/
|
|
87
|
+
function isBigInt(value) {
|
|
88
|
+
return typeof value === "bigint";
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* * Type guard to check if a value is a primitive (i.e. `string | number | boolean | symbol | bigint | null | undefined`).
|
|
92
|
+
* @param value - The value to check.
|
|
93
|
+
* @returns `true` if the value is a primitive, otherwise `false`.
|
|
94
|
+
*/
|
|
95
|
+
function isPrimitive(value) {
|
|
96
|
+
return value === null || [
|
|
97
|
+
"string",
|
|
98
|
+
"number",
|
|
99
|
+
"boolean",
|
|
100
|
+
"symbol",
|
|
101
|
+
"bigint",
|
|
102
|
+
"undefined"
|
|
103
|
+
].includes(typeof value);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* * Type guard to check if a value is a normal primitive (i.e. `string | number | boolean | null | undefined`).
|
|
107
|
+
* @param value - The value to check.
|
|
108
|
+
* @returns `true` if the value is a primitive, otherwise `false`.
|
|
109
|
+
*/
|
|
110
|
+
function isNormalPrimitive(value) {
|
|
111
|
+
return value == null || [
|
|
112
|
+
"string",
|
|
113
|
+
"number",
|
|
114
|
+
"boolean",
|
|
115
|
+
"undefined"
|
|
116
|
+
].includes(typeof value);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* * Type guard to check if a value is a non-empty string.
|
|
120
|
+
* @param value - The value to check.
|
|
121
|
+
* @returns `true` if the value is a non-empty string, otherwise `false`.
|
|
122
|
+
*/
|
|
123
|
+
function isNonEmptyString(value) {
|
|
124
|
+
return isString(value) && value?.length > 0;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* * Type guard to check if a value is falsy.
|
|
128
|
+
* @param value - The value to check.
|
|
129
|
+
* @returns `true` if the value is falsy, otherwise `false`.
|
|
130
|
+
*/
|
|
131
|
+
function isFalsy(value) {
|
|
132
|
+
return !value;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* * Type guard to check if a value is truthy.
|
|
136
|
+
* @param value - The value to check.
|
|
137
|
+
* @returns `true` if the value is truthy (not null or undefined), otherwise `false`.
|
|
138
|
+
*/
|
|
139
|
+
function isTruthy(value) {
|
|
140
|
+
return Boolean(value);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
export { isNonEmptyString as a, isNumber as c, isString as d, isSymbol as f, isInteger as i, isPositiveInteger as l, isUndefined as m, isBoolean as n, isNormalPrimitive as o, isTruthy as p, isFalsy as r, isNull as s, isBigInt as t, isPrimitive as u };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 - present Nazmul Hassan
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { g as UUIDVersion, m as UUID } from "./hash-B6JPEyAz.mjs";
|
|
18
|
+
|
|
19
|
+
//#region src/guards/specials.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* * Type guard to check if a value is a valid email string.
|
|
22
|
+
* @param value - The value to check.
|
|
23
|
+
* @returns `true` if the value is a valid email, otherwise `false`.
|
|
24
|
+
*/
|
|
25
|
+
declare function isEmail(value: unknown): value is string;
|
|
26
|
+
/**
|
|
27
|
+
* * Type guard to check if a value is an array of valid email strings.
|
|
28
|
+
* @param value - The value to check.
|
|
29
|
+
* @returns `true` if the value is an array of valid email strings, otherwise `false`.
|
|
30
|
+
*/
|
|
31
|
+
declare function isEmailArray(value: unknown): value is string[];
|
|
32
|
+
/**
|
|
33
|
+
* * Type guard to check if a value is a valid date string.
|
|
34
|
+
* @param value - The value to check.
|
|
35
|
+
* @returns `true` if the value is a valid date string, otherwise `false`.
|
|
36
|
+
*/
|
|
37
|
+
declare function isDateString(value: unknown): value is string;
|
|
38
|
+
/**
|
|
39
|
+
* * Type guard to check if a value is a valid UUID (`RFC4122` `v1`-`v8`).
|
|
40
|
+
* @param value - The value to check.
|
|
41
|
+
* @returns `true` if the value matches standard UUID pattern, otherwise `false`.
|
|
42
|
+
*/
|
|
43
|
+
declare function isUUID(value: unknown): value is UUID<UUIDVersion>;
|
|
44
|
+
/**
|
|
45
|
+
* * Type guard to check if the code is running in a browser environment.
|
|
46
|
+
* @returns `true` if the code is running in a browser, otherwise `false`.
|
|
47
|
+
*/
|
|
48
|
+
declare function isBrowser(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* * Type guard to check if the code is running in a Node.js environment.
|
|
51
|
+
* @returns `true` if the code is running in Node.js, otherwise `false`.
|
|
52
|
+
*/
|
|
53
|
+
declare function isNode(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* * Type guard to check if a value is a valid URL.
|
|
56
|
+
* @param value - The value to check.
|
|
57
|
+
* @returns `true` if the value is a valid URL, otherwise `false`.
|
|
58
|
+
*/
|
|
59
|
+
declare function isURL(value: unknown): value is string;
|
|
60
|
+
/**
|
|
61
|
+
* * Type guard to check if a value is a valid Base64 encoded string.
|
|
62
|
+
* @param value - The value to check.
|
|
63
|
+
* @returns `true` if the value is a valid Base64 string, otherwise `false`.
|
|
64
|
+
*/
|
|
65
|
+
declare function isBase64(value: unknown): value is string;
|
|
66
|
+
/**
|
|
67
|
+
* * Type guard to check if a value is a valid hexadecimal byte sequence.
|
|
68
|
+
* @param value - The value to check, spaced between bytes or un-spaced.
|
|
69
|
+
* @returns `true` if the value is a valid hexadecimal byte sequence, otherwise `false`.
|
|
70
|
+
*/
|
|
71
|
+
declare function isHexString(value: unknown): value is string;
|
|
72
|
+
/**
|
|
73
|
+
* * Type guard to check if a value is a valid binary byte sequence.
|
|
74
|
+
* @param value - The value to check, spaced between bytes or un-spaced.
|
|
75
|
+
* @returns `true` if the value is a valid binary byte sequence, otherwise `false`.
|
|
76
|
+
*/
|
|
77
|
+
declare function isBinaryString(value: unknown): value is string;
|
|
78
|
+
/**
|
|
79
|
+
* * Type guard to check if a value is a valid phone number.
|
|
80
|
+
* @param value - The value to check.
|
|
81
|
+
* @returns `true` if the value is a valid phone number, otherwise `false`.
|
|
82
|
+
*/
|
|
83
|
+
declare function isPhoneNumber(value: unknown): value is string;
|
|
84
|
+
/**
|
|
85
|
+
* * Type guard to check if a value is a valid IP address (IPv4 or IPv6).
|
|
86
|
+
* @param value - The value to check.
|
|
87
|
+
* @returns `true` if the value is a valid IP address, otherwise `false`.
|
|
88
|
+
*/
|
|
89
|
+
declare function isIPAddress(value: unknown): value is string;
|
|
90
|
+
/**
|
|
91
|
+
* * Type guard to check if the current environment matches a given string.
|
|
92
|
+
* @param env - The expected environment (e.g., "production", "development").
|
|
93
|
+
* @returns `true` if the value is a numeric string parsable by `Number()`, otherwise `false`.
|
|
94
|
+
*/
|
|
95
|
+
declare function isEnvironment(env: string): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* * Type guard to check if a value is a string representing a finite number.
|
|
98
|
+
*
|
|
99
|
+
* @remarks
|
|
100
|
+
* - Accepts strings like: `"42"`, `" -5.5 "`, `"0.123"`, `"-0"`, `"1e5"`.
|
|
101
|
+
* - Rejects strings like: `"NaN"`, `"Infinity"`, `"-Infinity"`, `"abc"`, `""`, `"42abc"`.
|
|
102
|
+
*
|
|
103
|
+
* @param value - The value to test.
|
|
104
|
+
* @returns `true` if the value is a string that fully represents a finite number.
|
|
105
|
+
*/
|
|
106
|
+
declare function isNumericString(value: unknown): value is `${number}`;
|
|
107
|
+
//#endregion
|
|
108
|
+
export { isEmail as a, isHexString as c, isNumericString as d, isPhoneNumber as f, isDateString as i, isIPAddress as l, isUUID as m, isBinaryString as n, isEmailArray as o, isURL as p, isBrowser as r, isEnvironment as s, isBase64 as t, isNode as u };
|