toolbox-x 1.2.1 → 2.0.1
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/{Color-Dsut0Bex.d.cts → Color-BCsnSEmt.d.cts} +1 -1
- package/dist/{Color-DCfoQk_-.d.mts → Color-CKmhtXdG.d.mts} +1 -1
- package/dist/{Stylog-DXZtHAbp.d.mts → Stylog-CXpN-oeY.d.mts} +5 -5
- package/dist/{Stylog-TyLCTRtT.d.cts → Stylog-DJOVxym_.d.cts} +5 -5
- package/dist/{area-CcRQ6TfR.d.cts → area-CHhwLR12.d.cts} +3 -3
- package/dist/{area-CvSC96va.d.mts → area-DOqFLNcr.d.mts} +3 -3
- package/dist/{array-B6jWzJ4F.d.mts → array-BNbTIBni.d.mts} +1 -1
- package/dist/{array-CqDu610k.d.cts → array-CL3apdfa.d.cts} +1 -1
- package/dist/{basics-KobRNhV-.d.cts → basics-B9aytOct.d.cts} +5 -5
- package/dist/{basics-V5M2oltn.d.mts → basics-BNQqY5WD.d.mts} +5 -5
- package/dist/{basics-K8BDSYD6.cjs → basics-CJmdhXoo.cjs} +567 -14
- package/dist/{basics-1_M7UvCn.mjs → basics-CebgkY-n.mjs} +449 -16
- package/dist/{case-uKFzt5TY.cjs → case-Bd7QLHYw.cjs} +3 -3
- package/dist/{case-KdrBKjjK.d.mts → case-Bkkm6Mqi.d.mts} +12 -12
- package/dist/{case-BQwn5N-k.mjs → case-DBC4Rj0h.mjs} +3 -3
- package/dist/{case--Vjea9DS.d.cts → case-DFD3Ml1p.d.cts} +12 -12
- package/dist/change-case.cjs +1 -1
- package/dist/change-case.d.cts +1 -1
- package/dist/change-case.d.mts +1 -1
- package/dist/change-case.mjs +1 -1
- package/dist/colors.d.cts +2 -2
- package/dist/colors.d.mts +2 -2
- package/dist/{constants-C4RW7Lei.cjs → constants-Dz5vxNQ9.cjs} +37 -0
- package/dist/{constants-rNhoy4DH.mjs → constants-j-iXjwDl.mjs} +32 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.mts +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/converter.cjs +2 -2
- package/dist/converter.d.cts +2 -2
- package/dist/converter.d.mts +2 -2
- package/dist/converter.mjs +2 -2
- package/dist/date.cjs +51 -10
- package/dist/date.d.cts +22 -5
- package/dist/date.d.mts +22 -5
- package/dist/date.mjs +49 -11
- package/dist/dom.cjs +5 -6
- package/dist/dom.d.cts +3 -3
- package/dist/dom.d.mts +3 -3
- package/dist/dom.mjs +4 -5
- package/dist/{form-DoQGMTOc.d.mts → form-CC9T9WnX.d.cts} +2 -2
- package/dist/{form-mP-nl8EC.d.cts → form-CheKmgjj.d.mts} +2 -2
- package/dist/guards-B2s2wlVN.mjs +425 -0
- package/dist/{guards-C0smSAKC.mjs → guards-BK1QuvFZ.mjs} +2 -2
- package/dist/{guards-ClGDJrQp.cjs → guards-Bsh6Bfdq.cjs} +2 -2
- package/dist/{guards-0VjySrPM.cjs → guards-DMJcjPDt.cjs} +279 -3
- package/dist/guards.cjs +9 -8
- package/dist/guards.d.cts +6 -5
- package/dist/guards.d.mts +6 -5
- package/dist/guards.mjs +5 -5
- package/dist/{hash-BcoFHSu1.d.cts → hash-C0Wr7H8v.d.mts} +1 -1
- package/dist/{hash-GYRx2ee_.d.mts → hash-DJ8b9VHB.d.cts} +1 -1
- package/dist/hash.cjs +8 -8
- package/dist/hash.d.cts +8 -8
- package/dist/hash.d.mts +8 -8
- package/dist/hash.mjs +4 -5
- package/dist/{http-status-xrlR-LlB.d.mts → http-status-BSee6mB5.d.mts} +1 -1
- package/dist/{http-status-C0DOpCDf.d.cts → http-status-DJn87B_Y.d.cts} +1 -1
- package/dist/http-status.cjs +4 -4
- package/dist/http-status.d.cts +6 -6
- package/dist/http-status.d.mts +6 -6
- package/dist/http-status.mjs +4 -4
- package/dist/index-01oaUuP6.d.mts +292 -0
- package/dist/index-CgwlWrZM.d.cts +292 -0
- package/dist/index.cjs +67 -248
- package/dist/index.d.cts +25 -280
- package/dist/index.d.mts +25 -280
- package/dist/index.mjs +11 -194
- package/dist/{object-ChFVh95z.d.cts → object-Mglyg4AW.d.cts} +28 -1
- package/dist/{object-ChFVh95z.d.mts → object-Mglyg4AW.d.mts} +28 -1
- package/dist/{objectify-DEnFpPt1.mjs → objectify-CQa8gQib.mjs} +3 -4
- package/dist/{objectify-DewBSJP_.cjs → objectify-xQvZS3UI.cjs} +5 -6
- package/dist/paginator.d.cts +1 -1
- package/dist/paginator.d.mts +1 -1
- package/dist/{parse-DovagZFA.cjs → parse-BWu3UbOk.cjs} +4 -4
- package/dist/{parse-BhZ6-tKg.mjs → parse-CNDdS-sy.mjs} +4 -4
- package/dist/{pluralizer-CdG-VJ6t.d.cts → pluralizer-BGMC8LLz.d.cts} +1 -1
- package/dist/{pluralizer-D2Lh8CdU.d.mts → pluralizer-CQNzRhwR.d.mts} +1 -1
- package/dist/pluralizer.cjs +6 -6
- package/dist/pluralizer.d.cts +6 -6
- package/dist/pluralizer.d.mts +6 -6
- package/dist/pluralizer.mjs +6 -6
- package/dist/{specials-Cye93-uo.mjs → specials-Hq5Ncd6y.mjs} +2 -2
- package/dist/{specials-BM6cx43o.cjs → specials-dkYP1Nh2.cjs} +2 -2
- package/dist/{string-Dq2b8rcN.d.cts → string-BDwBuik3.d.cts} +4 -2
- package/dist/{string-CkwTVFeL.d.mts → string-_1ImwUJT.d.mts} +4 -2
- package/dist/stylog.cjs +5 -5
- package/dist/stylog.d.cts +2 -2
- package/dist/stylog.d.mts +2 -2
- package/dist/stylog.mjs +5 -5
- package/dist/types/array.d.cts +1 -1
- package/dist/types/array.d.mts +1 -1
- package/dist/types/colors.d.cts +1 -1
- package/dist/types/colors.d.mts +1 -1
- package/dist/types/converter.d.cts +1 -1
- package/dist/types/converter.d.mts +1 -1
- package/dist/types/date.d.cts +2 -2
- package/dist/types/date.d.mts +2 -2
- package/dist/types/form.d.cts +1 -1
- package/dist/types/form.d.mts +1 -1
- package/dist/types/hash.d.cts +1 -1
- package/dist/types/hash.d.mts +1 -1
- package/dist/types/http-status.d.cts +1 -1
- package/dist/types/http-status.d.mts +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/number.d.cts +1 -1
- package/dist/types/number.d.mts +1 -1
- package/dist/types/object.d.cts +2 -2
- package/dist/types/object.d.mts +2 -2
- package/dist/types/pluralizer.d.cts +1 -1
- package/dist/types/pluralizer.d.mts +1 -1
- package/dist/types/string.d.cts +2 -2
- package/dist/types/string.d.mts +2 -2
- package/dist/types/stylog.d.cts +1 -1
- package/dist/types/stylog.d.mts +1 -1
- package/dist/types/utils.d.cts +1 -1
- package/dist/types/utils.d.mts +1 -1
- package/dist/{utilities-CzyXCRHM.cjs → utilities-CWV1GPGY.cjs} +1 -1
- package/dist/{utilities-B9axOvOX.mjs → utilities-DPscNbS1.mjs} +1 -1
- package/dist/{uuid-DgTBxcVu.d.cts → uuid-CiJtSUbo.d.cts} +3 -3
- package/dist/{uuid-Yc3Uu8qr.d.mts → uuid-D-gjPs4Q.d.mts} +3 -3
- package/dist/verbalizer.cjs +3 -3
- package/dist/verbalizer.d.cts +3 -3
- package/dist/verbalizer.d.mts +3 -3
- package/dist/verbalizer.mjs +3 -3
- package/package.json +7 -6
- package/dist/guards-DeO4ukiK.mjs +0 -221
- package/dist/utils-BxguWSoa.cjs +0 -568
- package/dist/utils-DXovsTKs.mjs +0 -449
|
@@ -14,9 +14,433 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { a as isNonEmptyString, d as isString } from "./primitives-Djsevc69.mjs";
|
|
18
|
-
import { E as isObjectWithKeys, c as isHexString, m as isUUID } from "./specials-
|
|
17
|
+
import { a as isNonEmptyString, c as isNumber, d as isString, m as isUndefined, n as isBoolean, u as isPrimitive } from "./primitives-Djsevc69.mjs";
|
|
18
|
+
import { C as isMethodDescriptor, E as isObjectWithKeys, T as isObject, b as isFunction, c as isHexString, d as isNumericString, g as isArrayOfType, h as isArray, j as isValidArray, m as isUUID, w as isNotEmptyObject } from "./specials-Hq5Ncd6y.mjs";
|
|
19
|
+
import { a as normalizeNumber } from "./utilities-DPscNbS1.mjs";
|
|
20
|
+
import { t as isDateLike } from "./guards-BK1QuvFZ.mjs";
|
|
19
21
|
|
|
22
|
+
//#region src/array/helpers.ts
|
|
23
|
+
/**
|
|
24
|
+
* Safely resolves value of nested key (dot-notation key like `"user.city"`).
|
|
25
|
+
*
|
|
26
|
+
* @param obj - The source object
|
|
27
|
+
* @param path - The nested path string (e.g. `"user.city"`)
|
|
28
|
+
* @returns The resolved value or `undefined`
|
|
29
|
+
*/
|
|
30
|
+
function _resolveNestedKey(obj, path) {
|
|
31
|
+
if (isNotEmptyObject(obj)) return path?.split(".").reduce((acc, key) => {
|
|
32
|
+
if (isNotEmptyObject(acc)) return acc[key];
|
|
33
|
+
}, obj);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves a numeric value from a nested property (dot-notation key like 'user.income.tax').
|
|
37
|
+
* Falls back to 0 if value is not a number or numeric string.
|
|
38
|
+
*
|
|
39
|
+
* @param obj - The source object to read from.
|
|
40
|
+
* @param path - The dot-notation path string like 'user.income.tax'.
|
|
41
|
+
* @returns The numeric value at that path, or 0 if not valid.
|
|
42
|
+
*/
|
|
43
|
+
function _getNumericProp(obj, path) {
|
|
44
|
+
return normalizeNumber(_resolveNestedKey(obj, path)) ?? 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/array/sort.ts
|
|
49
|
+
/**
|
|
50
|
+
* Compare two strings using natural sorting (e.g., `"file2"` < `"file10"`).
|
|
51
|
+
* - Optionally supports case-insensitive and locale-aware string chunk comparisons.
|
|
52
|
+
*
|
|
53
|
+
* @param a - The first string to compare.
|
|
54
|
+
* @param b - The second string to compare.
|
|
55
|
+
* @param options - Optional settings to configure comparison behavior.
|
|
56
|
+
* @returns A negative number if `a` comes before `b`, a positive number if `a` comes after `b`, or 0 if equal.
|
|
57
|
+
*/
|
|
58
|
+
function naturalSort(a, b, options) {
|
|
59
|
+
const { caseInsensitive = true, localeAware = false } = options || {};
|
|
60
|
+
/**
|
|
61
|
+
* * Splits a string into an array of number and non-number chunks.
|
|
62
|
+
* @param str - The string to split.
|
|
63
|
+
* @returns An array of string and number parts.
|
|
64
|
+
*/
|
|
65
|
+
const _createChunks = (str) => {
|
|
66
|
+
const chunks = [];
|
|
67
|
+
let current = "";
|
|
68
|
+
let isNumeric = false;
|
|
69
|
+
for (const char of str) {
|
|
70
|
+
const charIsNum = !Number.isNaN(Number(char));
|
|
71
|
+
if (current?.length === 0) {
|
|
72
|
+
current = char;
|
|
73
|
+
isNumeric = charIsNum;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (charIsNum === isNumeric) current += char;
|
|
77
|
+
else {
|
|
78
|
+
chunks?.push(isNumeric ? Number(current) : current);
|
|
79
|
+
current = char;
|
|
80
|
+
isNumeric = charIsNum;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (current?.length > 0) chunks?.push(isNumeric ? Number(current) : current);
|
|
84
|
+
return chunks;
|
|
85
|
+
};
|
|
86
|
+
const aChunks = _createChunks(a);
|
|
87
|
+
const bChunks = _createChunks(b);
|
|
88
|
+
for (let i = 0; i < Math.min(aChunks?.length, bChunks?.length); i++) {
|
|
89
|
+
let aChunk = aChunks[i];
|
|
90
|
+
let bChunk = bChunks[i];
|
|
91
|
+
if (caseInsensitive && isString(aChunk) && isString(bChunk)) {
|
|
92
|
+
aChunk = aChunk?.toLowerCase();
|
|
93
|
+
bChunk = bChunk?.toLowerCase();
|
|
94
|
+
}
|
|
95
|
+
if (typeof aChunk !== typeof bChunk) return isString(aChunk) ? 1 : -1;
|
|
96
|
+
if (aChunk !== bChunk) {
|
|
97
|
+
if (isNumber(aChunk) && isNumber(bChunk)) return aChunk - bChunk;
|
|
98
|
+
if (isString(aChunk) && isString(bChunk)) {
|
|
99
|
+
if (localeAware) {
|
|
100
|
+
const cmp = aChunk.localeCompare(bChunk, void 0, { sensitivity: caseInsensitive ? "accent" : "variant" });
|
|
101
|
+
if (cmp !== 0) return cmp;
|
|
102
|
+
}
|
|
103
|
+
return aChunk < bChunk ? -1 : 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return aChunks?.length - bChunks?.length;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* * Sorts an array of strings, numbers, booleans, or objects based on the provided options.
|
|
111
|
+
*
|
|
112
|
+
* @param array - The array to sort.
|
|
113
|
+
* @param options - Sorting options.
|
|
114
|
+
* @returns The sorted array.
|
|
115
|
+
*/
|
|
116
|
+
function sortAnArray(array, options) {
|
|
117
|
+
if (!isValidArray(array)) return array;
|
|
118
|
+
if (isArrayOfType(array, isString)) return [...array].sort((a, b) => options?.sortOrder === "desc" ? naturalSort(b, a) : naturalSort(a, b));
|
|
119
|
+
if (isArrayOfType(array, isNumber)) return [...array].sort((a, b) => options?.sortOrder === "desc" ? b - a : a - b);
|
|
120
|
+
if (isArrayOfType(array, isBoolean)) return [...array].sort((a, b) => options?.sortOrder === "desc" ? Number(b) - Number(a) : Number(a) - Number(b));
|
|
121
|
+
if (isArrayOfType(array, isObject) && options && "sortByField" in options) return [...array].sort((a, b) => {
|
|
122
|
+
const _getKeyValue = (obj, path) => {
|
|
123
|
+
return path.split(".").reduce((acc, key) => acc?.[key], obj);
|
|
124
|
+
};
|
|
125
|
+
const keyA = _getKeyValue(a, options?.sortByField);
|
|
126
|
+
const keyB = _getKeyValue(b, options?.sortByField);
|
|
127
|
+
if (keyA == null || keyB == null) return keyA == null ? 1 : -1;
|
|
128
|
+
if (isString(keyA) && isString(keyB)) return options?.sortOrder === "desc" ? naturalSort(keyB, keyA) : naturalSort(keyA, keyB);
|
|
129
|
+
if (isNumber(keyA) && isNumber(keyB)) return options?.sortOrder === "desc" ? keyB - keyA : keyA - keyB;
|
|
130
|
+
if (isBoolean(keyA) && isBoolean(keyB)) return options?.sortOrder === "desc" ? Number(keyB) - Number(keyA) : Number(keyA) - Number(keyB);
|
|
131
|
+
return 0;
|
|
132
|
+
});
|
|
133
|
+
return [...array];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/utils/index.ts
|
|
138
|
+
/**
|
|
139
|
+
* * Deeply compare two values (arrays, objects, or primitive values).
|
|
140
|
+
*
|
|
141
|
+
* @param a First value to compare.
|
|
142
|
+
* @param b Second value to compare.
|
|
143
|
+
* @returns Whether the values are deeply equal.
|
|
144
|
+
*/
|
|
145
|
+
const isDeepEqual = (a, b) => {
|
|
146
|
+
if (a === b) return true;
|
|
147
|
+
if (typeof a !== typeof b) return false;
|
|
148
|
+
if (a === null || b === null) return a === b;
|
|
149
|
+
if (isArray(a) && isArray(b)) {
|
|
150
|
+
if (a?.length !== b?.length) return false;
|
|
151
|
+
return a?.every((element, index) => isDeepEqual(element, b?.[index]));
|
|
152
|
+
}
|
|
153
|
+
if (isObject(a) && isObject(b)) {
|
|
154
|
+
const aKeys = Object.keys(a);
|
|
155
|
+
const bKeys = Object.keys(b);
|
|
156
|
+
if (aKeys?.length !== bKeys?.length) return false;
|
|
157
|
+
return aKeys?.every((key) => isDeepEqual(a?.[key], b?.[key]));
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* * Converts an array of primitive values or objects to a string using a separator or target key.
|
|
163
|
+
*
|
|
164
|
+
* @param array Array to convert.
|
|
165
|
+
* @param options Options for separator or key extraction from objects.
|
|
166
|
+
* @returns String representation of array values.
|
|
167
|
+
*/
|
|
168
|
+
function convertArrayToString(array, options) {
|
|
169
|
+
if (!isValidArray(array)) return "";
|
|
170
|
+
const { separator = ", " } = options ?? {};
|
|
171
|
+
if (isArrayOfType(array, isPrimitive)) return array?.join(separator);
|
|
172
|
+
else if (isArrayOfType(array, isNotEmptyObject)) if (options && "target" in options) return array?.map((el) => _resolveNestedKey(el, options?.target))?.join(separator);
|
|
173
|
+
else return "";
|
|
174
|
+
return "";
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* * A generic debounce function that delays the execution of a callback.
|
|
178
|
+
*
|
|
179
|
+
* @param callback - The function to debounce.
|
|
180
|
+
* @param delay - The delay in milliseconds. Default is `300ms`.
|
|
181
|
+
* @returns A debounced version of the callback function.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* const debouncedSearch = debounceAction((query: string) => {
|
|
185
|
+
* console.log(`Searching for: ${query}`);
|
|
186
|
+
* }, 300);
|
|
187
|
+
*
|
|
188
|
+
* debouncedSearch('laptop'); // Executes after 300ms of inactivity.
|
|
189
|
+
*/
|
|
190
|
+
function debounceAction(callback, delay = 300) {
|
|
191
|
+
let timeoutId;
|
|
192
|
+
return (...args) => {
|
|
193
|
+
clearTimeout(timeoutId);
|
|
194
|
+
timeoutId = setTimeout(() => {
|
|
195
|
+
callback(...args);
|
|
196
|
+
}, delay);
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* * A generic throttle function that ensures a callback is executed at most once per specified interval.
|
|
201
|
+
*
|
|
202
|
+
* @param callback - The function to throttle.
|
|
203
|
+
* @param delay - The delay in milliseconds. Default is `150ms`.
|
|
204
|
+
* @returns A throttled version of the callback function.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* const throttledResize = throttleAction(() => {
|
|
208
|
+
* console.log('Resized');
|
|
209
|
+
* }, 300);
|
|
210
|
+
*
|
|
211
|
+
* window.addEventListener('resize', throttledResize);
|
|
212
|
+
*/
|
|
213
|
+
function throttleAction(callback, delay = 150) {
|
|
214
|
+
let lastCall = 0;
|
|
215
|
+
return (...args) => {
|
|
216
|
+
const now = Date.now();
|
|
217
|
+
if (now - lastCall >= delay) {
|
|
218
|
+
lastCall = now;
|
|
219
|
+
callback(...args);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* * Retrieves the names of all instance methods defined directly on a class prototype.
|
|
225
|
+
*
|
|
226
|
+
* @param cls - The class constructor (not an instance).
|
|
227
|
+
* @returns A sorted array of instance method names.
|
|
228
|
+
*/
|
|
229
|
+
function getInstanceMethodNames(cls) {
|
|
230
|
+
const prototype = cls.prototype;
|
|
231
|
+
return sortAnArray(Object.getOwnPropertyNames(prototype).filter((method) => {
|
|
232
|
+
if (method === "constructor") return false;
|
|
233
|
+
return isMethodDescriptor(Object.getOwnPropertyDescriptor(prototype, method));
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* * Retrieves the names of all static methods defined directly on a class constructor.
|
|
238
|
+
*
|
|
239
|
+
* @param cls - The class constructor (not an instance).
|
|
240
|
+
* @returns A sorted array of static method names.
|
|
241
|
+
*/
|
|
242
|
+
function getStaticMethodNames(cls) {
|
|
243
|
+
return sortAnArray(Object.getOwnPropertyNames(cls).filter((method) => {
|
|
244
|
+
return method !== "prototype" && method !== "name" && method !== "length";
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* * Counts the number of instance methods defined directly on a class prototype.
|
|
249
|
+
*
|
|
250
|
+
* @param cls - The class constructor (not an instance).
|
|
251
|
+
* @returns The number of instance methods defined on the class prototype.
|
|
252
|
+
*/
|
|
253
|
+
function countInstanceMethods(cls) {
|
|
254
|
+
return getInstanceMethodNames(cls)?.length;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* * Counts the number of static methods defined directly on a class constructor.
|
|
258
|
+
*
|
|
259
|
+
* @param cls - The class constructor (not an instance).
|
|
260
|
+
* @returns The number of static methods defined on the class constructor.
|
|
261
|
+
*/
|
|
262
|
+
function countStaticMethods(cls) {
|
|
263
|
+
return getStaticMethodNames(cls)?.length;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* * Retrieves the names of all instance getters defined directly on a class prototype.
|
|
267
|
+
*
|
|
268
|
+
* @param cls - The class constructor (not an instance).
|
|
269
|
+
* @returns A sorted array of instance getter names.
|
|
270
|
+
*/
|
|
271
|
+
function getInstanceGetterNames(cls) {
|
|
272
|
+
const descriptors = Object.getOwnPropertyDescriptors(cls.prototype);
|
|
273
|
+
return sortAnArray(Object.entries(descriptors).filter(([key, desc]) => isFunction(desc.get) && key !== "constructor").map(([key]) => key));
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* * Retrieves the names of all static getters defined directly on a class constructor.
|
|
277
|
+
*
|
|
278
|
+
* @param cls - The class constructor (not an instance).
|
|
279
|
+
* @returns A sorted array of static getter names.
|
|
280
|
+
*/
|
|
281
|
+
function getStaticGetterNames(cls) {
|
|
282
|
+
return sortAnArray(Object.entries(Object.getOwnPropertyDescriptors(cls)).filter(([key, desc]) => typeof desc.get === "function" && key !== "prototype").map(([key]) => key));
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* * Gathers detailed information about the instance and static methods of a class.
|
|
286
|
+
*
|
|
287
|
+
* @param cls - The class constructor (not an instance).
|
|
288
|
+
* @returns An object containing names and counts of instance and static methods.
|
|
289
|
+
*/
|
|
290
|
+
function getClassDetails(cls) {
|
|
291
|
+
const instanceNames = getInstanceMethodNames(cls);
|
|
292
|
+
const staticNames = getStaticMethodNames(cls);
|
|
293
|
+
const instanceGetters = getInstanceGetterNames(cls);
|
|
294
|
+
const staticGetters = getStaticGetterNames(cls);
|
|
295
|
+
return {
|
|
296
|
+
instanceMethods: instanceNames,
|
|
297
|
+
staticMethods: staticNames,
|
|
298
|
+
instanceGetters,
|
|
299
|
+
staticGetters,
|
|
300
|
+
instanceCount: instanceNames?.length,
|
|
301
|
+
staticCount: staticNames?.length,
|
|
302
|
+
totalGetters: instanceGetters?.length + staticGetters?.length,
|
|
303
|
+
totalMethods: instanceNames?.length + staticNames?.length
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* * Create a deterministic JSON string representation of any value.
|
|
308
|
+
* - The output format matches standard JSON but with guaranteed sorted keys.
|
|
309
|
+
*
|
|
310
|
+
* @remarks
|
|
311
|
+
* - This function guarantees **stable, repeatable output** by:
|
|
312
|
+
* - Sorting all object keys alphabetically.
|
|
313
|
+
* - Recursively stabilizing nested objects and arrays.
|
|
314
|
+
* - Converting all `undefined` values into `null` so the output remains valid JSON.
|
|
315
|
+
* - Converting date-like objects (`Date`, `Chronos`, `Moment.js`, `Day.js`, `Luxon`, `JS-Joda`, `Temporal`) **in the same way that {@link JSON.stringify} would serialize them**, ensuring predictable and JSON-compliant output.
|
|
316
|
+
* - Falling back to native JSON serialization for primitives.
|
|
317
|
+
*
|
|
318
|
+
* - **Useful for:**
|
|
319
|
+
* - Hash generation (e.g., signatures, cache keys)
|
|
320
|
+
* - Deep equality checks
|
|
321
|
+
* - Producing predictable output across environments
|
|
322
|
+
*
|
|
323
|
+
* @param obj - The value to stringify into a deterministic JSON string.
|
|
324
|
+
* @returns A stable, deterministic string representation of the input.
|
|
325
|
+
*/
|
|
326
|
+
function stableStringify(obj) {
|
|
327
|
+
const _replacer = (_, v) => v === void 0 ? null : v;
|
|
328
|
+
if (isNotEmptyObject(obj)) return "{" + Object.keys(obj).sort().map((k) => JSON.stringify(k, _replacer) + ":" + (isDateLike(obj[k]) ? JSON.stringify(obj[k]) : stableStringify(obj[k]))).join(",") + "}";
|
|
329
|
+
if (isValidArray(obj)) return "[" + obj.map((v) => stableStringify(v)).join(",") + "]";
|
|
330
|
+
return JSON.stringify(obj, _replacer);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* * Remove trailing or leading garbage characters **after/before JSON object or array**.
|
|
334
|
+
* @param str String to sanitize/strip.
|
|
335
|
+
* @returns Sanitized/stripped JSON string.
|
|
336
|
+
*/
|
|
337
|
+
function stripJsonEdgeGarbage(str) {
|
|
338
|
+
if (!isNonEmptyString(str)) return "";
|
|
339
|
+
const lastIdx = Math.max(str.lastIndexOf("}"), str.lastIndexOf("]"));
|
|
340
|
+
const _idxOf = (sym) => str.indexOf(sym) !== -1 ? str.indexOf(sym) : Infinity;
|
|
341
|
+
const firstIdx = Math.min(_idxOf("{"), _idxOf("["));
|
|
342
|
+
if (lastIdx === -1 || firstIdx === Infinity) return str;
|
|
343
|
+
return str.slice(firstIdx, lastIdx + 1);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* * Parses any valid JSON string, optionally converting stringified primitives inside (nested) arrays or objects.
|
|
347
|
+
*
|
|
348
|
+
* @typeParam T - Expected return type (default is unknown).
|
|
349
|
+
* @param value - The JSON string to parse.
|
|
350
|
+
* @param parsePrimitives - Whether to convert stringified primitives (default: `true`).
|
|
351
|
+
* @returns The parsed JSON value typed as `T`, or the original parsed value with optional primitive conversion.
|
|
352
|
+
* - Returns `{}` if parsing fails, such as when the input is malformed or invalid JSON or passing single quoted string.
|
|
353
|
+
*
|
|
354
|
+
* - *Unlike {@link https://toolbox-x.nazmul-nhb.dev/docs/utils/object/parse-json-to-object parseJsonToObject}, which ensures the root value is an object,
|
|
355
|
+
* this function returns any valid JSON structure such as arrays, strings, numbers, or objects.*
|
|
356
|
+
*
|
|
357
|
+
* This is useful when you're not sure of the root structure of the JSON, or when you expect something other than an object.
|
|
358
|
+
*
|
|
359
|
+
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/utils/object/parse-json-to-object parseJsonToObject} for strict object-only parsing.
|
|
360
|
+
*/
|
|
361
|
+
const parseJSON = (value, parsePrimitives = true) => {
|
|
362
|
+
try {
|
|
363
|
+
const parsed = JSON.parse(value);
|
|
364
|
+
return parsePrimitives ? deepParsePrimitives(parsed) : parsed;
|
|
365
|
+
} catch {
|
|
366
|
+
return {};
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* * Recursively parses primitive values inside objects and arrays.
|
|
371
|
+
*
|
|
372
|
+
* @typeParam T - Expected return type after parsing (default is unknown).
|
|
373
|
+
* @param input - Any input value to parse recursively.
|
|
374
|
+
* @returns Input with primitives (strings like "true", "123") converted, typed as `T`.
|
|
375
|
+
*/
|
|
376
|
+
function deepParsePrimitives(input) {
|
|
377
|
+
if (Array.isArray(input)) return input?.map(deepParsePrimitives);
|
|
378
|
+
if (isObject(input)) {
|
|
379
|
+
const result = {};
|
|
380
|
+
for (const [key, value] of Object.entries(input)) result[key] = deepParsePrimitives(value);
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
if (isString(input)) {
|
|
384
|
+
if (/^(true|false)$/i.test(input)) return input?.toLowerCase() === "true";
|
|
385
|
+
if (isNumericString(input)) return Number(input);
|
|
386
|
+
if (input === "null") return null;
|
|
387
|
+
if (input === "undefined") return;
|
|
388
|
+
return input;
|
|
389
|
+
}
|
|
390
|
+
return input;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* * Defines a method on any prototype — including built-in prototypes — in a safe, idempotent manner.
|
|
394
|
+
* - The method is non-enumerable by default and will not overwrite an existing method unless explicitly allowed.
|
|
395
|
+
*
|
|
396
|
+
* @param proto The target prototype object (e.g., String.prototype).
|
|
397
|
+
* @param name The method name to define on the prototype.
|
|
398
|
+
* @param impl The function implementation for the method.
|
|
399
|
+
* @param options Optional property-descriptor settings and overwrite rules.
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* // Safely augment prototype methods by extending the global interface:
|
|
403
|
+
* declare global {
|
|
404
|
+
* interface String {
|
|
405
|
+
* toBang(): string;
|
|
406
|
+
* }
|
|
407
|
+
* }
|
|
408
|
+
*
|
|
409
|
+
* // Define a custom method on String.prototype
|
|
410
|
+
* definePrototypeMethod(String.prototype, 'toBang', function (this: String) {
|
|
411
|
+
* return this.toString().concat('!');
|
|
412
|
+
* // or
|
|
413
|
+
* // return this.concat('!');
|
|
414
|
+
* });
|
|
415
|
+
*
|
|
416
|
+
* "Hi".toBang(); // "Hi!"
|
|
417
|
+
*
|
|
418
|
+
* // Attempting to redefine without overwrite option is ignored
|
|
419
|
+
* definePrototypeMethod(String.prototype, 'toBang', () => 'x'); // ignored
|
|
420
|
+
*
|
|
421
|
+
* // Overwrite intentionally using the overwrite option
|
|
422
|
+
* definePrototypeMethod(
|
|
423
|
+
* String.prototype,
|
|
424
|
+
* 'toBang',
|
|
425
|
+
* function (this: String) { return this.concat('!!!'); },
|
|
426
|
+
* { overwrite: true }
|
|
427
|
+
* );
|
|
428
|
+
*
|
|
429
|
+
* "Hi".toBang(); // "Hi!!!"
|
|
430
|
+
*/
|
|
431
|
+
function definePrototypeMethod(proto, name, impl, options) {
|
|
432
|
+
if (Object.hasOwn(proto, name) && !options?.overwrite) return;
|
|
433
|
+
Object.defineProperty(proto, name, {
|
|
434
|
+
value: function(...args) {
|
|
435
|
+
return impl.apply(this, args);
|
|
436
|
+
},
|
|
437
|
+
enumerable: options?.enumerable ?? false,
|
|
438
|
+
configurable: options?.configurable ?? false,
|
|
439
|
+
writable: options?.writable ?? true
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
//#endregion
|
|
20
444
|
//#region src/hash/utils.ts
|
|
21
445
|
/**
|
|
22
446
|
* * Generates a random hexadecimal string of the specified length.
|
|
@@ -805,13 +1229,22 @@ function _randomNode48() {
|
|
|
805
1229
|
return (parseInt(node.slice(0, 2).join(""), 16) | 1).toString(16).padStart(2, "0") + node.slice(2).join("");
|
|
806
1230
|
}
|
|
807
1231
|
/**
|
|
808
|
-
*
|
|
1232
|
+
* Fills the given {@link Uint8Array} with random values using crypto API if available, otherwise falls back to {@link Math.random}.
|
|
809
1233
|
* @param bytes Instance of {@link Uint8Array} to fill with random values.
|
|
810
|
-
* @returns
|
|
1234
|
+
* @returns Random bytes. It also mutates the {@link bytes} argument.
|
|
811
1235
|
*/
|
|
812
|
-
function
|
|
813
|
-
if (crypto?.getRandomValues) crypto.getRandomValues(bytes);
|
|
1236
|
+
function _fillWithRandomValues(bytes) {
|
|
1237
|
+
if (!isUndefined(crypto) && crypto?.getRandomValues) crypto.getRandomValues(bytes);
|
|
814
1238
|
else for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
1239
|
+
return bytes;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Generates random hex string of given byte length using crypto API if available, otherwise falls back to {@link Math.random}.
|
|
1243
|
+
* @param bytes Instance of {@link Uint8Array} to fill with random values.
|
|
1244
|
+
* @returns Hex string representation of the random bytes. It also mutates the {@link bytes} argument.
|
|
1245
|
+
*/
|
|
1246
|
+
function _bytesToRandomHex(bytes) {
|
|
1247
|
+
_fillWithRandomValues(bytes);
|
|
815
1248
|
let hex = "";
|
|
816
1249
|
for (let i = 0; i < bytes.length; i++) hex += bytes[i].toString(16).padStart(2, "0");
|
|
817
1250
|
return hex;
|
|
@@ -1031,9 +1464,9 @@ function sha1(msg) {
|
|
|
1031
1464
|
* // Returns: '7037e204b825b83553ba336a6ec35b796d505599286ae864729ed6cb33ae9fe1'
|
|
1032
1465
|
* ```
|
|
1033
1466
|
*
|
|
1034
|
-
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/
|
|
1035
|
-
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/
|
|
1036
|
-
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/
|
|
1467
|
+
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/utils/hash/encoding#sha256bytes sha256Bytes} for hashing raw bytes
|
|
1468
|
+
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/utils/hash/encoding#utf8tobytes utf8ToBytes} for converting string to bytes
|
|
1469
|
+
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/utils/hash/encoding#bytestohex bytesToHex} for converting bytes to a hexadecimal string
|
|
1037
1470
|
*/
|
|
1038
1471
|
function sha256(msg) {
|
|
1039
1472
|
if (!isString(msg)) throw new TypeError("Input must be of type string!");
|
|
@@ -1087,7 +1520,7 @@ function sha256(msg) {
|
|
|
1087
1520
|
* - `v7`: Millisecond precision; extremely high throughput may still cause rare collisions.
|
|
1088
1521
|
* - `v8`: Uses a simple timestamp + randomness layout; custom layouts are not supported here.
|
|
1089
1522
|
*
|
|
1090
|
-
* - Use {@link https://toolbox-x.nazmul-nhb.dev/docs/
|
|
1523
|
+
* - Use {@link https://toolbox-x.nazmul-nhb.dev/docs/utils/string/generate-random-id generateRandomID} for customized id generation or {@link https://toolbox-x.nazmul-nhb.dev/docs/utils/hash/random-hex randomHex} for hex-only random string with custom length.
|
|
1091
1524
|
*/
|
|
1092
1525
|
function uuid(options) {
|
|
1093
1526
|
const { version = "v4", uppercase = false } = options || {};
|
|
@@ -1242,8 +1675,8 @@ function truncateString(str, maxLength) {
|
|
|
1242
1675
|
* @param options Configuration options for random ID generation.
|
|
1243
1676
|
* @returns The generated ID string composed of the random alphanumeric string of specified length with optional `timeStamp`, `prefix`, and `suffix`, `caseOption` and `separator`.
|
|
1244
1677
|
*
|
|
1245
|
-
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/
|
|
1246
|
-
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/
|
|
1678
|
+
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/utils/hash/uuid uuid} for `uuid` generation
|
|
1679
|
+
* @see {@link https://toolbox-x.nazmul-nhb.dev/docs/utils/hash/random-hex randomHex} for random hexadecimal string generation
|
|
1247
1680
|
*
|
|
1248
1681
|
* @example
|
|
1249
1682
|
* // Generate an ID with all default options
|
|
@@ -1292,10 +1725,10 @@ function generateRandomID(options) {
|
|
|
1292
1725
|
const date = timeStamp ? Date.now() : "";
|
|
1293
1726
|
const randomString = Array.from({ length }, () => Math.random().toString(36).slice(2, 3)).join("");
|
|
1294
1727
|
const ID = [
|
|
1295
|
-
prefix
|
|
1728
|
+
prefix?.trim(),
|
|
1296
1729
|
date,
|
|
1297
1730
|
randomString,
|
|
1298
|
-
suffix
|
|
1731
|
+
suffix?.trim()
|
|
1299
1732
|
].filter(Boolean).join(separator);
|
|
1300
1733
|
switch (caseOption) {
|
|
1301
1734
|
case "upper": return ID.toUpperCase();
|
|
@@ -1304,7 +1737,7 @@ function generateRandomID(options) {
|
|
|
1304
1737
|
}
|
|
1305
1738
|
}
|
|
1306
1739
|
/**
|
|
1307
|
-
* * Trims all
|
|
1740
|
+
* * Trims all whitespaces in a string or an array of strings.
|
|
1308
1741
|
*
|
|
1309
1742
|
* @param input String or array of strings.
|
|
1310
1743
|
* @returns Trimmed string or array of strings.
|
|
@@ -1317,4 +1750,4 @@ function trimString(input) {
|
|
|
1317
1750
|
}
|
|
1318
1751
|
|
|
1319
1752
|
//#endregion
|
|
1320
|
-
export { uint8To32ArrayBE as A, bytesToUtf8 as C, intTo4BytesBE as D, hmacSha256 as E, randomHex as O, bytesToHex as S, hexToBytes as T, _constantTimeEquals as _, isUUIDv1 as a, base64ToBytes as b, isUUIDv4 as c, isUUIDv7 as d, isUUIDv8 as f, sha256 as g, sha1 as h, decodeUUID as i, utf8ToBytes as j, sha256Bytes as k, isUUIDv5 as l, md5 as m, trimString as n, isUUIDv2 as o, uuid as p, truncateString as r, isUUIDv3 as s, generateRandomID as t, isUUIDv6 as u, _padStartWith0 as v, concatBytes as w, bytesToBase64 as x, _splitByCharLength as y };
|
|
1753
|
+
export { uint8To32ArrayBE as A, getInstanceMethodNames as B, bytesToUtf8 as C, intTo4BytesBE as D, hmacSha256 as E, debounceAction as F, stableStringify as G, getStaticMethodNames as H, deepParsePrimitives as I, naturalSort as J, stripJsonEdgeGarbage as K, definePrototypeMethod as L, convertArrayToString as M, countInstanceMethods as N, randomHex as O, countStaticMethods as P, getClassDetails as R, bytesToHex as S, hexToBytes as T, isDeepEqual as U, getStaticGetterNames as V, parseJSON as W, _getNumericProp as X, sortAnArray as Y, _resolveNestedKey as Z, _constantTimeEquals as _, isUUIDv1 as a, base64ToBytes as b, isUUIDv4 as c, isUUIDv7 as d, isUUIDv8 as f, sha256 as g, sha1 as h, decodeUUID as i, utf8ToBytes as j, sha256Bytes as k, isUUIDv5 as l, md5 as m, trimString as n, isUUIDv2 as o, uuid as p, throttleAction as q, truncateString as r, isUUIDv3 as s, generateRandomID as t, isUUIDv6 as u, _padStartWith0 as v, concatBytes as w, bytesToBase64 as x, _splitByCharLength as y, getInstanceGetterNames as z };
|
|
@@ -132,11 +132,11 @@ function convertStringCase(value, format, options) {
|
|
|
132
132
|
return start.concat(body, end);
|
|
133
133
|
}
|
|
134
134
|
case "snake_case": {
|
|
135
|
-
const body = tokens.map(
|
|
135
|
+
const body = tokens.map(lowerCase).join("_");
|
|
136
136
|
return start.concat(body, end);
|
|
137
137
|
}
|
|
138
138
|
case "kebab-case": {
|
|
139
|
-
const body = tokens.map(
|
|
139
|
+
const body = tokens.map(lowerCase).join("-");
|
|
140
140
|
return start.concat(body, end);
|
|
141
141
|
}
|
|
142
142
|
case "Title Case": {
|
|
@@ -195,7 +195,7 @@ function _getDelimiterRegex(delims) {
|
|
|
195
195
|
/** Normalizes delimiters + splits the string */
|
|
196
196
|
function _normalizeDelimiters(str, delims) {
|
|
197
197
|
const delRegExp = _getDelimiterRegex(delims);
|
|
198
|
-
return str.replace(/(\p{Ll}?\d+|(?<=\p{Lu}))(\p{Lu})/gu, "$1 $2").replace(delRegExp, " ").replace(/\s+/g, " ").trim().split(" ").filter(Boolean);
|
|
198
|
+
return str.replace(/(\p{Ll}?\d+|(?<=\p{Lu}|\p{Ll}))(\p{Lu})/gu, "$1 $2").replace(delRegExp, " ").replace(/\s+/g, " ").trim().split(" ").filter(Boolean);
|
|
199
199
|
}
|
|
200
200
|
/** Capitalize a string (first letter capital, rest lowercase) */
|
|
201
201
|
function _capitalize(str) {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { B as
|
|
17
|
+
import { A as KebabCase, B as StringCaseOptions, E as DotCase, H as TrainCase, L as SentenceCase, M as PascalCase, N as PascalSnakeCase, P as PathCase, R as SnakeCase, V as TitleCase, _ as ConstantCase, h as CaseFormat, m as CapitalizeOptions, p as CamelCase, u as $WidenEmpty } from "./string-_1ImwUJT.mjs";
|
|
18
18
|
|
|
19
19
|
//#region src/string/case.d.ts
|
|
20
20
|
/**
|
|
@@ -124,7 +124,7 @@ declare function capitalizeString(string: string, options?: CapitalizeOptions):
|
|
|
124
124
|
* @param del Additional delimiter characters to recognize.
|
|
125
125
|
* @returns The `camelCase` formatted string.
|
|
126
126
|
*/
|
|
127
|
-
declare function toCamelCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): CamelCase<Str, Del
|
|
127
|
+
declare function toCamelCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<CamelCase<Str, Del>>;
|
|
128
128
|
/**
|
|
129
129
|
* * Converts a string into `PascalCase`, using the optional custom delimiters in addition to the default delimiters.
|
|
130
130
|
*
|
|
@@ -145,7 +145,7 @@ declare function toCamelCase<Str extends string, Del extends string = ''>(str: S
|
|
|
145
145
|
* @param del Additional delimiter characters to recognize.
|
|
146
146
|
* @returns The `PascalCase` formatted string.
|
|
147
147
|
*/
|
|
148
|
-
declare function toPascalCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): PascalCase<Str, Del
|
|
148
|
+
declare function toPascalCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<PascalCase<Str, Del>>;
|
|
149
149
|
/**
|
|
150
150
|
* * Converts a string into `snake_case`, using the optional custom delimiters in addition to the default delimiters.
|
|
151
151
|
*
|
|
@@ -165,7 +165,7 @@ declare function toPascalCase<Str extends string, Del extends string = ''>(str:
|
|
|
165
165
|
* @param del Additional delimiter characters to recognize.
|
|
166
166
|
* @returns The `snake_case` formatted string.
|
|
167
167
|
*/
|
|
168
|
-
declare function toSnakeCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): SnakeCase<Str, Del
|
|
168
|
+
declare function toSnakeCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<SnakeCase<Str, Del>>;
|
|
169
169
|
/**
|
|
170
170
|
* * Converts a string into `kebab-case`, using the optional custom delimiters in addition to the default delimiters.
|
|
171
171
|
*
|
|
@@ -185,7 +185,7 @@ declare function toSnakeCase<Str extends string, Del extends string = ''>(str: S
|
|
|
185
185
|
* @param del Additional delimiter characters to recognize.
|
|
186
186
|
* @returns The `kebab-case` formatted string.
|
|
187
187
|
*/
|
|
188
|
-
declare function toKebabCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): KebabCase<Str, Del
|
|
188
|
+
declare function toKebabCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<KebabCase<Str, Del>>;
|
|
189
189
|
/**
|
|
190
190
|
* * Converts a string into `Train-Case`, using the optional custom delimiters in addition to the default delimiters.
|
|
191
191
|
*
|
|
@@ -204,7 +204,7 @@ declare function toKebabCase<Str extends string, Del extends string = ''>(str: S
|
|
|
204
204
|
* @param del Additional delimiter characters to recognize.
|
|
205
205
|
* @returns The `Train-Case` formatted string.
|
|
206
206
|
*/
|
|
207
|
-
declare function toTrainCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): TrainCase<Str, Del
|
|
207
|
+
declare function toTrainCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<TrainCase<Str, Del>>;
|
|
208
208
|
/**
|
|
209
209
|
* * Converts a string into `dot.case`, using the optional custom delimiters in addition to the default delimiters.
|
|
210
210
|
*
|
|
@@ -223,7 +223,7 @@ declare function toTrainCase<Str extends string, Del extends string = ''>(str: S
|
|
|
223
223
|
* @param del Additional delimiter characters to recognize.
|
|
224
224
|
* @returns The `dot.case` formatted string.
|
|
225
225
|
*/
|
|
226
|
-
declare function toDotCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): DotCase<Str, Del
|
|
226
|
+
declare function toDotCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<DotCase<Str, Del>>;
|
|
227
227
|
/**
|
|
228
228
|
* * Converts a string into `path/case`, using the optional custom delimiters in addition to the default delimiters.
|
|
229
229
|
*
|
|
@@ -242,7 +242,7 @@ declare function toDotCase<Str extends string, Del extends string = ''>(str: Str
|
|
|
242
242
|
* @param del Additional delimiter characters to recognize.
|
|
243
243
|
* @returns The `path/case` formatted string.
|
|
244
244
|
*/
|
|
245
|
-
declare function toPathCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): PathCase<Str, Del
|
|
245
|
+
declare function toPathCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<PathCase<Str, Del>>;
|
|
246
246
|
/**
|
|
247
247
|
* * Converts a string into `CONSTANT_CASE`, using the optional custom delimiters in addition to the default delimiters.
|
|
248
248
|
*
|
|
@@ -261,7 +261,7 @@ declare function toPathCase<Str extends string, Del extends string = ''>(str: St
|
|
|
261
261
|
* @param del Additional delimiter characters to recognize.
|
|
262
262
|
* @returns The `CONSTANT_CASE` formatted string.
|
|
263
263
|
*/
|
|
264
|
-
declare function toConstantCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): ConstantCase<Str, Del
|
|
264
|
+
declare function toConstantCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<ConstantCase<Str, Del>>;
|
|
265
265
|
/**
|
|
266
266
|
* * Converts a string into `Pascal_Snake_Case`, using the optional custom delimiters in addition to the default delimiters.
|
|
267
267
|
*
|
|
@@ -280,7 +280,7 @@ declare function toConstantCase<Str extends string, Del extends string = ''>(str
|
|
|
280
280
|
* @param del Additional delimiter characters to recognize.
|
|
281
281
|
* @returns The `Pascal_Snake_Case` formatted string.
|
|
282
282
|
*/
|
|
283
|
-
declare function toPascalSnakeCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): PascalSnakeCase<Str, Del
|
|
283
|
+
declare function toPascalSnakeCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<PascalSnakeCase<Str, Del>>;
|
|
284
284
|
/**
|
|
285
285
|
* * Converts a string into `Title Case`, using the optional custom delimiters in addition to the default delimiters.
|
|
286
286
|
*
|
|
@@ -301,7 +301,7 @@ declare function toPascalSnakeCase<Str extends string, Del extends string = ''>(
|
|
|
301
301
|
* @param del Additional delimiter characters to recognize.
|
|
302
302
|
* @returns The `Title Case` formatted string.
|
|
303
303
|
*/
|
|
304
|
-
declare function toTitleCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): TitleCase<Str, Del
|
|
304
|
+
declare function toTitleCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<TitleCase<Str, Del>>;
|
|
305
305
|
/**
|
|
306
306
|
* * Converts a string into `Sentence case`, using the optional custom delimiters in addition to the default delimiters.
|
|
307
307
|
*
|
|
@@ -322,6 +322,6 @@ declare function toTitleCase<Str extends string, Del extends string = ''>(str: S
|
|
|
322
322
|
* @param del Additional delimiter characters to recognize.
|
|
323
323
|
* @returns The `Sentence case` formatted string.
|
|
324
324
|
*/
|
|
325
|
-
declare function toSentenceCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): SentenceCase<Str, Del
|
|
325
|
+
declare function toSentenceCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<SentenceCase<Str, Del>>;
|
|
326
326
|
//#endregion
|
|
327
327
|
export { toDotCase as a, toPascalSnakeCase as c, toSnakeCase as d, toTitleCase as f, toConstantCase as i, toPathCase as l, convertStringCase as n, toKebabCase as o, toTrainCase as p, toCamelCase as r, toPascalCase as s, capitalizeString as t, toSentenceCase as u };
|