@rzl-zone/utils-js 2.0.1 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +26 -0
- package/dist/any-BmdI8UbK.d.ts +67 -0
- package/dist/array-CIZRbqTF.d.ts +223 -0
- package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +72 -0
- package/dist/assertions/index.cjs +1 -0
- package/dist/assertions/index.d.ts +428 -0
- package/dist/assertions/index.js +1 -0
- package/dist/chunk-2TRAPBZ7.cjs +1 -0
- package/dist/chunk-3D74QO5D.cjs +1 -0
- package/dist/chunk-4DK3RCC4.js +2 -0
- package/dist/chunk-4JOQ45HL.js +1 -0
- package/dist/chunk-55CZALRS.js +1 -0
- package/dist/chunk-56QBKKRE.js +1 -0
- package/dist/chunk-5JFV3GDE.cjs +4 -0
- package/dist/chunk-5SZUSNGZ.js +1 -0
- package/dist/chunk-62HX5Z45.cjs +1 -0
- package/dist/chunk-7NA6DUHR.cjs +2 -0
- package/dist/chunk-7YWAQOA4.cjs +1 -0
- package/dist/chunk-BVPMMWDL.cjs +1 -0
- package/dist/chunk-BYZAD3XN.cjs +1 -0
- package/dist/chunk-CEFYHEM4.cjs +1 -0
- package/dist/chunk-CN53M4QZ.cjs +1 -0
- package/dist/chunk-D47MHBSD.cjs +1 -0
- package/dist/chunk-DGH75GJD.js +1 -0
- package/dist/chunk-E5NUI7PN.js +1 -0
- package/dist/chunk-ELDDNERR.js +1 -0
- package/dist/chunk-EXZ47NOW.js +1 -0
- package/dist/chunk-FDITZ5C6.cjs +1 -0
- package/dist/chunk-FF76ISQ2.js +1 -0
- package/dist/chunk-FIEZKTAZ.cjs +1 -0
- package/dist/chunk-FSSV24W7.cjs +1 -0
- package/dist/chunk-G5LXIEFO.js +0 -0
- package/dist/chunk-GCGU2WB7.js +1 -0
- package/dist/chunk-GECI2YBP.js +1 -0
- package/dist/chunk-GQE4OVHC.cjs +1 -0
- package/dist/chunk-GRVZXQXL.cjs +1 -0
- package/dist/chunk-I4AVNHPA.cjs +1 -0
- package/dist/chunk-JFRL7NKU.js +4 -0
- package/dist/chunk-JWHM3WZQ.cjs +1 -0
- package/dist/chunk-KCQDDZJE.cjs +1 -0
- package/dist/chunk-L54ZPSYJ.js +1 -0
- package/dist/chunk-LVKAYEZ4.js +1 -0
- package/dist/chunk-MBDWTK54.cjs +1 -0
- package/dist/chunk-MMSYCIJ2.cjs +1 -0
- package/dist/chunk-MNGGDB2G.js +1 -0
- package/dist/chunk-MY7BA4GI.cjs +1 -0
- package/dist/chunk-N2IJPIND.cjs +1 -0
- package/dist/chunk-NIMNTEGV.js +1 -0
- package/dist/chunk-NNM7QCNB.js +1 -0
- package/dist/chunk-PUQXRLZH.cjs +1 -0
- package/dist/chunk-PVJF2JHM.js +1 -0
- package/dist/chunk-QCFXEUKL.js +1 -0
- package/dist/chunk-QFCGBBSY.js +1 -0
- package/dist/chunk-QQYAUPSK.cjs +1 -0
- package/dist/chunk-RN3TP3S3.js +1 -0
- package/dist/chunk-RV2VULM7.cjs +1 -0
- package/dist/chunk-SW6HYEW7.cjs +1 -0
- package/dist/chunk-SYJC7UAW.js +1 -0
- package/dist/chunk-TC4VBE4Y.cjs +1 -0
- package/dist/chunk-TUXDINHF.cjs +1 -0
- package/dist/chunk-U5Y2FXMN.cjs +1 -0
- package/dist/chunk-UUPQI6ND.cjs +1 -0
- package/dist/chunk-VYCGZ2S6.js +1 -0
- package/dist/chunk-W5EDKJK3.js +1 -0
- package/dist/chunk-WHAVUFEU.js +1 -0
- package/dist/chunk-XCFIOTCV.js +1 -0
- package/dist/chunk-XE27XPJR.js +1 -0
- package/dist/chunk-XH6MCRLP.js +1 -0
- package/dist/chunk-XVB3ZZEB.js +1 -0
- package/dist/chunk-ZBSIGJFO.cjs +1 -0
- package/dist/chunk-ZYAML74V.js +1 -0
- package/dist/conversions/index.cjs +1 -0
- package/dist/conversions/index.d.ts +1633 -0
- package/dist/conversions/index.js +1 -0
- package/dist/env/index.cjs +1 -0
- package/dist/env/index.d.ts +19 -0
- package/dist/env/index.js +1 -0
- package/dist/events/index.cjs +1 -0
- package/dist/events/index.d.ts +119 -0
- package/dist/events/index.js +1 -0
- package/dist/extends-Mp81Hq9-.d.ts +145 -0
- package/dist/formatting/index.cjs +1 -0
- package/dist/formatting/index.d.ts +912 -0
- package/dist/formatting/index.js +1 -0
- package/dist/generator/index.cjs +1 -0
- package/dist/generator/index.d.ts +163 -0
- package/dist/generator/index.js +1 -0
- package/dist/if-CvT4R7Kh.d.ts +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -4313
- package/dist/index.js +1 -1
- package/dist/is-array-Ckm_47hw.d.ts +1557 -0
- package/dist/isPlainObject-BKYaI6a8.d.ts +182 -0
- package/dist/never-BfayMBF9.d.ts +75 -0
- package/dist/next/index.cjs +8 -1
- package/dist/next/index.d.ts +169 -169
- package/dist/next/index.js +8 -1
- package/dist/next/server/index.cjs +2 -1
- package/dist/next/server/index.d.ts +37 -37
- package/dist/next/server/index.js +2 -1
- package/dist/nils-DMz3kU7M.d.ts +177 -0
- package/dist/omit-VvmIsZmX.d.ts +28 -0
- package/dist/operations/index.cjs +1 -0
- package/dist/operations/index.d.ts +182 -0
- package/dist/operations/index.js +1 -0
- package/dist/parsers/index.cjs +1 -0
- package/dist/parsers/index.d.ts +37 -0
- package/dist/parsers/index.js +1 -0
- package/dist/predicates/index.cjs +1 -0
- package/dist/predicates/index.d.ts +1839 -0
- package/dist/predicates/index.js +1 -0
- package/dist/prettify-C4xLcYOP.d.ts +353 -0
- package/dist/promise/index.cjs +1 -0
- package/dist/promise/index.d.ts +40 -0
- package/dist/promise/index.js +1 -0
- package/dist/rzl-utils.global.js +4 -1
- package/dist/strings/index.cjs +1 -0
- package/dist/strings/index.d.ts +816 -0
- package/dist/strings/index.js +1 -0
- package/dist/stylings/index.cjs +1 -0
- package/dist/stylings/index.d.ts +49 -0
- package/dist/stylings/index.js +1 -0
- package/dist/type-data-DDs-u2kq.d.ts +261 -0
- package/dist/types/index.d.ts +3589 -2090
- package/dist/urls/index.cjs +1 -0
- package/dist/urls/index.d.ts +418 -0
- package/dist/urls/index.js +1 -0
- package/package.json +147 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,4313 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/** -------------------------------------------------------
|
|
3
|
-
* * ***Asserts that a value is of type `string`.***
|
|
4
|
-
* -------------------------------------------------------
|
|
5
|
-
*
|
|
6
|
-
* Throws a `TypeError` if the value is not a string.
|
|
7
|
-
*
|
|
8
|
-
* @param {unknown} value - The value to check.
|
|
9
|
-
* @param {string | ((actualType: string) => string)} [message]
|
|
10
|
-
* Optional custom error message. If a function is provided,
|
|
11
|
-
* it receives the actual type (e.g. "number") and should return a string message.
|
|
12
|
-
* @returns {asserts value is string} Ensures `value` is `string` after this call.
|
|
13
|
-
*
|
|
14
|
-
* @throws {TypeError} If the value is not a string.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* assertIsString("hello"); // ✅ ok
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* assertIsString(42); // ❌ throws TypeError: Expected value to be 'string', but got 'number'
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* assertIsString(42, "Must be a string!"); // ❌ throws: Must be a string!
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* assertIsString(42, (type) => `Expected string but got ${type}`); // ❌ throws: Expected string but got number
|
|
27
|
-
*/
|
|
28
|
-
declare const assertIsString:(value:unknown,message?:string |((typeValue:string)=>string))=>asserts value is string;
|
|
29
|
-
/** ---------------------------------------------
|
|
30
|
-
* * ***Converts all values in an array from numbers or other types to strings.***
|
|
31
|
-
* * ***The function can also remove invalid values (null, undefined) based on the options provided.***
|
|
32
|
-
* ---------------------------------
|
|
33
|
-
*
|
|
34
|
-
* * 🚫 Note: This function does NOT support recursive or nested arrays.
|
|
35
|
-
* It only processes a flat array of values.
|
|
36
|
-
*
|
|
37
|
-
* * Use `toStringDeep` if you want to recursive.
|
|
38
|
-
* ---------------------------------------------
|
|
39
|
-
*
|
|
40
|
-
* @param {Array<string | number | null | undefined>} [array] - The array to be transformed.
|
|
41
|
-
* @param {Object} [options] - The options object that controls the transformation behavior.
|
|
42
|
-
* @param {boolean} [options.removeInvalidValue=true] - If true, removes invalid values (null, undefined) from the result. Default is true.
|
|
43
|
-
* @returns {Array<string | null | undefined>} - A new array with string representations of the values or an array with invalid values removed if specified.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* toStringArrayUnRecursive([1, 2, '3'])
|
|
47
|
-
* // => ['1', '2', '3']
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* toStringArrayUnRecursive([1, null, undefined, 'abc'], { removeInvalidValue: true })
|
|
51
|
-
* // => ['1', 'abc']
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* toStringArrayUnRecursive([1, null, undefined, 'abc'], { removeInvalidValue: false })
|
|
55
|
-
* // => ['1', null, undefined, 'abc']
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* toStringArrayUnRecursive(undefined)
|
|
59
|
-
* // => undefined
|
|
60
|
-
*/
|
|
61
|
-
declare function toStringArrayUnRecursive(array?:undefined | null,options?:{
|
|
62
|
-
/** If true, removes invalid values (null, undefined) from the result. Default is true.
|
|
63
|
-
* @default true
|
|
64
|
-
*/
|
|
65
|
-
removeInvalidValue:boolean;}):undefined;declare function toStringArrayUnRecursive(array?:Array<never>,options?:{
|
|
66
|
-
/** If true, removes invalid values (null, undefined) from the result. Default is true.
|
|
67
|
-
* @default true
|
|
68
|
-
*/
|
|
69
|
-
removeInvalidValue:boolean;}):Array<never>;declare function toStringArrayUnRecursive(array?:Array<undefined | null>| Array<null | undefined>,options?:{
|
|
70
|
-
/** If true, removes invalid values (null, undefined) from the result. Default is true.
|
|
71
|
-
* @default true
|
|
72
|
-
*/
|
|
73
|
-
removeInvalidValue:boolean;}):Array<undefined>;declare function toStringArrayUnRecursive<T>(array?:Array<T>,options?:{
|
|
74
|
-
/** If true, removes invalid values (null, undefined) from the result. Default is true.
|
|
75
|
-
* @default true
|
|
76
|
-
*/
|
|
77
|
-
removeInvalidValue:true;}):Array<string>| undefined;declare function toStringArrayUnRecursive<T>(array?:Array<T>,options?:{
|
|
78
|
-
/** If true, removes invalid values (null, undefined) from the result. Default is true.
|
|
79
|
-
* @default true
|
|
80
|
-
*/
|
|
81
|
-
removeInvalidValue:false;}):Array<string | null | undefined>| undefined;
|
|
82
|
-
/** ---------------------------------
|
|
83
|
-
* * ***Converts an array of string values (or values that can be cast to string) to an array of numbers.***
|
|
84
|
-
* * ***Optionally removes invalid values (non-numeric values) based on the provided options.***
|
|
85
|
-
* ---------------------------------
|
|
86
|
-
*
|
|
87
|
-
* * 🚫 Note: This function does NOT support recursive or nested arrays.
|
|
88
|
-
* It only processes a flat array of values.
|
|
89
|
-
*
|
|
90
|
-
* * Use `toNumbersDeep` if you want to recursive.
|
|
91
|
-
* ---------------------------------
|
|
92
|
-
*
|
|
93
|
-
* @param {Array<string | null | undefined>} [array] - The array of string values (or values convertible to strings) to be transformed into numbers.
|
|
94
|
-
* @param {Object} [options] - Options that affect the conversion behavior.
|
|
95
|
-
* @param {boolean} [options.removeInvalidValueNumber=true] - If true, removes invalid number values (e.g., NaN, undefined) from the result. Default is true.
|
|
96
|
-
* @returns {Array<number | undefined>} - An array of numbers converted from the string values, or an array with invalid values removed if specified.
|
|
97
|
-
*/
|
|
98
|
-
declare function toNumberArrayUnRecursive(array?:undefined | null,options?:{
|
|
99
|
-
/** If true, removes invalid number values (e.g., NaN, undefined) from the result. Default is true.
|
|
100
|
-
*
|
|
101
|
-
* @default true
|
|
102
|
-
*/
|
|
103
|
-
removeInvalidValueNumber?:boolean;}):undefined;declare function toNumberArrayUnRecursive(array?:Array<never>,options?:{
|
|
104
|
-
/** If true, removes invalid number values (e.g., NaN, undefined) from the result. Default is true.
|
|
105
|
-
*
|
|
106
|
-
* @default true
|
|
107
|
-
*/
|
|
108
|
-
removeInvalidValueNumber?:boolean;}):Array<never>;declare function toNumberArrayUnRecursive(array?:Array<undefined | null>| Array<null | undefined>,options?:{
|
|
109
|
-
/** If true, removes invalid number values (e.g., NaN, undefined) from the result. Default is true.
|
|
110
|
-
*
|
|
111
|
-
* @default true
|
|
112
|
-
*/
|
|
113
|
-
removeInvalidValueNumber?:boolean;}):Array<undefined>;declare function toNumberArrayUnRecursive<T>(array?:Array<T>,options?:{
|
|
114
|
-
/** If true, removes invalid number values (e.g., NaN, undefined) from the result. Default is true.
|
|
115
|
-
*
|
|
116
|
-
* @default true
|
|
117
|
-
*/
|
|
118
|
-
removeInvalidValueNumber?:true;}):Array<number>| undefined;declare function toNumberArrayUnRecursive<T>(array?:Array<T>,options?:{
|
|
119
|
-
/** If true, removes invalid number values (e.g., NaN, undefined) from the result. Default is true.
|
|
120
|
-
*
|
|
121
|
-
* @default true
|
|
122
|
-
*/
|
|
123
|
-
removeInvalidValueNumber:false;}):Array<number | undefined>| undefined;type ResUnFTN<Force extends false | "stringOrNumber" | "primitives" | "all"=false>=Force extends "all" ? Array<unknown[] | Record<string,unknown>| string>:Force extends "stringOrNumber" ? Array<string | boolean | bigint | symbol | null | undefined | Record<string,unknown>| AnyFunction | unknown[] | Date | RegExp | Map<unknown,unknown>| Set<unknown>| Promise<unknown>>:Force extends "primitives" ? Array<string | symbol | Record<string,unknown>| AnyFunction | unknown[] | Date | RegExp | Map<unknown,unknown>| Set<unknown>| Promise<unknown>>:Force extends false ? Array<string | number | bigint | boolean | symbol | RegExp | Record<string,unknown>| AnyFunction | Date | Map<unknown,unknown>| Set<unknown>| Promise<unknown>| unknown[] | null | undefined>:unknown[];type ResFTN<Force extends false | "stringOrNumber" | "primitives" | "all"=false>=Force extends "all" ? Array<string | Record<string,unknown>>:Force extends "stringOrNumber" ? Array<string | boolean | bigint | symbol | null | undefined | Record<string,unknown>| AnyFunction | Date | RegExp | Promise<unknown>>:Force extends "primitives" ? Array<string | symbol | RegExp | Record<string,unknown>| AnyFunction | Date | Promise<unknown>>:Force extends false ? Array<string | number | bigint | boolean | symbol | RegExp | Record<string,unknown>| AnyFunction | Date | Promise<unknown>| null | undefined>:unknown[];type DedupeResult<Force extends false | "stringOrNumber" | "primitives" | "all"=false,FTN extends boolean=false>=FTN extends false ? ResUnFTN<Force>:ResFTN<Force>;
|
|
124
|
-
/** ----------------------------------------------------------
|
|
125
|
-
* * ***Removes `null` and `undefined` values from an array, including nested arrays.***
|
|
126
|
-
* ----------------------------------------------------------
|
|
127
|
-
*
|
|
128
|
-
* - ✅ Returns `undefined` if the input is explicitly `undefined` or `null`.
|
|
129
|
-
* - ✅ Returns `[]` if input is empty or all elements are removed after filtering.
|
|
130
|
-
* - ✅ Recursively filters nested arrays while preserving structure.
|
|
131
|
-
* - ✅ Ensures proper type inference for safer downstream operations.
|
|
132
|
-
*
|
|
133
|
-
* @template T - The type of elements in the array.
|
|
134
|
-
* @param {T[]} [input] - The array to be filtered.
|
|
135
|
-
* @returns {T[] | undefined} A new array with `null` and `undefined` values removed,
|
|
136
|
-
* or `undefined` if the input is explicitly `undefined` or `null`.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* filterNullArray([1, null, 2, undefined, 3]);
|
|
140
|
-
* // => [1, 2, 3]
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* filterNullArray([null, undefined]);
|
|
144
|
-
* // => []
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* filterNullArray(undefined);
|
|
148
|
-
* // => undefined
|
|
149
|
-
* @example
|
|
150
|
-
* filterNullArray(null);
|
|
151
|
-
* // => undefined
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* filterNullArray([]);
|
|
155
|
-
* // => []
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* filterNullArray([1, [null, 2, [undefined, 3]]]);
|
|
159
|
-
* // => [1, [2, [3]]]
|
|
160
|
-
*/
|
|
161
|
-
declare const filterNullArray:<T>(input?:T[] | null)=>T[] | undefined;
|
|
162
|
-
/** ----------------------------------------------------------
|
|
163
|
-
* * ***Deduplicates values in an array (with optional flattening and deep stringification).***
|
|
164
|
-
* ----------------------------------------------------------
|
|
165
|
-
*
|
|
166
|
-
* Supports various modes for converting values to strings before deduplication:
|
|
167
|
-
* - `"stringOrNumber"`: Converts strings and numbers to strings.
|
|
168
|
-
* - `"primitives"`: Converts all primitives (string, number, boolean, bigint, null, undefined, NaN) to strings.
|
|
169
|
-
* - `"all"`: Converts all values (primitives, objects, Maps, Sets, Symbols, RegExp, Dates, Errors, Promises, functions)
|
|
170
|
-
* to strings, including nested object properties.
|
|
171
|
-
* - `false` (default): No conversion applied.
|
|
172
|
-
*
|
|
173
|
-
* Options:
|
|
174
|
-
* - `forceToString`: Enables string conversion for comparison, default is `false`.
|
|
175
|
-
* - `flatten`: If true, deeply flattens arrays, Maps, and Sets before deduplication, default is `false`.
|
|
176
|
-
*
|
|
177
|
-
* @template FTS - `forceToString` mode.
|
|
178
|
-
* @template FTN - `flatten` mode.
|
|
179
|
-
*
|
|
180
|
-
* @param {unknown[]} inputArray - The array to deduplicate. Can be deeply nested and contain any mix of types.
|
|
181
|
-
* @param {{ forceToString?: false | "stringOrNumber" | "primitives" | "all" }} [options] - Options to control string conversion.
|
|
182
|
-
* @returns {DedupeResult<FTS, FTN>} Deduplicated array with optional transformations.
|
|
183
|
-
*
|
|
184
|
-
* @throws {TypeError} If the input is not an array, or options is not an object, or if `forceToString` is invalid.
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* dedupeArray(["apple", "banana", "apple"]);
|
|
188
|
-
* // => ["apple", "banana"]
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* dedupeArray([[1, 2], [1, 2]], { flatten: true });
|
|
192
|
-
* // => [1, 2]
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* dedupeArray([new Set([1, 2]), new Set([2, 3])], { flatten: true });
|
|
196
|
-
* // => [1, 2, 3]
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* dedupeArray([1, "1", 2, "2"], { forceToString: "stringOrNumber" });
|
|
200
|
-
* // => ["1", "2"]
|
|
201
|
-
*
|
|
202
|
-
* @example
|
|
203
|
-
* dedupeArray([true, "true", false, undefined], { forceToString: "primitives" });
|
|
204
|
-
* // => ["true", "false", "undefined"]
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* dedupeArray([1, "1", { a: 1 }], { forceToString: "all" });
|
|
208
|
-
* // => ["1", { a: "1" }]
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* dedupeArray([1, 1, [2, 2, [3, 3]]]);
|
|
212
|
-
* // => [1, [2, [3]]]
|
|
213
|
-
*
|
|
214
|
-
* @example
|
|
215
|
-
* dedupeArray([null, undefined, null]);
|
|
216
|
-
* // => [null, undefined]
|
|
217
|
-
*
|
|
218
|
-
* @example
|
|
219
|
-
* dedupeArray([[], [[]], [[[]]], [[]], [[[]]]]);
|
|
220
|
-
* // => [[], [[]], [[[]]]]
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* const fn = () => 1;
|
|
224
|
-
* dedupeArray([fn, fn, () => 1]);
|
|
225
|
-
* // => [fn, () => 1] cause: ref () => 1 and fn is different but ref const `fn` and `fn` is same ref.
|
|
226
|
-
*
|
|
227
|
-
* @example
|
|
228
|
-
* dedupeArray([Symbol("x"), Symbol("x")]);
|
|
229
|
-
* // => [Symbol("x")] (symbols are same by identity, so dedupe
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* dedupeArray([NaN, NaN, 1, "1"]);
|
|
233
|
-
* // => [NaN, 1, "1"]
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* dedupeArray([NaN, NaN, 1, "1"], { forceToString: "primitives" });
|
|
237
|
-
* // => ["NaN", "1"]
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* dedupeArray([new Date("2025-01-01"), new Date("2025-01-01")]);
|
|
241
|
-
* // => [Date("2025-01-01")] (same time, deduped)
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* dedupeArray([new Date("2025-01-01"), new Date("2025-01-01")], { forceToString: "all" });
|
|
245
|
-
* // => ["2025-01-01T00:00:00.000Z"]
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* dedupeArray([/abc/, /abc/], { forceToString: "all" });
|
|
249
|
-
* // => ["/abc/"]
|
|
250
|
-
*
|
|
251
|
-
* @example
|
|
252
|
-
* dedupeArray([new Map(), new Set(), new Error("err")], { forceToString: "all" });
|
|
253
|
-
* // => ["[object Map]", "[object Set]", "Error: err"]
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* dedupeArray([Promise.resolve(1), Promise.resolve(1)], { forceToString: "all" });
|
|
257
|
-
* // => ["[object Promise]"]
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
* dedupeArray([{ a: 1 }, { a: 1 }, { a: 2 }], { forceToString: "primitives" });
|
|
261
|
-
* // => [{ a: "1" }, { a: "2" }]
|
|
262
|
-
*
|
|
263
|
-
* @example
|
|
264
|
-
* dedupeArray([{ a: { b: 1 } }, { a: { b: 1 } }], { forceToString: "all" });
|
|
265
|
-
* // => [{ a: { b: "1" } }]
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* dedupeArray("not an array");
|
|
269
|
-
* // Throws TypeError
|
|
270
|
-
*
|
|
271
|
-
* @example
|
|
272
|
-
* dedupeArray([1, 2, 3], { forceToString: "invalid" });
|
|
273
|
-
* // Throws TypeError
|
|
274
|
-
*/
|
|
275
|
-
declare const dedupeArray:<FTS extends false | "stringOrNumber" | "primitives" | "all"=false,FTN extends boolean=false>(inputArray:unknown[],options?:{
|
|
276
|
-
/** Enables string conversion for comparison, default is `false`.
|
|
277
|
-
*
|
|
278
|
-
* @default false
|
|
279
|
-
*/
|
|
280
|
-
forceToString?:FTS;
|
|
281
|
-
/** If true, deeply flattens arrays, Maps, and Sets before deduplication, default is `false`.
|
|
282
|
-
*
|
|
283
|
-
* @default false
|
|
284
|
-
*/
|
|
285
|
-
flatten?:FTN;})=>DedupeResult<FTS,FTN>;
|
|
286
|
-
/** ---------------------------------
|
|
287
|
-
* * ***Converts a given value into a boolean (strict).***
|
|
288
|
-
* ---------------------------------
|
|
289
|
-
*
|
|
290
|
-
* This is stricter than normal JS coercion:
|
|
291
|
-
* - `null` and `undefined` return `false`.
|
|
292
|
-
* - Empty strings return `false`, non-empty strings return `true`.
|
|
293
|
-
* - Numbers: `0` is `false`, others `true`.
|
|
294
|
-
* - Booleans returned as-is.
|
|
295
|
-
* - Arrays: `[]` is `false`, non-empty is `true`.
|
|
296
|
-
* - Objects: `{}` is `false`, object with keys is `true`.
|
|
297
|
-
*
|
|
298
|
-
* @param {unknown} [value] - The value to be converted.
|
|
299
|
-
* @returns {boolean} `true` if the value is considered non-empty, otherwise `false`.
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* toBooleanContent(null); // false
|
|
303
|
-
* toBooleanContent(""); // false
|
|
304
|
-
* toBooleanContent(" "); // false
|
|
305
|
-
* toBooleanContent(" asd "); // true
|
|
306
|
-
* toBooleanContent("abc"); // true
|
|
307
|
-
* toBooleanContent(0); // false
|
|
308
|
-
* toBooleanContent(42); // true
|
|
309
|
-
* toBooleanContent([]); // false
|
|
310
|
-
* toBooleanContent([1]); // true
|
|
311
|
-
* toBooleanContent({}); // false
|
|
312
|
-
* toBooleanContent({ a: 1 }); // true
|
|
313
|
-
*/
|
|
314
|
-
declare const toBooleanContent:(value?:unknown)=>boolean;
|
|
315
|
-
/** -------------------------------------------------
|
|
316
|
-
* * ***Recursively checks if value is "non-empty".***
|
|
317
|
-
* -------------------------------------------------
|
|
318
|
-
*
|
|
319
|
-
* This function does a deep inspection to determine if the input
|
|
320
|
-
* contains any meaningful / non-empty value. It is stricter than
|
|
321
|
-
* JavaScript's normal truthy checks because it looks *inside*
|
|
322
|
-
* nested arrays & objects.
|
|
323
|
-
*
|
|
324
|
-
* Rules:
|
|
325
|
-
* - `null` and `undefined` return `false`
|
|
326
|
-
* - Empty strings `""` return `false`
|
|
327
|
-
* - `0` returns `false`
|
|
328
|
-
* - Empty arrays `[]` or empty objects `{}` return `false`
|
|
329
|
-
* - Checks deeply nested arrays/objects — if any value inside is "non-empty", returns `true`
|
|
330
|
-
*
|
|
331
|
-
* @param {unknown} [value] - The value to check.
|
|
332
|
-
* @returns {boolean} `true` if the value or anything nested inside is non-empty, otherwise `false`.
|
|
333
|
-
*
|
|
334
|
-
* @example
|
|
335
|
-
* toBooleanContentDeep(null); // false
|
|
336
|
-
* toBooleanContentDeep(""); // false
|
|
337
|
-
* toBooleanContentDeep(0); // false
|
|
338
|
-
* toBooleanContentDeep([]); // false
|
|
339
|
-
* toBooleanContentDeep({}); // false
|
|
340
|
-
* toBooleanContentDeep([[], {}]); // false
|
|
341
|
-
*
|
|
342
|
-
* toBooleanContentDeep("abc"); // true
|
|
343
|
-
* toBooleanContentDeep(42); // true
|
|
344
|
-
* toBooleanContentDeep([0, "", null]); // false
|
|
345
|
-
* toBooleanContentDeep([0, "", 5]); // true
|
|
346
|
-
* toBooleanContentDeep({ a: 0 }); // false
|
|
347
|
-
* toBooleanContentDeep({ a: 1 }); // true
|
|
348
|
-
* toBooleanContentDeep({ a: { b: [] }}); // false
|
|
349
|
-
* toBooleanContentDeep({ a: { b: "x" }}); // true
|
|
350
|
-
*/
|
|
351
|
-
declare const toBooleanContentDeep:(value?:unknown)=>boolean;
|
|
352
|
-
/** ---------------------------------
|
|
353
|
-
* * ***Converts a value into a strict boolean.***
|
|
354
|
-
* ---------------------------------
|
|
355
|
-
*
|
|
356
|
-
* This function checks if the input is a valid representation of `true`
|
|
357
|
-
* (e.g., `"true"`, `"on"`, `"yes"`, `"1"`, `1`, `true`, `"indeterminate"`).
|
|
358
|
-
* Any other value, including `undefined` and `null`, will return `false`.
|
|
359
|
-
*
|
|
360
|
-
* Supports optional `caseInsensitive` and `trimString` to customize string normalization.
|
|
361
|
-
*
|
|
362
|
-
* @param {unknown} [value] - The value to convert.
|
|
363
|
-
* @param {Object} [options] - Options for conversion behavior.
|
|
364
|
-
* @param {boolean} [options.caseInsensitive=false] - Whether string comparison ignores case. Default: `false`.
|
|
365
|
-
* @param {boolean} [options.trimString=true] - Whether to trim whitespace before comparison. Default: `true`.
|
|
366
|
-
* @returns {boolean} `true` if the value matches a truthy representation, otherwise `false`.
|
|
367
|
-
*
|
|
368
|
-
* @example
|
|
369
|
-
* toBooleanExplicit(true) // true
|
|
370
|
-
* toBooleanExplicit("on") // true
|
|
371
|
-
* toBooleanExplicit("Yes") // false
|
|
372
|
-
* toBooleanExplicit(" YES ", { trimString: false }) // false
|
|
373
|
-
* toBooleanExplicit(" YES ", { trimString: true, caseInsensitive: true }) // true
|
|
374
|
-
* toBooleanExplicit(" YES ", { trimString: true, caseInsensitive: false }) // false
|
|
375
|
-
* toBooleanExplicit("yes", { caseInsensitive: false }) // true
|
|
376
|
-
* toBooleanExplicit("1") // true
|
|
377
|
-
* toBooleanExplicit(1) // true
|
|
378
|
-
* toBooleanExplicit(0) // false
|
|
379
|
-
* toBooleanExplicit("off") // false
|
|
380
|
-
*/
|
|
381
|
-
declare const toBooleanExplicit:(value?:unknown,options?:{
|
|
382
|
-
/** Whether string comparison ignores case. Default: `false`.
|
|
383
|
-
*
|
|
384
|
-
* @default false
|
|
385
|
-
*/
|
|
386
|
-
caseInsensitive?:boolean;
|
|
387
|
-
/** Whether to trim whitespace before comparison. Default: `true`.
|
|
388
|
-
*
|
|
389
|
-
* @default true
|
|
390
|
-
*/
|
|
391
|
-
trimString?:boolean;})=>boolean;
|
|
392
|
-
/** ---------------------------------
|
|
393
|
-
* * ***Converts a given value into a boolean (loose).***
|
|
394
|
-
* ---------------------------------
|
|
395
|
-
*
|
|
396
|
-
* This follows JavaScript's typical truthy/falsy rules with some tweaks:
|
|
397
|
-
* - `null` and `undefined` return `false`.
|
|
398
|
-
* - Empty strings return `false`, non-empty strings return `true`.
|
|
399
|
-
* - Numbers: `0` is `false`, others `true`.
|
|
400
|
-
* - Booleans returned as-is.
|
|
401
|
-
* - Arrays: `[]` is `false`, non-empty is `true`.
|
|
402
|
-
* - Other objects: uses `Boolean(value)`, so `{}` is `true`.
|
|
403
|
-
*
|
|
404
|
-
* @param {unknown} [value] - The value to be converted.
|
|
405
|
-
* @returns {boolean} `true` if the value is truthy, otherwise `false`.
|
|
406
|
-
*
|
|
407
|
-
* @example
|
|
408
|
-
* toBooleanLoose(null); // false
|
|
409
|
-
* toBooleanLoose(""); // false
|
|
410
|
-
* toBooleanLoose("abc"); // true
|
|
411
|
-
* toBooleanLoose(0); // false
|
|
412
|
-
* toBooleanLoose(42); // true
|
|
413
|
-
* toBooleanLoose([]); // false
|
|
414
|
-
* toBooleanLoose([1]); // true
|
|
415
|
-
* toBooleanLoose({}); // true
|
|
416
|
-
* toBooleanLoose({ a: 1 }); // true
|
|
417
|
-
*/
|
|
418
|
-
declare const toBooleanLoose:(value?:unknown)=>boolean;
|
|
419
|
-
/** * ----------------------------------------------------------
|
|
420
|
-
* * ***Extracts digits from a string or number input.***
|
|
421
|
-
* ----------------------------------------------------------
|
|
422
|
-
*
|
|
423
|
-
* ✅ Converts the input to a string, trims whitespace, and removes any characters
|
|
424
|
-
* that are not digits (`0-9`).
|
|
425
|
-
*
|
|
426
|
-
* ✅ Returns the cleaned numeric value as a `number`.
|
|
427
|
-
*
|
|
428
|
-
* 🚩 If the input is `null`, `undefined`, or results in no digits,
|
|
429
|
-
* it safely returns `0`.
|
|
430
|
-
*
|
|
431
|
-
* @param {string | number | null | undefined} value
|
|
432
|
-
* The value to process. Accepts a string, number, `null`, or `undefined`.
|
|
433
|
-
*
|
|
434
|
-
* @returns {number}
|
|
435
|
-
* The numeric value after extracting digits.
|
|
436
|
-
* Returns `0` if input is invalid or contains no digits.
|
|
437
|
-
*
|
|
438
|
-
* @example
|
|
439
|
-
* extractDigits("123abc456"); // ➔ 123456
|
|
440
|
-
* extractDigits("$1,234.56"); // ➔ 123456
|
|
441
|
-
* extractDigits("9A8B7C6"); // ➔ 9876
|
|
442
|
-
* extractDigits("abc"); // ➔ 0
|
|
443
|
-
* extractDigits(undefined); // ➔ 0
|
|
444
|
-
* extractDigits(null); // ➔ 0
|
|
445
|
-
* extractDigits(12345); // ➔ 12345
|
|
446
|
-
* extractDigits(" 00a "); // ➔ 0
|
|
447
|
-
*/
|
|
448
|
-
declare const extractDigits:(value?:string | number | null)=>number;
|
|
449
|
-
/** -------------------------------------------------------------
|
|
450
|
-
* * Parses a human-friendly currency string into a JavaScript number.
|
|
451
|
-
* -------------------------------------------------------------
|
|
452
|
-
*
|
|
453
|
-
* 🚀 Supports multi-locale formats:
|
|
454
|
-
*
|
|
455
|
-
* - European: "15.000,10" ➔ 15300.10
|
|
456
|
-
* - US: "15,000.10" ➔ 15300.10
|
|
457
|
-
* - Swiss: "15'000.10" ➔ 15300.10
|
|
458
|
-
* - French: "15 000,10" ➔ 15300.10
|
|
459
|
-
* - Indian: "1,23,456.78" ➔ 123456.78
|
|
460
|
-
* - Compact: "15300000,10" ➔ 15300000.10
|
|
461
|
-
*
|
|
462
|
-
* ✅ Features:
|
|
463
|
-
* - Strips symbols automatically: "Rp", "$", "EUR", etc.
|
|
464
|
-
* - Handles bracket negatives: "(15.000,10)" ➔ -15300.10
|
|
465
|
-
* - Normalizes decimal separator (last dot or comma).
|
|
466
|
-
* - Detects non-breaking spaces (\u00A0, \u202F) often in European data.
|
|
467
|
-
* - Fallback to 0 for empty, invalid, or non-numeric strings.
|
|
468
|
-
*
|
|
469
|
-
* 🔍 How it parses internally:
|
|
470
|
-
* 1. Removes all characters except digits, ., ,, ', spaces.
|
|
471
|
-
* 2. Detects bracket (...) as negative.
|
|
472
|
-
* 3. If Indian style (1,23,456) detected by multiple ,\d{2}, removes all commas.
|
|
473
|
-
* 4. Otherwise:
|
|
474
|
-
* - If multiple dots & no commas ➔ thousands: removes all .
|
|
475
|
-
* - If multiple commas & no dots ➔ thousands: removes all ,
|
|
476
|
-
* - If mixed, treats last , or . as decimal
|
|
477
|
-
* 5. Converts final decimal to . for JS float.
|
|
478
|
-
*
|
|
479
|
-
* 🛠 Gotchas:
|
|
480
|
-
* - If both . and , are present, last occurrence is used as decimal.
|
|
481
|
-
* - For strings like "1.121.234,56" ➔ decimal is ,.
|
|
482
|
-
* - For "1,121,234.56" ➔ decimal is ..
|
|
483
|
-
* - For "15300000,2121" ➔ decimal becomes . internally.
|
|
484
|
-
*
|
|
485
|
-
* @param {string} input
|
|
486
|
-
* Any messy currency string. May contain:
|
|
487
|
-
* - currency symbols (Rp, $, CHF, EUR)
|
|
488
|
-
* - thousands separators (.,', space, \u00A0, \u202F)
|
|
489
|
-
* - various decimal formats (, or .)
|
|
490
|
-
* - bracket negative: "(15.000,10)"
|
|
491
|
-
*
|
|
492
|
-
* @returns {number}
|
|
493
|
-
* JavaScript float representation.
|
|
494
|
-
* Will return 0 for invalid, empty, or non-string input.
|
|
495
|
-
*
|
|
496
|
-
* 📦 Examples of input ➔ output:
|
|
497
|
-
* @example
|
|
498
|
-
* parseCurrencyString("Rp 15.300.000,21");
|
|
499
|
-
* // ➔ 15300000.21
|
|
500
|
-
*
|
|
501
|
-
* parseCurrencyString("15 300 000,21");
|
|
502
|
-
* // ➔ 15300000.21
|
|
503
|
-
*
|
|
504
|
-
* parseCurrencyString("CHF 15'300'000.21");
|
|
505
|
-
* // ➔ 15300000.21
|
|
506
|
-
*
|
|
507
|
-
* parseCurrencyString("$15,300,000.21");
|
|
508
|
-
* // ➔ 15300000.21
|
|
509
|
-
*
|
|
510
|
-
* parseCurrencyString("(15.000,10)");
|
|
511
|
-
* // ➔ -15000.10
|
|
512
|
-
*
|
|
513
|
-
* parseCurrencyString("1,23,456.78");
|
|
514
|
-
* // ➔ 123456.78
|
|
515
|
-
*
|
|
516
|
-
* parseCurrencyString("15300000,2121");
|
|
517
|
-
* // ➔ 15300000.2121
|
|
518
|
-
*
|
|
519
|
-
* parseCurrencyString("USD 15 300 000.21");
|
|
520
|
-
* // ➔ 15300000.21
|
|
521
|
-
*
|
|
522
|
-
* parseCurrencyString("");
|
|
523
|
-
* // ➔ 0
|
|
524
|
-
*
|
|
525
|
-
* parseCurrencyString("abc");
|
|
526
|
-
* // ➔ 0
|
|
527
|
-
*
|
|
528
|
-
* @description
|
|
529
|
-
* * Notes:
|
|
530
|
-
* - Use this function as a first step to **sanitize currency inputs**
|
|
531
|
-
* before storing into database or doing math.
|
|
532
|
-
* - Always pair this with your formatter for consistent output display.
|
|
533
|
-
*/
|
|
534
|
-
declare const parseCurrencyString:(input?:string | null)=>number;
|
|
535
|
-
/** ----------------------------------------------------------
|
|
536
|
-
* * ***Converts a value from a string to its natural JavaScript type.***
|
|
537
|
-
* ----------------------------------------------------------
|
|
538
|
-
*
|
|
539
|
-
* ✅ Supported conversions:
|
|
540
|
-
* - `"true"` → `true`
|
|
541
|
-
* - `"false"` → `false`
|
|
542
|
-
* - `"null"` → `null`
|
|
543
|
-
* - `"undefined"` → `undefined`
|
|
544
|
-
* - `"42"` → `42` (number)
|
|
545
|
-
* - `"3.14"` → `3.14` (number)
|
|
546
|
-
* - `"3,567,890.14"` → `3567890.14` (number)
|
|
547
|
-
* - `" "` → `""` (trimmed)
|
|
548
|
-
* - Other strings are returned trimmed & lowercased.
|
|
549
|
-
* - Non-string inputs are returned unchanged.
|
|
550
|
-
*
|
|
551
|
-
* @example
|
|
552
|
-
* convertType("true") // → true
|
|
553
|
-
* convertType(" 42 ") // → 42
|
|
554
|
-
* convertType("FALSE") // → false
|
|
555
|
-
* convertType(" null ") // → null
|
|
556
|
-
* convertType(" ") // → ""
|
|
557
|
-
* convertType(100) // → 100
|
|
558
|
-
* convertType({}) // → {}
|
|
559
|
-
*
|
|
560
|
-
* @param {any} value - The value to convert (usually string or unknown type).
|
|
561
|
-
* @returns {any} The converted JavaScript type (boolean, number, null, undefined, or original).
|
|
562
|
-
*/
|
|
563
|
-
declare const convertType:(value:unknown)=>unknown;type NonJsonParsableType=Omit<Exclude<unknown,string | null | undefined>,string>;type Contains<T,U>=[Extract<T,U>] extends [never] ? false:true;type UnknownValue={undefined:true;};type SafeJsonParseResult<TData,T>=IfNotExtends<T,NonJsonParsableType>extends true ? T extends never ? undefined:T extends void ? undefined:T extends number ? undefined:Contains<T,string>extends true ? Contains<T,null & string>extends true ? TData | null | undefined:TData | undefined:IfExtends<T,null>extends true ? null:IfNotExtends<T,NonJsonParsableType>extends true ? TData | null | undefined:undefined:Contains<T,string>extends true ? IsAny<T>extends true ? TData | undefined | null:TData | undefined:undefined;interface CleanParsedDataOptions{
|
|
564
|
-
/** Convert numeric strings to numbers (e.g., `"42"` → `42`).
|
|
565
|
-
*
|
|
566
|
-
* @default false
|
|
567
|
-
*/
|
|
568
|
-
convertNumbers?:boolean;
|
|
569
|
-
/** Convert `"true"` / `"false"` strings to boolean values.
|
|
570
|
-
*
|
|
571
|
-
* @default false
|
|
572
|
-
*/
|
|
573
|
-
convertBooleans?:boolean;
|
|
574
|
-
/** Convert valid date strings into `Date` objects.
|
|
575
|
-
*
|
|
576
|
-
* @default false
|
|
577
|
-
*/
|
|
578
|
-
convertDates?:boolean;
|
|
579
|
-
/** Custom date formats to be parsed (e.g., `["DD/MM/YYYY", "MM/DD/YYYY"]`).
|
|
580
|
-
*
|
|
581
|
-
* @default []
|
|
582
|
-
*/
|
|
583
|
-
customDateFormats?:string[];
|
|
584
|
-
/** Remove `null` values from objects and arrays.
|
|
585
|
-
*
|
|
586
|
-
* @default false
|
|
587
|
-
*/
|
|
588
|
-
removeNulls?:boolean;
|
|
589
|
-
/**
|
|
590
|
-
* Remove `undefined` values from objects and arrays.
|
|
591
|
-
*
|
|
592
|
-
* - `false` (default): replaces `undefined` with `null`
|
|
593
|
-
* - `true`: removes keys with `undefined` values
|
|
594
|
-
*/
|
|
595
|
-
removeUndefined?:boolean;
|
|
596
|
-
/** Remove empty objects `{}` from the final output.
|
|
597
|
-
*
|
|
598
|
-
* @default false
|
|
599
|
-
*/
|
|
600
|
-
removeEmptyObjects?:boolean;
|
|
601
|
-
/** Remove empty arrays `[]` from the final output.
|
|
602
|
-
*
|
|
603
|
-
* @default false
|
|
604
|
-
*/
|
|
605
|
-
removeEmptyArrays?:boolean;
|
|
606
|
-
/** Strict mode: Removes values that do not match selected conversions.
|
|
607
|
-
*
|
|
608
|
-
* @default false
|
|
609
|
-
*/
|
|
610
|
-
strictMode?:boolean;
|
|
611
|
-
/** Enable error logging if JSON parsing fails.
|
|
612
|
-
*
|
|
613
|
-
* @default false
|
|
614
|
-
*/
|
|
615
|
-
loggingOnFail?:boolean;
|
|
616
|
-
/** Custom error handler function.
|
|
617
|
-
*
|
|
618
|
-
* @default undefined
|
|
619
|
-
*/
|
|
620
|
-
onError?:(error:unknown)=>void;}
|
|
621
|
-
/** --------------------------------------------------
|
|
622
|
-
* * ***Cleans parsed JSON data based on provided options.***
|
|
623
|
-
* --------------------------------------------------
|
|
624
|
-
*
|
|
625
|
-
* @template T - Expected output type.
|
|
626
|
-
* @param {unknown} data - The parsed JSON data.
|
|
627
|
-
* @param {CleanParsedDataOptions} options - Cleaning options.
|
|
628
|
-
* @returns {T | undefined} - The cleaned data.
|
|
629
|
-
*
|
|
630
|
-
* **Note: If using `convertDates`, result may contain Date objects. You may need type assertions in strict TypeScript settings.**
|
|
631
|
-
*
|
|
632
|
-
* @example
|
|
633
|
-
* // Convert numbers and remove nulls
|
|
634
|
-
* const result = cleanParsedData({ age: "25", name: null }, { convertNumbers: true, removeNulls: true });
|
|
635
|
-
* console.log(result); // Output: { age: 25 }
|
|
636
|
-
*
|
|
637
|
-
* @example
|
|
638
|
-
* // Convert boolean strings
|
|
639
|
-
* const result = cleanParsedData({ isActive: "true" }, { convertBooleans: true });
|
|
640
|
-
* console.log(result); // Output: { isActive: true }
|
|
641
|
-
*/
|
|
642
|
-
declare const cleanParsedData:<T=unknown>(data:T,options?:CleanParsedDataOptions)=>T | undefined | null;
|
|
643
|
-
/** --------------------------------------------------
|
|
644
|
-
* * ***Parses custom date formats like "DD/MM/YYYY" or "MM/DD/YYYY".***
|
|
645
|
-
* --------------------------------------------------
|
|
646
|
-
*
|
|
647
|
-
* @param {string} dateString - Date string to parse.
|
|
648
|
-
* @param {string} format - Date format to match.
|
|
649
|
-
* @returns {Date | null} - Returns a Date object if valid, otherwise null.
|
|
650
|
-
*/
|
|
651
|
-
declare const parseCustomDate:(dateString:string,format:string)=>Date | null;
|
|
652
|
-
/** --------------------------------------------------
|
|
653
|
-
* * ***Safely parses JSON while handling errors and applying transformations.***
|
|
654
|
-
* --------------------------------------------------
|
|
655
|
-
*
|
|
656
|
-
* - ✅ **Supports generics** to ensure accurate return type inference.
|
|
657
|
-
* - Always provide both `<TData, TInput>` for best results.
|
|
658
|
-
* - ***Scroll down for full generic behavior explanation.***
|
|
659
|
-
* - ✅ Automatically parses valid JSON strings into objects, arrays, numbers, etc.
|
|
660
|
-
* - ✅ Supports data transformation via options (e.g., convert strings to numbers, booleans, or dates).
|
|
661
|
-
* - ✅ Returns:
|
|
662
|
-
* 1. `null` → if input is explicitly `null`.
|
|
663
|
-
* 2. `undefined` → if input is `undefined`, not a string, or if parsing fails.
|
|
664
|
-
* 3. Parsed and cleaned result (`TData`) → if input is a valid JSON string.
|
|
665
|
-
*
|
|
666
|
-
* ⚠ **JSON.stringify note**: If the input JSON string was created using `JSON.stringify()`, any properties with
|
|
667
|
-
* `undefined` values would have been automatically removed or converted to `null` depending on the serializer.
|
|
668
|
-
* Example:
|
|
669
|
-
* ```ts
|
|
670
|
-
* JSON.stringify({ a: undefined, b: 1 }); // → '{"b":1}'
|
|
671
|
-
* JSON.parse('{"a": undefined, "b": 1}') // ❌ invalid JSON
|
|
672
|
-
*
|
|
673
|
-
* safeJsonParse('{"name": "John", "score": undefined}');
|
|
674
|
-
* // result → { name:"John", score:null } ← because `undefined` is not valid JSON, gets replaced
|
|
675
|
-
* ```
|
|
676
|
-
* Therefore, if you see `undefined` in raw input, it will likely throw unless pre-cleaned or replaced with `null`.
|
|
677
|
-
* @template TData - The expected output type after parsing and cleaning.
|
|
678
|
-
* @template TInput - The input value type, used for advanced type inference and return typing.
|
|
679
|
-
*
|
|
680
|
-
* @param {TInput} value - The JSON string or value to parse.
|
|
681
|
-
* @param {CleanParsedDataOptions} [options] - Options to clean, convert types, enable strict mode,
|
|
682
|
-
* support custom date formats, enable logging, or handle errors via callback.
|
|
683
|
-
*
|
|
684
|
-
* @returns {SafeJsonParseResult<TData, TInput>} Parsed and optionally cleaned result, or `null`/`undefined`.
|
|
685
|
-
*
|
|
686
|
-
* @throws {TypeError} If `options` is provided but not a valid object.
|
|
687
|
-
*
|
|
688
|
-
* @example
|
|
689
|
-
* 1. ***Basic parse with number & boolean conversion:***
|
|
690
|
-
* ```ts
|
|
691
|
-
* const result = safeJsonParse('{"age": "30", "isActive": "true"}', {
|
|
692
|
-
* convertNumbers: true,
|
|
693
|
-
* convertBooleans: true
|
|
694
|
-
* });
|
|
695
|
-
* // result → { age: 30, isActive: true }
|
|
696
|
-
* ```
|
|
697
|
-
* 2. ***Handling `undefined` in input string (manually written, not JSON.stringify):***
|
|
698
|
-
* ```ts
|
|
699
|
-
* const result = safeJsonParse('{"score": undefined}');
|
|
700
|
-
* // result → { score: null } ← because `undefined` is not valid JSON, gets replaced
|
|
701
|
-
* ```
|
|
702
|
-
*
|
|
703
|
-
* 3. ***Strict mode (removes invalid values):***
|
|
704
|
-
* ```ts
|
|
705
|
-
* const result = safeJsonParse('{"name": " ", "score": "99abc"}', {
|
|
706
|
-
* convertNumbers: true,
|
|
707
|
-
* strictMode: true
|
|
708
|
-
* });
|
|
709
|
-
* // result → {}
|
|
710
|
-
*
|
|
711
|
-
* const result2 = safeJsonParse('{"name": " ", "score": undefined}');
|
|
712
|
-
* // result2 → { name:"",score: null }
|
|
713
|
-
* ```
|
|
714
|
-
*
|
|
715
|
-
* 4. ***Custom date format parsing:***
|
|
716
|
-
* ```ts
|
|
717
|
-
* const result = safeJsonParse('{"birthday": "25/12/2000"}', {
|
|
718
|
-
* convertDates: true,
|
|
719
|
-
* customDateFormats: ["DD/MM/YYYY"]
|
|
720
|
-
* });
|
|
721
|
-
* // result → { birthday: new Date("2000-12-25T00:00:00.000Z") }
|
|
722
|
-
* ```
|
|
723
|
-
*
|
|
724
|
-
* 5. ***Invalid JSON with custom error handling:***
|
|
725
|
-
* ```ts
|
|
726
|
-
* safeJsonParse("{invalid}", {
|
|
727
|
-
* loggingOnFail: true,
|
|
728
|
-
* onError: (err) => console.log("Custom handler:", err.message)
|
|
729
|
-
* });
|
|
730
|
-
* // → Logs parsing error and invokes handler
|
|
731
|
-
* ```
|
|
732
|
-
*
|
|
733
|
-
* 6. ***Null or non-string input returns null/undefined:***
|
|
734
|
-
* ```ts
|
|
735
|
-
* safeJsonParse(null); // → null
|
|
736
|
-
* safeJsonParse(undefined); // → undefined
|
|
737
|
-
* safeJsonParse(123); // → undefined
|
|
738
|
-
* ```
|
|
739
|
-
*
|
|
740
|
-
* 7. ***Generic usage: Provide both output and input type to ensure correct return typing:***
|
|
741
|
-
* ```ts
|
|
742
|
-
* type UserType = { name: string };
|
|
743
|
-
*
|
|
744
|
-
* const obj = JSON.stringify({
|
|
745
|
-
* name: "John"
|
|
746
|
-
* });
|
|
747
|
-
*
|
|
748
|
-
* const toParse = isAuth() ? obj : null;
|
|
749
|
-
* const toParse2 = isAuth() ? obj : undefined;
|
|
750
|
-
*
|
|
751
|
-
* // * `Without Generic`:
|
|
752
|
-
* const parsed = safeJsonParse(toParse);
|
|
753
|
-
* //- runtime: { name: "John" } | undefined | null
|
|
754
|
-
* //- type: Record<string, unknown> | undefined | null
|
|
755
|
-
* const parsed2 = safeJsonParse(toParse);
|
|
756
|
-
* //- runtime: { name: "John" } | undefined
|
|
757
|
-
* //- type: Record<string, unknown> | undefined
|
|
758
|
-
*
|
|
759
|
-
* // * `With Generic`:
|
|
760
|
-
* const parsed = safeJsonParse<UserType>(toParse);
|
|
761
|
-
* //- runtime: { name: "John" } | undefined | null
|
|
762
|
-
* //- type: undefined ← (⚠ unexpected!)
|
|
763
|
-
* const parsed2 = safeJsonParse<UserType>(toParse);
|
|
764
|
-
* //- runtime: { name: "John" } | undefined
|
|
765
|
-
* //- type: undefined ← (⚠ unexpected!)
|
|
766
|
-
* const parsed = safeJsonParse<UserType, typeof toParse>(toParse);
|
|
767
|
-
* //- runtime: { name: "John" } | null | undefined
|
|
768
|
-
* //- type: UserType | null | undefined
|
|
769
|
-
* const parsed2 = safeJsonParse<UserType, typeof toParse>(toParse);
|
|
770
|
-
* //- runtime: { name: "John" } | undefined
|
|
771
|
-
* //- type: UserType | undefined
|
|
772
|
-
* ```
|
|
773
|
-
* @note
|
|
774
|
-
* ⚠ **Generic Behavior:**
|
|
775
|
-
* - This function supports advanced generic inference for clean, type-safe return values.
|
|
776
|
-
* - If only the first generic (`TData`) is provided and the second (`TInput`) is omitted,
|
|
777
|
-
* then `TInput` defaults to `undefined`, resulting in a return type of `undefined`.
|
|
778
|
-
* - To ensure correct return typing, **always pass both generics** when `value` is dynamic,
|
|
779
|
-
* nullable, or unioned: `safeJsonParse<TData, typeof value>(value)`.
|
|
780
|
-
* - This makes the returned type exactly match your expectation: `TData | null | undefined`.
|
|
781
|
-
*/
|
|
782
|
-
declare function safeJsonParse<TData extends Record<string,any>=Record<string,unknown>,TInput extends UnknownValue=UnknownValue>(value:TInput,options?:CleanParsedDataOptions):IsAny<TInput>extends true ? TData | null | undefined:undefined;declare function safeJsonParse<TData extends Record<string,any>=Record<string,unknown>,TInput extends string | null | undefined | unknown=undefined>(value:TInput,options?:CleanParsedDataOptions):SafeJsonParseResult<TData,TInput>;type Prev=[never,RangeNumberTo999<1,40>];type DotPath<T,Prefix extends string="",Depth extends number=RangeNumberTo999<1,40>>=Depth extends never ? never:T extends(infer U)[] ? U extends object ? DotPath<U,`${Prefix}`,Prev[Depth]>:never:T extends object ?{[K in Extract<keyof T,string>]:T[K] extends object ? DotPath<T[K],`${Prefix}${K}.`,Prev[Depth]>| `${Prefix}${K}`:`${Prefix}${K}`;}[Extract<keyof T,string>]:never;type ConfigRemoveObjectPaths<T>={key:DotPath<T>;deep?:boolean;};
|
|
783
|
-
/** ------------------------------------------------------------------------
|
|
784
|
-
* * ***Deletes multiple keys (shallow or deeply nested) from an object.***
|
|
785
|
-
* ------------------------------------------------------------------------
|
|
786
|
-
*
|
|
787
|
-
* ✅ Features:
|
|
788
|
-
* - Removes one or more keys from an object based on their paths (supports dot notation for nested).
|
|
789
|
-
* - Can delete deeply from all matching nested levels (even inside arrays) when `deep: true`.
|
|
790
|
-
* - By default does **not mutate** the original object. Clones it first.
|
|
791
|
-
* Set `deepClone = false` to mutate in place (useful for performance on large data).
|
|
792
|
-
* - Ensures type safety on `key` paths via `DotPath<T>`, reducing accidental invalid paths.
|
|
793
|
-
*
|
|
794
|
-
* 🔍 Behavior:
|
|
795
|
-
* - When `deep: false` (default), only deletes the direct property at the specified path.
|
|
796
|
-
* - When `deep: true`, searches deeply and recursively deletes the key from all levels,
|
|
797
|
-
* including inside arrays of objects (applies the *same* path repeatedly).
|
|
798
|
-
* - Can delete nested properties safely without throwing even if intermediate objects are missing.
|
|
799
|
-
*
|
|
800
|
-
* 🚀 Edge Handling:
|
|
801
|
-
* - Ignores invalid intermediate objects (will just skip that branch).
|
|
802
|
-
* - If `object` is `null` or not an object, returns an empty object.
|
|
803
|
-
* - Throws if `keysToDelete` is not a proper array of `{ key, deep? }` objects.
|
|
804
|
-
*
|
|
805
|
-
* @template T - The shape of the input object, used for type-safe dot paths.
|
|
806
|
-
*
|
|
807
|
-
* @param {T} object - The object to remove keys from. Must be an object or will return `{}`.
|
|
808
|
-
* @param {Array<{ key: DotPath<T>, deep?: boolean }>} keysToDelete -
|
|
809
|
-
* An array of instructions:
|
|
810
|
-
* - `key`: A string path using dot notation (e.g. `"user.profile.name"`).
|
|
811
|
-
* - `deep`: If `true`, will recursively remove all instances of the key path at any depth.
|
|
812
|
-
* @param {boolean} [deepClone=true] -
|
|
813
|
-
* Whether to deep clone the original object before modifying.
|
|
814
|
-
* - `true` (default): returns a *new object* with the specified keys removed.
|
|
815
|
-
* - `false`: modifies the original object in place and returns it.
|
|
816
|
-
*
|
|
817
|
-
* @returns {Partial<T>}
|
|
818
|
-
* - A new object with specified keys removed if `deepClone` is `true`.
|
|
819
|
-
* - The *same mutated object* if `deepClone` is `false`.
|
|
820
|
-
*
|
|
821
|
-
* @throws {TypeError}
|
|
822
|
-
* - If `object` is not an object.
|
|
823
|
-
* - If `keysToDelete` is not an array of `{ key, deep? }` objects.
|
|
824
|
-
*
|
|
825
|
-
* @example
|
|
826
|
-
* // 🟢 Shallow deletion
|
|
827
|
-
* removeObjectPaths(
|
|
828
|
-
* { a: 1, b: 2, c: { d: 3 } },
|
|
829
|
-
* [{ key: "b" }]
|
|
830
|
-
* );
|
|
831
|
-
* // => { a: 1, c: { d: 3 } }
|
|
832
|
-
*
|
|
833
|
-
* @example
|
|
834
|
-
* // 🟢 Nested deletion (shallow, removes only exact path)
|
|
835
|
-
* removeObjectPaths(
|
|
836
|
-
* { user: { profile: { name: "Alice", age: 30 } } },
|
|
837
|
-
* [{ key: "user.profile.age" }]
|
|
838
|
-
* );
|
|
839
|
-
* // => { user: { profile: { name: "Alice" } } }
|
|
840
|
-
*
|
|
841
|
-
* @example
|
|
842
|
-
* // 🔥 Deep deletion (recursively removes key from all levels and arrays)
|
|
843
|
-
* removeObjectPaths(
|
|
844
|
-
* { items: [{ price: 10 }, { price: 20, details: { price: 30 } }] },
|
|
845
|
-
* [{ key: "price", deep: true }]
|
|
846
|
-
* );
|
|
847
|
-
* // => { items: [{}, { details: {} }] }
|
|
848
|
-
*
|
|
849
|
-
* @example
|
|
850
|
-
* // 📝 Without cloning: mutates original object
|
|
851
|
-
* const obj = { x: 1, y: 2 };
|
|
852
|
-
* removeObjectPaths(obj, [{ key: "y" }], false);
|
|
853
|
-
* console.log(obj); // => { x: 1 }
|
|
854
|
-
*
|
|
855
|
-
* @example
|
|
856
|
-
* // 🚫 Invalid usage throws
|
|
857
|
-
* removeObjectPaths(42, [{ key: "a" }]);
|
|
858
|
-
* // => throws TypeError
|
|
859
|
-
*/
|
|
860
|
-
declare const removeObjectPaths:<T extends Record<string,unknown>>(object:T,keysToDelete:ConfigRemoveObjectPaths<T>[],deepClone?:boolean)=>Partial<T>;
|
|
861
|
-
/** --------------------------------------------
|
|
862
|
-
* * ***Safely converts a JavaScript value into a stable, JSON-compatible string.***
|
|
863
|
-
* --------------------------------------------
|
|
864
|
-
*
|
|
865
|
-
* Features:
|
|
866
|
-
* - Recursively sorts object keys if `sortKeys` is true, to ensure stable key order.
|
|
867
|
-
* - Optionally sorts array values if `ignoreOrder` is true (only sorts shallow primitives inside arrays).
|
|
868
|
-
* - Removes functions and symbols (they are omitted from the output).
|
|
869
|
-
* - Converts `undefined`, `NaN`, `Infinity`, `-Infinity` to `null`.
|
|
870
|
-
* - Converts `BigInt` to a string (since JSON does not support it).
|
|
871
|
-
* - Handles circular references by replacing them with the string `"[Circular]"`.
|
|
872
|
-
* - Serializes:
|
|
873
|
-
* - `Date` instances as ISO strings.
|
|
874
|
-
* - `Map` as `{ map: [ [key, value], ... ] }`.
|
|
875
|
-
* - `Set` as `{ set: [values...] }`.
|
|
876
|
-
*
|
|
877
|
-
* Compared to `JSON.stringify`, this ensures **stable output**:
|
|
878
|
-
* - Same object structure always produces the same string.
|
|
879
|
-
* - Useful for deep equality checks, hashing, caching keys, or snapshot tests.
|
|
880
|
-
*
|
|
881
|
-
* @param {unknown} value
|
|
882
|
-
* The value to serialize. Can be primitives, objects, arrays, Maps, Sets, Dates, etc.
|
|
883
|
-
*
|
|
884
|
-
* @param {boolean} [sortKeys=true]
|
|
885
|
-
* Whether to sort object keys alphabetically (recursively). If `false`, preserves original insertion order.
|
|
886
|
-
*
|
|
887
|
-
* @param {boolean} [ignoreOrder=false]
|
|
888
|
-
* Whether to sort array primitive values. When `true`:
|
|
889
|
-
* - Only primitive values in arrays are sorted.
|
|
890
|
-
* - Objects and nested arrays keep their position and are placed after sorted primitives.
|
|
891
|
-
* If `false`, arrays retain their original order.
|
|
892
|
-
*
|
|
893
|
-
* @param {boolean} [pretty=false]
|
|
894
|
-
* If `true`, output is formatted with 2-space indentation and newlines (pretty-printed).
|
|
895
|
-
* If `false`, produces compact single-line JSON.
|
|
896
|
-
*
|
|
897
|
-
* @returns {string}
|
|
898
|
-
* A stable JSON string representation of the input value.
|
|
899
|
-
*
|
|
900
|
-
* @throws {TypeError}
|
|
901
|
-
* Throws if `sortKeys`, `ignoreOrder`, or `pretty` are not strictly boolean.
|
|
902
|
-
*
|
|
903
|
-
* @example
|
|
904
|
-
* // Basic object key sorting
|
|
905
|
-
* safeStableStringify({ b: 2, a: 1 });
|
|
906
|
-
* // => '{"a":1,"b":2}'
|
|
907
|
-
*
|
|
908
|
-
* @example
|
|
909
|
-
* // Disable key sorting (preserve insertion order)
|
|
910
|
-
* safeStableStringify({ b: 2, a: 1 }, false);
|
|
911
|
-
* // => '{"b":2,"a":1}'
|
|
912
|
-
*
|
|
913
|
-
* @example
|
|
914
|
-
* // Sorting arrays
|
|
915
|
-
* safeStableStringify([3, 1, 2], true, true);
|
|
916
|
-
* // => '[1,2,3]'
|
|
917
|
-
*
|
|
918
|
-
* @example
|
|
919
|
-
* // Nested object + ignoreOrder=true
|
|
920
|
-
* safeStableStringify({ z: [3, 1, 2], x: { d: 4, c: 3 } }, true, true);
|
|
921
|
-
* // => '{"x":{"c":3,"d":4},"z":[1,2,3]}'
|
|
922
|
-
*
|
|
923
|
-
* @example
|
|
924
|
-
* // sortKeys=false and ignoreOrder=true
|
|
925
|
-
* safeStableStringify({ z: [3, 1, 2], x: { d: 4, c: 3 } }, false, true);
|
|
926
|
-
* // => '{"z":[1,2,3],"x":{"d":4,"c":3}}'
|
|
927
|
-
*
|
|
928
|
-
* @example
|
|
929
|
-
* // pretty print output
|
|
930
|
-
* safeStableStringify([3, 1, 2], true, true, true);
|
|
931
|
-
* // => `[
|
|
932
|
-
* // 1,
|
|
933
|
-
* // 2,
|
|
934
|
-
* // 3
|
|
935
|
-
* // ]`
|
|
936
|
-
*
|
|
937
|
-
* @example
|
|
938
|
-
* // Handles Date, BigInt, Map and Set
|
|
939
|
-
* safeStableStringify({
|
|
940
|
-
* time: new Date("2025-01-01"),
|
|
941
|
-
* big: BigInt(9007199254740991),
|
|
942
|
-
* data: new Map([["key", new Set([1, 2])]])
|
|
943
|
-
* });
|
|
944
|
-
* // => '{"big":"9007199254740991","data":{"map":[["key",{"set":[1,2]}]]},"time":"2025-01-01T00:00:00.000Z"}'
|
|
945
|
-
*
|
|
946
|
-
* @example
|
|
947
|
-
* // Functions and symbols are removed
|
|
948
|
-
* safeStableStringify({ f: () => {}, s: Symbol("wow") });
|
|
949
|
-
* // => '{}'
|
|
950
|
-
*
|
|
951
|
-
* @example
|
|
952
|
-
* // undefined, NaN, Infinity convert to null
|
|
953
|
-
* safeStableStringify([undefined, NaN, Infinity, -Infinity]);
|
|
954
|
-
* // => '[null,null,null,null]'
|
|
955
|
-
*
|
|
956
|
-
* @example
|
|
957
|
-
* // Circular reference
|
|
958
|
-
* const obj = { name: "A" };
|
|
959
|
-
* obj.self = obj;
|
|
960
|
-
* safeStableStringify(obj);
|
|
961
|
-
* // => '{"name":"A","self":"[Circular]"}'
|
|
962
|
-
*
|
|
963
|
-
* @example
|
|
964
|
-
* // Complex nested ignoreOrder with objects
|
|
965
|
-
* const arr = [9, 7, [4, 2, 3], { z: [5, 1, 6] }];
|
|
966
|
-
* safeStableStringify(arr, true, true);
|
|
967
|
-
* // => '[7,9,[2,3,4],{"z":[1,5,6]}]'
|
|
968
|
-
*/
|
|
969
|
-
declare const safeStableStringify:(value:unknown,sortKeys?:boolean,ignoreOrder?:boolean,pretty?:boolean)=>string;
|
|
970
|
-
/** ----------------------------------------------------------
|
|
971
|
-
* * ***Recursively converts a value into a string based on the `forceToString` option.***
|
|
972
|
-
* ----------------------------------------------------------
|
|
973
|
-
*
|
|
974
|
-
* - `"stringOrNumber"`: Converts strings and numbers to strings.
|
|
975
|
-
* - `"primitives"`: Converts all primitives (number, string, boolean, bigint, undefined, null, NaN) to strings.
|
|
976
|
-
* - `"all"`: Converts everything, including symbols, functions, Dates, RegExp, Maps, Sets, Errors, Promises,
|
|
977
|
-
* and deeply all object properties, to strings.
|
|
978
|
-
* - `false` (default): Leaves everything unchanged.
|
|
979
|
-
*
|
|
980
|
-
* Special behaviors:
|
|
981
|
-
* - `NaN` → `"NaN"` only in `"primitives"` or `"all"` mode.
|
|
982
|
-
* - `Date` → ISO string only in `"all"` mode.
|
|
983
|
-
* - `RegExp` → Source string (e.g. `/abc/i`) only in `"all"` mode.
|
|
984
|
-
* - `Symbol` → `Symbol(description)` string only in `"all"` mode.
|
|
985
|
-
* - `Map` → Array of [key, value] pairs with keys/values stringified deeply (only in `"all"` mode).
|
|
986
|
-
* - `Set` → Array of values stringified deeply (only in `"all"` mode).
|
|
987
|
-
* - `Function` → Source code string (e.g. `"() => 1"`) only in `"all"` mode.
|
|
988
|
-
* - `Error`, `Promise` → Stringified via `.toString()` only in `"all"` mode.
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
* @param {unknown} value - The value to process. Can be anything: primitive, array, object, function, etc.
|
|
992
|
-
* @param {false | "stringOrNumber" | "primitives" | "all"} forceToString - The mode of string conversion.
|
|
993
|
-
* @returns {unknown} A new value with the conversion applied based on `forceToString`.
|
|
994
|
-
*
|
|
995
|
-
* @example
|
|
996
|
-
* toStringDeepForce(42, "stringOrNumber");
|
|
997
|
-
* // => "42"
|
|
998
|
-
*
|
|
999
|
-
* @example
|
|
1000
|
-
* toStringDeepForce(true, "primitives");
|
|
1001
|
-
* // => "true"
|
|
1002
|
-
*
|
|
1003
|
-
* @example
|
|
1004
|
-
* toStringDeepForce(null, "primitives");
|
|
1005
|
-
* // => "null"
|
|
1006
|
-
*
|
|
1007
|
-
* @example
|
|
1008
|
-
* toStringDeepForce(Symbol("x"), "all");
|
|
1009
|
-
* // => "Symbol(x)"
|
|
1010
|
-
*
|
|
1011
|
-
* @example
|
|
1012
|
-
* toStringDeepForce({ a: 1, b: [2, NaN] }, "primitives");
|
|
1013
|
-
* // => { a: "1", b: ["2", "NaN"] }
|
|
1014
|
-
*
|
|
1015
|
-
* @example
|
|
1016
|
-
* toStringDeepForce(new Date("2025-01-01"), "all");
|
|
1017
|
-
* // => "2025-01-01T00:00:00.000Z"
|
|
1018
|
-
*
|
|
1019
|
-
* @example
|
|
1020
|
-
* toStringDeepForce(() => 1, "all");
|
|
1021
|
-
* // => "() => 1"
|
|
1022
|
-
*
|
|
1023
|
-
* @example
|
|
1024
|
-
* toStringDeepForce(/abc/i, "all");
|
|
1025
|
-
* // => "/abc/i"
|
|
1026
|
-
*
|
|
1027
|
-
* @example
|
|
1028
|
-
* toStringDeepForce(new Map([["a", 1], ["b", 2]]), "all");
|
|
1029
|
-
* // => [["a", "1"], ["b", "2"]]
|
|
1030
|
-
*
|
|
1031
|
-
* @example
|
|
1032
|
-
* toStringDeepForce(new Set([1, 2, 3]), "all");
|
|
1033
|
-
* // => ["1", "2", "3"]
|
|
1034
|
-
*
|
|
1035
|
-
* @example
|
|
1036
|
-
* toStringDeepForce(new Error("Oops"), "all");
|
|
1037
|
-
* // => "Error: Oops"
|
|
1038
|
-
*
|
|
1039
|
-
* @example
|
|
1040
|
-
* toStringDeepForce(Promise.resolve(1), "all");
|
|
1041
|
-
* // => "[object Promise]"
|
|
1042
|
-
*
|
|
1043
|
-
* @example
|
|
1044
|
-
* toStringDeepForce({ func: () => 123 }, "all");
|
|
1045
|
-
* // => { func: "() => 123" }
|
|
1046
|
-
*
|
|
1047
|
-
* @example
|
|
1048
|
-
* toStringDeepForce([1, "a", { b: 2 }], false);
|
|
1049
|
-
* // => [1, "a", { b: 2 }]
|
|
1050
|
-
*/
|
|
1051
|
-
declare const toStringDeepForce:(value:unknown,forceToString:false | "stringOrNumber" | "primitives" | "all")=>unknown;type ConvertedDeepNumber<T,RemoveEmptyObjects extends boolean,RemoveEmptyArrays extends boolean>=T extends null | undefined ? never:T extends number | `${number}` ? number:T extends any[] ? ConvertedDeepNumber<T[number],RemoveEmptyObjects,RemoveEmptyArrays>[]:T extends Record<string,unknown>?{[K in keyof T]:ConvertedDeepNumber<T[K],RemoveEmptyObjects,RemoveEmptyArrays>;}extends infer O ? RemoveEmptyObjects extends true ? keyof O extends never ? never:O:O:never:never;
|
|
1052
|
-
/** --------------------------------------------------
|
|
1053
|
-
* * ***Converts deeply nested arrays or objects into number while preserving structure.***
|
|
1054
|
-
* --------------------------------------------------
|
|
1055
|
-
*
|
|
1056
|
-
* Features:
|
|
1057
|
-
* - ✅ Removes `null`, `undefined`, NaN, Infinity, and non-numeric values.
|
|
1058
|
-
* - 🔄 Recursively processes nested objects and arrays.
|
|
1059
|
-
* - 🔢 Converts valid number, including decimals (e.g. `"3.5"` → `3.5`).
|
|
1060
|
-
* - 🧹 Can remove empty objects `{}` or arrays `[]` based on flags.
|
|
1061
|
-
*
|
|
1062
|
-
* @template T - The input data type (Array, Object, etc)
|
|
1063
|
-
* @template RemoveEmptyObjects - Whether to remove empty objects
|
|
1064
|
-
* @template RemoveEmptyArrays - Whether to remove empty arrays
|
|
1065
|
-
*
|
|
1066
|
-
* @param {T} input - The data to convert
|
|
1067
|
-
* @param {boolean} [removeEmptyObjects=false] - Remove empty objects `{}` if `true`
|
|
1068
|
-
* @param {boolean} [removeEmptyArrays=false] - Remove empty arrays `[]` if `true`
|
|
1069
|
-
*
|
|
1070
|
-
* @returns {ConvertedDeepNumber<T, RemoveEmptyObjects, RemoveEmptyArrays> | undefined}
|
|
1071
|
-
* The transformed data, or `undefined` if entirely empty after processing.
|
|
1072
|
-
*
|
|
1073
|
-
* @example
|
|
1074
|
-
* toNumberDeep("123") // → 123
|
|
1075
|
-
* toNumberDeep("12.34") // → 12.34
|
|
1076
|
-
* toNumberDeep("not number") // → undefined
|
|
1077
|
-
*
|
|
1078
|
-
* @example
|
|
1079
|
-
* toNumberDeep([NaN, Infinity, -Infinity, "10"])
|
|
1080
|
-
* // → [10]
|
|
1081
|
-
*
|
|
1082
|
-
* @example
|
|
1083
|
-
* toNumberDeep({ a: {}, b: [] }, false, false)
|
|
1084
|
-
* // → { a: {}, b: [] }
|
|
1085
|
-
*
|
|
1086
|
-
* @example
|
|
1087
|
-
* toNumberDeep({ a: {}, b: [] }, true, false)
|
|
1088
|
-
* // → { b: [] }
|
|
1089
|
-
*
|
|
1090
|
-
* @example
|
|
1091
|
-
* toNumberDeep({ a: {}, b: [] }, false, true)
|
|
1092
|
-
* // → { a: {} }
|
|
1093
|
-
*
|
|
1094
|
-
* @example
|
|
1095
|
-
* toNumberDeep({ a: {}, b: [], c: { d: null } }, true, true)
|
|
1096
|
-
* // → {}
|
|
1097
|
-
*
|
|
1098
|
-
* @example
|
|
1099
|
-
* toNumberDeep({
|
|
1100
|
-
* a: "1",
|
|
1101
|
-
* b: {
|
|
1102
|
-
* c: "not num",
|
|
1103
|
-
* d: ["2", "3.5", null, { e: "4.4", f: "invalid" }],
|
|
1104
|
-
* },
|
|
1105
|
-
* g: [],
|
|
1106
|
-
* })
|
|
1107
|
-
* // → { a: 1, b: { d: [2, 3.5, { e: 4.4 }] }, g: [] }
|
|
1108
|
-
*
|
|
1109
|
-
* @example
|
|
1110
|
-
* toNumberDeep({ x: {}, y: [], z: [{ a: {}, b: [] }] }, false, true)
|
|
1111
|
-
* // → { x: {}, z: [{ a: {} }] }
|
|
1112
|
-
*
|
|
1113
|
-
* @example
|
|
1114
|
-
* toNumberDeep({ x: {}, y: [], z: [{ a: {}, b: [] }] }, true, false)
|
|
1115
|
-
* // → { y: [], z: [{ b: [] }] }
|
|
1116
|
-
*
|
|
1117
|
-
* @example
|
|
1118
|
-
* toNumberDeep({
|
|
1119
|
-
* x: {},
|
|
1120
|
-
* y: [],
|
|
1121
|
-
* z: [{ a: {}, b: [], c: "3" }, { d: "4.5" }]
|
|
1122
|
-
* }, true, true)
|
|
1123
|
-
* // → { z: [{ c: 3 }, { d: 4.5 }] }
|
|
1124
|
-
*
|
|
1125
|
-
* @example
|
|
1126
|
-
* toNumberDeep([[[[[["1"]]], null]], "2", "abc"], false, true)
|
|
1127
|
-
* // → [[[[[[1]]]]], 2]
|
|
1128
|
-
*
|
|
1129
|
-
* @example
|
|
1130
|
-
* toNumberDeep(["1", {}, [], ["2", {}, []]], true, true)
|
|
1131
|
-
* // → [1, [2]]
|
|
1132
|
-
*
|
|
1133
|
-
* @example
|
|
1134
|
-
* toNumberDeep(["1", () => {}, Symbol("wow"), "2"])
|
|
1135
|
-
* // → [1, 2]
|
|
1136
|
-
*
|
|
1137
|
-
* @example
|
|
1138
|
-
* toNumberDeep({ a: { b: {} } }, false, true)
|
|
1139
|
-
* // → { a: { b: {} } }
|
|
1140
|
-
*
|
|
1141
|
-
* @example
|
|
1142
|
-
* toNumberDeep(["1", { a: {} }], true)
|
|
1143
|
-
* // → [1]
|
|
1144
|
-
*
|
|
1145
|
-
* @example
|
|
1146
|
-
* toNumberDeep(["1", { a: {} }], false)
|
|
1147
|
-
* // → [1, { a: {} }]
|
|
1148
|
-
*
|
|
1149
|
-
* @example
|
|
1150
|
-
* toNumberDeep(["1", [], { a: [] }], false, false)
|
|
1151
|
-
* // → [1, [], { a: [] }]
|
|
1152
|
-
*/
|
|
1153
|
-
declare const toNumberDeep:<T extends unknown,RemoveEmptyObjects extends boolean=false,RemoveEmptyArrays extends boolean=false>(input:T,removeEmptyObjects?:RemoveEmptyObjects,removeEmptyArrays?:RemoveEmptyArrays)=>ConvertedDeepNumber<T,RemoveEmptyObjects,RemoveEmptyArrays>| undefined;type ConvertedDeepString<T,RemoveEmptyObjects extends boolean,RemoveEmptyArrays extends boolean>=T extends null | undefined ? never:T extends number | string ? string:T extends any[] ? ConvertedDeepString<T[number],RemoveEmptyObjects,RemoveEmptyArrays>[]:T extends Record<string,unknown>?{[K in keyof T]:ConvertedDeepString<T[K],RemoveEmptyObjects,RemoveEmptyArrays>;}extends infer O ? RemoveEmptyObjects extends true ? keyof O extends never ? never:O:O:never:never;
|
|
1154
|
-
/**
|
|
1155
|
-
* --------------------------------------------------
|
|
1156
|
-
* * ***Converts all values in an array, object, or deeply nested structure to string.***
|
|
1157
|
-
* --------------------------------------------------
|
|
1158
|
-
*
|
|
1159
|
-
* - ✅ Converts number and string to string format (e.g., `123 → "123"`).
|
|
1160
|
-
* - ✅ Keeps existing string as string.
|
|
1161
|
-
* - ✅ Removes `null`, `undefined`, `NaN`, `Infinity`, `-Infinity`.
|
|
1162
|
-
* - ✅ Removes non-primitive types like functions, symbols, and bigints.
|
|
1163
|
-
* - ✅ Processes deeply nested arrays and objects.
|
|
1164
|
-
* - ✅ Supports removing empty objects `{}` and empty arrays `[]` via flags.
|
|
1165
|
-
*
|
|
1166
|
-
* @template T - The input data type (array, object, or any nested combination).
|
|
1167
|
-
* @template RemoveEmptyObjects - If `true`, empty objects `{}` will be removed recursively.
|
|
1168
|
-
* @template RemoveEmptyArrays - If `true`, empty arrays `[]` will be removed recursively.
|
|
1169
|
-
*
|
|
1170
|
-
* @param {T} input - The input array, object, or value to convert.
|
|
1171
|
-
* @param {boolean} [removeEmptyObjects=false] - Whether to remove empty objects `{}`.
|
|
1172
|
-
* @param {boolean} [removeEmptyArrays=false] - Whether to remove empty arrays `[]`.
|
|
1173
|
-
*
|
|
1174
|
-
* @returns {ConvertedDeepString<T, RemoveEmptyObjects, RemoveEmptyArrays> | undefined}
|
|
1175
|
-
* The converted data structure with all values as string, or `undefined` if completely empty.
|
|
1176
|
-
*
|
|
1177
|
-
* @example
|
|
1178
|
-
* // Simple array conversion
|
|
1179
|
-
* toStringDeep([1, "2", 3])
|
|
1180
|
-
* // → ["1", "2", "3"]
|
|
1181
|
-
*
|
|
1182
|
-
* @example
|
|
1183
|
-
* // Nested arrays
|
|
1184
|
-
* toStringDeep([1, ["2", [3, [null, "4"]]]])
|
|
1185
|
-
* // → ["1", ["2", ["3", ["4"]]]]
|
|
1186
|
-
*
|
|
1187
|
-
* @example
|
|
1188
|
-
* // Object with nested values
|
|
1189
|
-
* toStringDeep({ a: 1, b: "2", c: { d: 3, e: null } })
|
|
1190
|
-
* // → { a: "1", b: "2", c: { d: "3" } }
|
|
1191
|
-
*
|
|
1192
|
-
* @example
|
|
1193
|
-
* // Removing empty objects
|
|
1194
|
-
* toStringDeep({ a: {}, b: "1" }, true, false)
|
|
1195
|
-
* // → { b: "1" }
|
|
1196
|
-
*
|
|
1197
|
-
* @example
|
|
1198
|
-
* // Removing empty arrays
|
|
1199
|
-
* toStringDeep(["1", [], { a: [] }], false, true)
|
|
1200
|
-
* // → ["1", { a: [] }]
|
|
1201
|
-
*
|
|
1202
|
-
* @example
|
|
1203
|
-
* // Removing both empty objects and arrays deeply
|
|
1204
|
-
* toStringDeep({ a: {}, b: [], c: [{ d: {}, e: [] }, "1"] }, true, true)
|
|
1205
|
-
* // → { c: ["1"] }
|
|
1206
|
-
*
|
|
1207
|
-
* @example
|
|
1208
|
-
* // Fully empty structure after processing becomes undefined
|
|
1209
|
-
* toStringDeep([null, undefined, {}], true, true)
|
|
1210
|
-
* // → undefined
|
|
1211
|
-
*/
|
|
1212
|
-
declare const toStringDeep:<T extends unknown,RemoveEmptyObjects extends boolean=false,RemoveEmptyArrays extends boolean=false>(input:T,removeEmptyObjects?:RemoveEmptyObjects,removeEmptyArrays?:RemoveEmptyArrays)=>ConvertedDeepString<T,RemoveEmptyObjects,RemoveEmptyArrays>| undefined;type ValueFormatPhoneNumber=string | number | null;type FormatPhoneNumberProps={
|
|
1213
|
-
/** @default " " */
|
|
1214
|
-
separator?:string;
|
|
1215
|
-
/** @default "" */
|
|
1216
|
-
plusNumberCountry?:string;
|
|
1217
|
-
/** @default "" */
|
|
1218
|
-
openingNumberCountry?:string;
|
|
1219
|
-
/** @default "" */
|
|
1220
|
-
closingNumberCountry?:string;
|
|
1221
|
-
/** @default false */
|
|
1222
|
-
checkValidOnly?:boolean;
|
|
1223
|
-
/** @default false */
|
|
1224
|
-
takeNumberOnly?:boolean;};type FormatPhoneNumberPropsString=OmitStrict<FormatPhoneNumberProps,"checkValidOnly" | "takeNumberOnly">&{
|
|
1225
|
-
/** @default false */
|
|
1226
|
-
checkValidOnly?:false;
|
|
1227
|
-
/** @default false */
|
|
1228
|
-
takeNumberOnly?:false;};type FormatPhoneNumberPropsBoolean=OmitStrict<FormatPhoneNumberProps,"separator" | "plusNumberCountry" | "closingNumberCountry" | "openingNumberCountry" | "takeNumberOnly">;type FormatPhoneNumberPropsTransform=OmitStrict<FormatPhoneNumberProps,"separator" | "plusNumberCountry" | "closingNumberCountry" | "openingNumberCountry" | "checkValidOnly">;type ScrollToTopOptions={
|
|
1229
|
-
/** `"auto" | "instant" | "smooth"` defaults value `"smooth"` */
|
|
1230
|
-
behavior?:ScrollBehavior | undefined;
|
|
1231
|
-
/** `number | undefined` defaults value `1` as `ms` */
|
|
1232
|
-
timeout?:number | undefined;};type RandomStringOptions={
|
|
1233
|
-
/** Ensures no whitespace characters in the generated string. Default: `true`. */
|
|
1234
|
-
avoidWhiteSpace?:boolean;
|
|
1235
|
-
/** Custom characters to replace the default number set if `type` is "number". */
|
|
1236
|
-
replaceGenInt?:string;
|
|
1237
|
-
/** Custom characters to replace the default string set if `type` is "string". */
|
|
1238
|
-
replaceGenStr?:string;
|
|
1239
|
-
/** Additional characters to include in the generated string. */
|
|
1240
|
-
addChar?:string;
|
|
1241
|
-
/** Minimum length of the generated string (1 to 5000). Default: `40`. */
|
|
1242
|
-
minLength?:number;
|
|
1243
|
-
/** Maximum length of the generated string (1 to 5000). Default: `40`. */
|
|
1244
|
-
maxLength?:number;
|
|
1245
|
-
/** Type of output: "string" (default) or "number". */
|
|
1246
|
-
type?:"string" | "number";};
|
|
1247
|
-
/** ----------------------------------------------------------
|
|
1248
|
-
* * ***Disables user interaction by adding a CSS class to the `<html>` element.***
|
|
1249
|
-
* ----------------------------------------------------------
|
|
1250
|
-
*
|
|
1251
|
-
* - Works only in **browser environments** (does nothing on the server-side).
|
|
1252
|
-
* - Prevents multiple additions of the same class.
|
|
1253
|
-
* - Can be used to indicate that a process is ongoing (e.g., loading state).
|
|
1254
|
-
*
|
|
1255
|
-
* @param {string} className - The CSS class to add (default: `"on_processing"`).
|
|
1256
|
-
* @returns {void}
|
|
1257
|
-
*
|
|
1258
|
-
* @example
|
|
1259
|
-
* disableUserInteraction(); // Adds "on_processing" class to <html>
|
|
1260
|
-
* disableUserInteraction("loading"); // Adds "loading" class to <html>
|
|
1261
|
-
*/
|
|
1262
|
-
declare const disableUserInteraction:(className?:string)=>void;
|
|
1263
|
-
/** ----------------------------------------------------------
|
|
1264
|
-
* * ***Enables user interaction by removing a CSS class from the `<html>` element.***
|
|
1265
|
-
* ----------------------------------------------------------
|
|
1266
|
-
*
|
|
1267
|
-
* - Works only in **browser environments** (does nothing on the server-side).
|
|
1268
|
-
* - Prevents errors if the class is already removed.
|
|
1269
|
-
* - Can be used to re-enable interactions after a process completes.
|
|
1270
|
-
*
|
|
1271
|
-
* @param {string} className - The CSS class to remove (default: `"on_processing"`).
|
|
1272
|
-
* @returns {void}
|
|
1273
|
-
*
|
|
1274
|
-
* @example
|
|
1275
|
-
* enableUserInteraction(); // Removes "on_processing" class from <html>
|
|
1276
|
-
* enableUserInteraction("loading"); // Removes "loading" class from <html>
|
|
1277
|
-
*/
|
|
1278
|
-
declare const enableUserInteraction:(className?:string)=>void;
|
|
1279
|
-
/** ----------------------------------------------------------
|
|
1280
|
-
* * ***Removes focus from the currently active element.***
|
|
1281
|
-
* ----------------------------------------------------------
|
|
1282
|
-
*
|
|
1283
|
-
* - Works only in **browser environments** (does nothing on the server-side).
|
|
1284
|
-
* - If an element is focused, it will lose focus.
|
|
1285
|
-
* - Logs a warning if no element is focused.
|
|
1286
|
-
*
|
|
1287
|
-
* @returns {void}
|
|
1288
|
-
*
|
|
1289
|
-
* @example
|
|
1290
|
-
* removeElementFocus(); // Removes focus from an active currently element.
|
|
1291
|
-
*/
|
|
1292
|
-
declare const removeElementFocus:()=>void;
|
|
1293
|
-
/** ----------------------------------------------------------
|
|
1294
|
-
* * ***Scrolls the page to the top with default smooth and extra optional settings.***
|
|
1295
|
-
* ----------------------------------------------------------
|
|
1296
|
-
*
|
|
1297
|
-
* - Works only in **browser environments** (does nothing on the server).
|
|
1298
|
-
* - Supports a **timeout delay** before scrolling.
|
|
1299
|
-
* - Uses the **native `window.scrollTo()`** API with smooth scrolling.
|
|
1300
|
-
*
|
|
1301
|
-
* @param {ScrollToTopOptions} [options] - Scrolling behavior options.
|
|
1302
|
-
* @param {ScrollBehavior} [options.behavior="smooth"] - The scroll behavior (`"auto"`,`"instant"` or `"smooth"`), default value is `"smooth"`.
|
|
1303
|
-
* @param {number} [options.timeout=1] - Delay (in milliseconds) before scrolling starts.
|
|
1304
|
-
* @returns {void}
|
|
1305
|
-
*
|
|
1306
|
-
* @example
|
|
1307
|
-
* smoothScrollToTop(); // Scrolls to top smoothly with 1ms delay
|
|
1308
|
-
* smoothScrollToTop({ behavior: "auto" }); // Instantly jumps to the top
|
|
1309
|
-
* smoothScrollToTop({ timeout: 500 }); // Scrolls to top after 500ms
|
|
1310
|
-
*/
|
|
1311
|
-
declare const scrollToTop:(options?:ScrollToTopOptions)=>void;type NegativeFormatOption="dash" | "brackets" | "abs" |{
|
|
1312
|
-
/**
|
|
1313
|
-
* Custom formatter function for the final formatted negative string.
|
|
1314
|
-
* If provided, it OVERRIDES style & space entirely.
|
|
1315
|
-
*/
|
|
1316
|
-
custom:(formatted:string)=>string;style?:never;space?:never;}|{custom?:never;
|
|
1317
|
-
/**
|
|
1318
|
-
* Use style & optional spacing for negative numbers.
|
|
1319
|
-
* @default "dash"
|
|
1320
|
-
*/
|
|
1321
|
-
style?:"dash" | "brackets" | "abs";
|
|
1322
|
-
/** @default false */
|
|
1323
|
-
space?:boolean;};type FormatCurrencyOptions={
|
|
1324
|
-
/** `Default: "."` */
|
|
1325
|
-
suffixCurrency?:string;
|
|
1326
|
-
/** `Default: "."` */
|
|
1327
|
-
separator?:string;
|
|
1328
|
-
/** `Default: false` */
|
|
1329
|
-
decimal?:boolean;
|
|
1330
|
-
/** `Default: 2` */
|
|
1331
|
-
totalDecimal?:number;
|
|
1332
|
-
/** `Default: true` */
|
|
1333
|
-
endDecimal?:boolean;
|
|
1334
|
-
/** `Default: ""` */
|
|
1335
|
-
suffixDecimal?:string;
|
|
1336
|
-
/** `Default: "round"` */
|
|
1337
|
-
roundedDecimal?:"round" | "ceil" | "floor" | false;
|
|
1338
|
-
/** `Default: ","` */
|
|
1339
|
-
separatorDecimals?:string;
|
|
1340
|
-
/** @default "dash" */
|
|
1341
|
-
negativeFormat?:NegativeFormatOption;
|
|
1342
|
-
/** @default false */
|
|
1343
|
-
indianFormat?:boolean;};
|
|
1344
|
-
/** -------------------------------------------------------
|
|
1345
|
-
* * Formats a number or messy currency string into a
|
|
1346
|
-
* beautifully formatted currency string, with highly
|
|
1347
|
-
* customizable separators, decimal control, rounding,
|
|
1348
|
-
* currency symbols, and negative styling.
|
|
1349
|
-
* -------------------------------------------------------
|
|
1350
|
-
*
|
|
1351
|
-
* ✅ Highlights:
|
|
1352
|
-
* - Accepts:
|
|
1353
|
-
* * Pure numbers: `15300.95`
|
|
1354
|
-
* * Messy currency strings from **any locale**:
|
|
1355
|
-
* - `"Rp 15.000,21"` (Indonesian / Euro)
|
|
1356
|
-
* - `"$12,345.60"` (US)
|
|
1357
|
-
* - `"CHF 12'345.60"` (Swiss)
|
|
1358
|
-
* - `"1,23,456.78"` (Indian)
|
|
1359
|
-
* - Auto extracts numeric value with smart multi-locale parsing
|
|
1360
|
-
* via `parseCurrencyString`.
|
|
1361
|
-
* - Handles:
|
|
1362
|
-
* * Thousands separators: `.`, `,`, `'`, ` `
|
|
1363
|
-
* * Decimal separators: `,`, `.`
|
|
1364
|
-
* * Decimal suffix (eg. `".-"`, `" USD"`)
|
|
1365
|
-
* * Currency prefix (eg. `"Rp "`, `"$ "`)
|
|
1366
|
-
* * Rounding: `"round"`, `"ceil"`, `"floor"`, or truncate
|
|
1367
|
-
* * Negative styling: dash `-`, brackets `( )`, absolute, or custom
|
|
1368
|
-
* - Strong type checks & clear errors for misconfigured options.
|
|
1369
|
-
*
|
|
1370
|
-
* ✅ How input is parsed:
|
|
1371
|
-
* - Removes all non-digit except `.`, `,`, `'` and spaces.
|
|
1372
|
-
* - Detects bracket negatives: `"(15.000,10)"` ➔ `-15000.10`
|
|
1373
|
-
* - Uses last `,` or `.` as decimal separator (others are thousands).
|
|
1374
|
-
* - Ignores currency symbols like `Rp`, `$` (must re-apply with `suffixCurrency`).
|
|
1375
|
-
*
|
|
1376
|
-
* ✅ Options:
|
|
1377
|
-
* @param {string|number} value
|
|
1378
|
-
* The input value to format.
|
|
1379
|
-
* Examples:
|
|
1380
|
-
* * `"Rp 15.000,21"`
|
|
1381
|
-
* * `"$12,345.60"`
|
|
1382
|
-
* * `"CHF 12'345.60"`
|
|
1383
|
-
* * `15300.95`
|
|
1384
|
-
*
|
|
1385
|
-
* @param {FormatCurrencyOptions} [options]
|
|
1386
|
-
* Optional configuration object:
|
|
1387
|
-
*
|
|
1388
|
-
* @property {string} separator
|
|
1389
|
-
* Thousands separator (default `"."`).
|
|
1390
|
-
* Example: `"."` ➔ `1.000.000`
|
|
1391
|
-
*
|
|
1392
|
-
* @property {string} separatorDecimals
|
|
1393
|
-
* Decimal separator (default `","`).
|
|
1394
|
-
* Example: `","` ➔ `1.000,10`
|
|
1395
|
-
*
|
|
1396
|
-
* @property {string} suffixCurrency
|
|
1397
|
-
* Prefix currency string (default `""`).
|
|
1398
|
-
* Does **not auto-keep input symbols**.
|
|
1399
|
-
* Must set manually: `suffixCurrency: "Rp "`.
|
|
1400
|
-
*
|
|
1401
|
-
* @property {boolean} decimal
|
|
1402
|
-
* Show decimals? (default `false`).
|
|
1403
|
-
* If `false`, rounds to integer.
|
|
1404
|
-
*
|
|
1405
|
-
* @property {number} totalDecimal
|
|
1406
|
-
* Total decimal digits (default `2`).
|
|
1407
|
-
* If `decimal: true` & `roundedDecimal: false`, simply cuts.
|
|
1408
|
-
*
|
|
1409
|
-
* @property {string} suffixDecimal
|
|
1410
|
-
* Text appended after decimals
|
|
1411
|
-
* (e.g. `".-"`, `" USD"`). Default `""`.
|
|
1412
|
-
*
|
|
1413
|
-
* @property {boolean} endDecimal
|
|
1414
|
-
* Actually append `suffixDecimal`? (default `true`).
|
|
1415
|
-
*
|
|
1416
|
-
* @property {"round"|"ceil"|"floor"|false} roundedDecimal
|
|
1417
|
-
* Rounding mode:
|
|
1418
|
-
* - `"round"` ➔ nearest
|
|
1419
|
-
* - `"ceil"` ➔ always up
|
|
1420
|
-
* - `"floor"` ➔ always down
|
|
1421
|
-
* - `false` ➔ truncate
|
|
1422
|
-
* Default `"round"`.
|
|
1423
|
-
*
|
|
1424
|
-
* @property {"dash"|"brackets"|"abs"|{style?, space?, custom?}} negativeFormat
|
|
1425
|
-
* How to format negatives:
|
|
1426
|
-
* - `"dash"` ➔ `-15.000`
|
|
1427
|
-
* - `"brackets"` ➔ `(15.000)`
|
|
1428
|
-
* - `"abs"` ➔ `15.000` (always positive)
|
|
1429
|
-
* - or object:
|
|
1430
|
-
* {
|
|
1431
|
-
* style: "dash"|"brackets"|"abs",
|
|
1432
|
-
* space: true|false,
|
|
1433
|
-
* custom: (formatted) => string
|
|
1434
|
-
* }
|
|
1435
|
-
* Default `"dash"`.
|
|
1436
|
-
*
|
|
1437
|
-
* @property {boolean} indianFormat
|
|
1438
|
-
* If `true`, formats as Indian: `12,34,567`.
|
|
1439
|
-
* Also forces `separator: ","`, `separatorDecimals: "."`.
|
|
1440
|
-
*
|
|
1441
|
-
* @returns {string}
|
|
1442
|
-
* Nicely formatted currency string.
|
|
1443
|
-
* Examples:
|
|
1444
|
-
* - `"15.000,10"`
|
|
1445
|
-
* - `"Rp 15.000,10.-"`
|
|
1446
|
-
* - `"15'000.10 USD"`
|
|
1447
|
-
* - `"12,34,567.89"`
|
|
1448
|
-
*
|
|
1449
|
-
* @throws {TypeError}
|
|
1450
|
-
* If:
|
|
1451
|
-
* - `value` is not string or number
|
|
1452
|
-
* - cannot parse to valid number
|
|
1453
|
-
* - options have invalid types
|
|
1454
|
-
*
|
|
1455
|
-
* ---
|
|
1456
|
-
*
|
|
1457
|
-
* ***✅ Notes:***
|
|
1458
|
-
* - Always re-apply symbols via `suffixCurrency`.
|
|
1459
|
-
* - `parseCurrencyString` smartly detects last decimal,
|
|
1460
|
-
* so `"1.121.234,56"` and `"1,121,234.56"` both parsed correctly.
|
|
1461
|
-
*/
|
|
1462
|
-
declare const formatCurrency:(value:string | number,options?:FormatCurrencyOptions)=>string;
|
|
1463
|
-
/** ----------------------------------------------------------
|
|
1464
|
-
* * ***Formats a number or numeric string by adding a custom separator
|
|
1465
|
-
* every three digits (thousands separator), and intelligently
|
|
1466
|
-
* flips the decimal separator according to the chosen separator.***
|
|
1467
|
-
* ----------------------------------------------------------
|
|
1468
|
-
*
|
|
1469
|
-
* - Converts a number to string before formatting.
|
|
1470
|
-
* - Defaults to using `,` as the thousands separator.
|
|
1471
|
-
* - If `.` is used as the separator, the decimal will automatically become `,`, and vice versa.
|
|
1472
|
-
* - Handles input with existing formatting (e.g. "1,234,567.89") and normalizes it.
|
|
1473
|
-
* - Supports custom separators, including spaces.
|
|
1474
|
-
* - Preserves decimals even if more than 2 digits.
|
|
1475
|
-
*
|
|
1476
|
-
* @param {string | number} value - The numeric value or string to format.
|
|
1477
|
-
* Can be plain numbers, or already formatted strings like "1,234,567.89".
|
|
1478
|
-
* @param {string} [separator=","] - The thousands separator to use.
|
|
1479
|
-
* Examples: "," (default), ".", " ", etc.
|
|
1480
|
-
*
|
|
1481
|
-
* @returns {string} The formatted string with thousands separators and
|
|
1482
|
-
* appropriate decimal separator.
|
|
1483
|
-
*
|
|
1484
|
-
* @example
|
|
1485
|
-
* formatNumber(1000000);
|
|
1486
|
-
* // → "1,000,000"
|
|
1487
|
-
*
|
|
1488
|
-
* formatNumber("987654321");
|
|
1489
|
-
* // → "987,654,321"
|
|
1490
|
-
*
|
|
1491
|
-
* formatNumber(1234567.89);
|
|
1492
|
-
* // → "1,234,567.89"
|
|
1493
|
-
*
|
|
1494
|
-
* formatNumber("1234567,89");
|
|
1495
|
-
* // → "1,234,567.89"
|
|
1496
|
-
*
|
|
1497
|
-
* formatNumber("1234567.892");
|
|
1498
|
-
* // → "1,234,567.892"
|
|
1499
|
-
*
|
|
1500
|
-
* formatNumber("1234567.89", ".");
|
|
1501
|
-
* // → "1.234.567,89"
|
|
1502
|
-
*
|
|
1503
|
-
* formatNumber("1234567,89", ",");
|
|
1504
|
-
* // → "1,234,567.89"
|
|
1505
|
-
*
|
|
1506
|
-
* formatNumber("987654321", " ");
|
|
1507
|
-
* // → "987 654 321"
|
|
1508
|
-
*
|
|
1509
|
-
* formatNumber("1,234,567.89");
|
|
1510
|
-
* // → "1,234,567.89"
|
|
1511
|
-
*
|
|
1512
|
-
* formatNumber("1.234.567,89", ",");
|
|
1513
|
-
* // → "1,234,567.89"
|
|
1514
|
-
*
|
|
1515
|
-
* formatNumber("1.234.567,893", ".");
|
|
1516
|
-
* // → "1.234.567,893"
|
|
1517
|
-
*
|
|
1518
|
-
* formatNumber("1234.56", ".");
|
|
1519
|
-
* // → "1.234,56"
|
|
1520
|
-
*
|
|
1521
|
-
* formatNumber("1234,56", ",");
|
|
1522
|
-
* // → "1,234.56"
|
|
1523
|
-
*
|
|
1524
|
-
* @throws {TypeError} If `value` is not a string or number,
|
|
1525
|
-
* or `separator` is not a string.
|
|
1526
|
-
*/
|
|
1527
|
-
declare const formatNumber:(value:string | number,separator?:string)=>string;
|
|
1528
|
-
/** -------------------------------------------------------
|
|
1529
|
-
* * ***Formats a phone number into a customizable local or international style.***
|
|
1530
|
-
* -------------------------------------------------------
|
|
1531
|
-
*
|
|
1532
|
-
* Can also:
|
|
1533
|
-
* - Return only digits (`takeNumberOnly`).
|
|
1534
|
-
* - Check validity (`checkValidOnly`) using a regex for international-style phone numbers.
|
|
1535
|
-
*
|
|
1536
|
-
* Validation (`checkValidOnly: true`)
|
|
1537
|
-
* Valid if:
|
|
1538
|
-
* - Only contains digits, optional leading `+`, spaces, parentheses `()`, hyphens `-`, or dots `.`.
|
|
1539
|
-
* - Digits-only length < 24.
|
|
1540
|
-
*
|
|
1541
|
-
* Example:
|
|
1542
|
-
* ```js
|
|
1543
|
-
* formatPhoneNumber("081234567890")
|
|
1544
|
-
* // => "0812 3456 7890"
|
|
1545
|
-
* ```
|
|
1546
|
-
*
|
|
1547
|
-
* Example:
|
|
1548
|
-
* ```js
|
|
1549
|
-
* formatPhoneNumber("(0812) 3456-7890", { takeNumberOnly: true })
|
|
1550
|
-
* // => "081234567890"
|
|
1551
|
-
* ```
|
|
1552
|
-
*
|
|
1553
|
-
* Example:
|
|
1554
|
-
* ```js
|
|
1555
|
-
* formatPhoneNumber("(0812) 3456-7890", { checkValidOnly: true })
|
|
1556
|
-
* // => true
|
|
1557
|
-
* ```
|
|
1558
|
-
*
|
|
1559
|
-
* Example:
|
|
1560
|
-
* ```js
|
|
1561
|
-
* formatPhoneNumber("+6281234567890", { checkValidOnly: true })
|
|
1562
|
-
* // => true
|
|
1563
|
-
* ```
|
|
1564
|
-
*
|
|
1565
|
-
* Example:
|
|
1566
|
-
* ```js
|
|
1567
|
-
* formatPhoneNumber("+1 (800) 123-4567", { checkValidOnly: true })
|
|
1568
|
-
* // => true
|
|
1569
|
-
* formatPhoneNumber("+44 20 7946 0958", { checkValidOnly: true })
|
|
1570
|
-
* // => true
|
|
1571
|
-
* ```
|
|
1572
|
-
*
|
|
1573
|
-
* Example:
|
|
1574
|
-
* ```js
|
|
1575
|
-
* formatPhoneNumber("0812-3456-7890", { checkValidOnly: true })
|
|
1576
|
-
* // => true
|
|
1577
|
-
* formatPhoneNumber("(0812) 3456 7890", { checkValidOnly: true })
|
|
1578
|
-
* // => true
|
|
1579
|
-
* formatPhoneNumber("0812 3456 7890", { checkValidOnly: true })
|
|
1580
|
-
* // => true
|
|
1581
|
-
* ```
|
|
1582
|
-
*
|
|
1583
|
-
* Example:
|
|
1584
|
-
* ```js
|
|
1585
|
-
* formatPhoneNumber("+62abc123", { checkValidOnly: true })
|
|
1586
|
-
* // => false
|
|
1587
|
-
* formatPhoneNumber("0812-3456-hello", { checkValidOnly: true })
|
|
1588
|
-
* // => false
|
|
1589
|
-
* formatPhoneNumber("+62 123456789012345678901234", { checkValidOnly: true })
|
|
1590
|
-
* // => false
|
|
1591
|
-
* formatPhoneNumber("++6281234567890", { checkValidOnly: true })
|
|
1592
|
-
* // => false
|
|
1593
|
-
* formatPhoneNumber("invalid@@@", { checkValidOnly: true })
|
|
1594
|
-
* // => false
|
|
1595
|
-
* ```
|
|
1596
|
-
*
|
|
1597
|
-
* Example:
|
|
1598
|
-
* ```js
|
|
1599
|
-
* formatPhoneNumber("+62.812.3456.7890", { checkValidOnly: true })
|
|
1600
|
-
* // => true
|
|
1601
|
-
* formatPhoneNumber("+62(812)3456-7890", { checkValidOnly: true })
|
|
1602
|
-
* // => true
|
|
1603
|
-
* ```
|
|
1604
|
-
*
|
|
1605
|
-
* Example:
|
|
1606
|
-
* ```js
|
|
1607
|
-
* formatPhoneNumber("081234567890", {
|
|
1608
|
-
* separator: "-",
|
|
1609
|
-
* plusNumberCountry: "+44",
|
|
1610
|
-
* openingNumberCountry: "(",
|
|
1611
|
-
* closingNumberCountry: ")",
|
|
1612
|
-
* })
|
|
1613
|
-
* // => "(+44) 8123-4567-890"
|
|
1614
|
-
* ```
|
|
1615
|
-
*
|
|
1616
|
-
* @throws {TypeError} If `value` is not string, number, null or undefined.
|
|
1617
|
-
* @throws {TypeError} If `options` is not an object or contains wrong types.
|
|
1618
|
-
*
|
|
1619
|
-
* @overload
|
|
1620
|
-
* @param value The phone number input (string or number).
|
|
1621
|
-
* @param options With `checkValidOnly: true`.
|
|
1622
|
-
* @returns A boolean indicating whether the input is a valid phone number.
|
|
1623
|
-
*
|
|
1624
|
-
* @overload
|
|
1625
|
-
* @param value The phone number input (string or number).
|
|
1626
|
-
* @param options With `takeNumberOnly: true`.
|
|
1627
|
-
* @returns A string of digits only.
|
|
1628
|
-
*
|
|
1629
|
-
* @overload
|
|
1630
|
-
* @param value The phone number input (string or number).
|
|
1631
|
-
* @param options Options to customize format output (country code, separator, etc).
|
|
1632
|
-
* @returns A formatted phone number string.
|
|
1633
|
-
*/
|
|
1634
|
-
declare function formatPhoneNumber(value?:ValueFormatPhoneNumber,options?:FormatPhoneNumberPropsString):string;declare function formatPhoneNumber(value?:ValueFormatPhoneNumber,options?:FormatPhoneNumberPropsBoolean):boolean;declare function formatPhoneNumber(value?:ValueFormatPhoneNumber,options?:FormatPhoneNumberPropsTransform):string;type SupportedLocales="en-US" | "en-GB" | "en-AU" | "en-CA" | "en-NZ" | "en-ZA" | "en-IN" | "en-IE" | "en-SG" | "en-HK" | "en-PH" | "en-MY" | "en-PK" | "en-KE" | "en-TZ" | "en-NG" | "en-LK" | "en-BW" | "en-ZM" | "id-ID" | "ms-MY" | "th-TH" | "vi-VN" | "tl-PH" | "ms-BN" | "zh-CN" | "zh-HK" | "zh-TW" | "zh-SG" | "zh-MO" | "ja-JP" | "ko-KR" | "fr-FR" | "fr-CA" | "fr-BE" | "fr-CH" | "fr-LU" | "fr-MA" | "fr-SN" | "fr-CM" | "fr-CI" | "fr-HT" | "fr-DZ" | "fr-TN" | "fr-ML" | "fr-NC" | "fr-PF" | "fr-GP" | "fr-MQ" | "fr-GF" | "de-DE" | "de-AT" | "de-CH" | "de-LU" | "de-LI" | "es-ES" | "es-MX" | "es-AR" | "es-CL" | "es-CO" | "es-PE" | "es-UY" | "es-VE" | "es-CR" | "es-EC" | "es-GT" | "es-HN" | "es-NI" | "es-PA" | "es-PR" | "es-SV" | "es-BO" | "es-PY" | "es-DO" | "es-CU" | "es-GQ" | "pt-BR" | "pt-PT" | "pt-MZ" | "pt-AO" | "pt-GW" | "pt-CV" | "pt-ST" | "it-IT" | "it-CH" | "it-SM" | "it-VA" | "nl-NL" | "nl-BE" | "nl-SR" | "nl-AW" | "nl-CW" | "ru-RU" | "uk-UA" | "kk-KZ" | "uz-UZ" | "ky-KG" | "tt-RU" | "ba-RU" | "cv-RU" | "sah-RU" | "pl-PL" | "cs-CZ" | "sk-SK" | "hu-HU" | "sl-SI" | "sv-SE" | "da-DK" | "no-NO" | "fi-FI" | "is-IS" | "ro-RO" | "bg-BG" | "hr-HR" | "sr-RS" | "mk-MK" | "bs-BA" | "me-ME" | "sq-AL" | "sq-XK" | "el-GR" | "el-CY" | "tr-TR" | "tr-CY" | "he-IL" | "ar-SA" | "ar-AE" | "ar-EG" | "ar-MA" | "ar-JO" | "ar-LB" | "ar-QA" | "ar-KW" | "ar-OM" | "ar-BH" | "ar-IQ" | "ar-LY" | "ar-TN" | "ar-YE" | "ar-SY" | "ar-PS" | "ar-SD" | "ar-DZ" | "ar-MR" | "ar-DJ" | "ar-SO" | "lt-LT" | "lv-LV" | "et-EE" | "hi-IN" | "bn-BD" | "pa-IN" | "ta-IN" | "te-IN" | "ml-IN" | "gu-IN" | "kn-IN" | "mr-IN" | "or-IN" | "as-IN" | "ne-IN" | "fa-IR" | "ur-PK" | "ps-AF" | "dv-MV" | "sw-KE" | "sw-TZ" | "zu-ZA" | "af-ZA" | "xh-ZA" | "ss-SZ" | "ts-ZA" | "tn-BW" | "ny-MW" | "lo-LA" | "mt-MT" | "ga-IE" | "cy-GB" | "ne-NP" | "si-LK" | "am-ET" | "om-ET" | "ti-ER" | "km-KH" | "my-MM" | "mn-MN" | "tg-TJ" | "tk-TM" | "hy-AM" | "ka-GE" | "az-AZ" | "be-BY" | "mo-MD" | "ro-MD" | "ht-HT" | "jw-ID" | "su-ID" | "to-TO" | "sm-WS" | "mi-NZ" | "bi-VU" | "fj-FJ" | "ty-PF" | "pau-PW" | "niu-NU" | "ck-CK" | "rw-RW" | "ln-CD" | "kg-CD" | "ha-NE" | "yo-NG" | "ig-NG" | "ak-GH" | "lg-UG" | "bo-CN" | "dz-BT" | "iu-CA" | "kl-GL" | "cv-RU" | "pap-AW" | "chr-US" | "haw-US" | "gv-IM" | "gd-GB" | "br-FR" | "co-FR" | "rm-CH" | "wa-BE" | "lb-LU" | "fur-IT" | "sc-IT" | "vec-IT" | "nap-IT" | "gsw-CH" | "rha-CH" |({}& string);
|
|
1635
|
-
/** ----------------------------------------------------------
|
|
1636
|
-
* * ***Formats a date and time into a custom string format.***
|
|
1637
|
-
* ----------------------------------------------------------
|
|
1638
|
-
*
|
|
1639
|
-
* - Supports only `YYYY`, `MM`, `DD`, `hh`, `mm`, and `ss` as placeholders.
|
|
1640
|
-
* - Uses a simple string replace (no locale).
|
|
1641
|
-
* - Returns `null` if the date is invalid or not provided.
|
|
1642
|
-
* - Defaults to `"YYYY-MM-DD hh:mm:ss"` format if none is specified.
|
|
1643
|
-
*
|
|
1644
|
-
* @param {string | Date | null} [date] - The date to format.
|
|
1645
|
-
* @param {string} [format="YYYY-MM-DD hh:mm:ss"] - The desired date format.
|
|
1646
|
-
* @returns {string | null} The formatted date string or `null` if invalid.
|
|
1647
|
-
*
|
|
1648
|
-
* @example
|
|
1649
|
-
* formatDateTime(new Date());
|
|
1650
|
-
* // => "2024-02-09 14:30:45" (example output with current time)
|
|
1651
|
-
*
|
|
1652
|
-
* formatDateTime("2023-07-01T14:30:45");
|
|
1653
|
-
* // => "2023-07-01 14:30:45"
|
|
1654
|
-
*
|
|
1655
|
-
* formatDateTime("2023-07-01T14:30:45", "DD/MM/YYYY");
|
|
1656
|
-
* // => "01/07/2023"
|
|
1657
|
-
*
|
|
1658
|
-
* formatDateTime("2023-07-01T14:30:45", "YYYY/MM/DD hh-mm-ss");
|
|
1659
|
-
* // => "2023/07/01 14-30-45"
|
|
1660
|
-
*
|
|
1661
|
-
* formatDateTime("2023-07-01T14:30:45", "hh:mm");
|
|
1662
|
-
* // => "14:30"
|
|
1663
|
-
*
|
|
1664
|
-
* formatDateTime("2023-07-01T14:30:45", "DATE: YYYY.MM.DD");
|
|
1665
|
-
* // => "DATE: 2023.07.01"
|
|
1666
|
-
*
|
|
1667
|
-
* formatDateTime("2023-07-01T14:30:45", "Year: YYYY, Time: hh:mm:ss");
|
|
1668
|
-
* // => "Year: 2023, Time: 14:30:45"
|
|
1669
|
-
*
|
|
1670
|
-
* formatDateTime("2023-07-01T14:30:45", "YYYY-MM");
|
|
1671
|
-
* // => "2023-07"
|
|
1672
|
-
*
|
|
1673
|
-
* formatDateTime("2023-07-01T14:30:45", "YYYYYYYY");
|
|
1674
|
-
* // => "20232023"
|
|
1675
|
-
*
|
|
1676
|
-
* formatDateTime("2023-07-01T14:30:45", "hh:mm:ss:ss");
|
|
1677
|
-
* // => "14:30:45:45"
|
|
1678
|
-
*
|
|
1679
|
-
* formatDateTime("invalid-date");
|
|
1680
|
-
* // => null
|
|
1681
|
-
*
|
|
1682
|
-
* formatDateTime(null);
|
|
1683
|
-
* // => null
|
|
1684
|
-
*
|
|
1685
|
-
* formatDateTime(undefined);
|
|
1686
|
-
* // => null
|
|
1687
|
-
*/
|
|
1688
|
-
declare const formatDateTime:(date?:string | Date | null,
|
|
1689
|
-
/** @default "YYYY-MM-DD hh:mm:ss" */
|
|
1690
|
-
format?:string)=>string | null;
|
|
1691
|
-
/** ----------------------------------------------------------
|
|
1692
|
-
* * ***Formats a date using the `Intl.DateTimeFormat` API.***
|
|
1693
|
-
* ----------------------------------------------------------
|
|
1694
|
-
*
|
|
1695
|
-
* - Supports custom locales (type-safe `SupportedLocales`).
|
|
1696
|
-
* - Accepts additional `Intl.DateTimeFormatOptions` like `timeZone`, `hour12`, etc.
|
|
1697
|
-
* - Defaults to `"en-US"` if `locale` is not provided or is an empty string.
|
|
1698
|
-
* - Returns `null` if the date is invalid, not provided, or options are invalid.
|
|
1699
|
-
*
|
|
1700
|
-
* @param {string | Date | null | undefined} [date] - The date to format.
|
|
1701
|
-
* Can be a `Date` object or an ISO string. If invalid or not provided, returns `null`.
|
|
1702
|
-
*
|
|
1703
|
-
* @param {Intl.DateTimeFormatOptions & { locale?: SupportedLocales | SupportedLocales[] }} [options]
|
|
1704
|
-
* - Optional formatting options for `Intl.DateTimeFormat`.
|
|
1705
|
-
* - Use `locale` to specify the language & region format.
|
|
1706
|
-
*
|
|
1707
|
-
* @returns {string | null}
|
|
1708
|
-
* - Formatted date string.
|
|
1709
|
-
* - Returns `null` if date is invalid or options are of wrong type.
|
|
1710
|
-
*
|
|
1711
|
-
* @example
|
|
1712
|
-
* formatDateIntl(new Date());
|
|
1713
|
-
* // => "7/14/2025"
|
|
1714
|
-
*
|
|
1715
|
-
* formatDateIntl("2025-07-14T00:00:00Z", { locale: "fr-FR", dateStyle: "long" });
|
|
1716
|
-
* // => "14 juillet 2025"
|
|
1717
|
-
*
|
|
1718
|
-
* formatDateIntl(null);
|
|
1719
|
-
* // => null
|
|
1720
|
-
*
|
|
1721
|
-
* formatDateIntl(new Date(), { timeZone: "UTC", hour: "2-digit", minute: "2-digit" });
|
|
1722
|
-
* // => "01:30 AM"
|
|
1723
|
-
*/
|
|
1724
|
-
declare const formatDateIntl:(date?:string | Date | null,options?:Intl.DateTimeFormatOptions &{locale?:SupportedLocales | SupportedLocales[];})=>string | null;
|
|
1725
|
-
/** ----------------------------------------------------------
|
|
1726
|
-
* * ***Formats a date into a human-readable string using `date-fns`.***
|
|
1727
|
-
* ----------------------------------------------------------
|
|
1728
|
-
*
|
|
1729
|
-
* - Supports custom output formats using `date-fns/format`.
|
|
1730
|
-
* - Can parse localized non-ISO strings via `inputFormat` & `inputLocale`.
|
|
1731
|
-
* - Supports `locale` as `"id"`, `"en"` or `date-fns` `Locale` objects (like `id` or `enUS`).
|
|
1732
|
-
* - Returns `null` if the date is invalid, not provided, or parsing fails.
|
|
1733
|
-
*
|
|
1734
|
-
* @param {string | Date | null} [date] - The date input to format. Can be:
|
|
1735
|
-
* - A `Date` object
|
|
1736
|
-
* - An ISO string (e.g. `"2024-01-01T12:00:00Z"`)
|
|
1737
|
-
* - A localized string (requires `inputFormat` + `inputLocale`)
|
|
1738
|
-
*
|
|
1739
|
-
* @param {object} [options] - Options for formatting and parsing.
|
|
1740
|
-
*
|
|
1741
|
-
* @param {string} [options.format="dd MMM yyyy - HH:mm:ss"]
|
|
1742
|
-
* The output format string (passed to `date-fns/format`).
|
|
1743
|
-
* E.g. `"dd MMMM yyyy, HH:mm:ss" => "14 Juli 2025, 17:25:42"`
|
|
1744
|
-
*
|
|
1745
|
-
* @param {"id" | "en" | (string & {}) | Locale} [options.locale="id"]
|
|
1746
|
-
* The output locale. If string, only `"id"` (Indonesian) or `"en"` (English)
|
|
1747
|
-
* is recognized. Or you can pass a `date-fns` `Locale` object.
|
|
1748
|
-
* Example:
|
|
1749
|
-
* ```ts
|
|
1750
|
-
* import { ar } from "date-fns/locale";
|
|
1751
|
-
* formatDateFns(new Date(), { locale: ar, format: "PPPppp" });
|
|
1752
|
-
* ```
|
|
1753
|
-
*
|
|
1754
|
-
* @param {"id" | "en" | (string & {}) | Locale} [options.inputLocale]
|
|
1755
|
-
* Required if `date` is a localized non-ISO string. Used with `inputFormat`.
|
|
1756
|
-
* Example for Indonesian string:
|
|
1757
|
-
* ```ts
|
|
1758
|
-
* formatDateFns("14 Juli 2025 10:25:42", {
|
|
1759
|
-
* inputFormat: "dd MMMM yyyy HH:mm:ss",
|
|
1760
|
-
* inputLocale: "id",
|
|
1761
|
-
* });
|
|
1762
|
-
* ```
|
|
1763
|
-
*
|
|
1764
|
-
* @param {string} [options.inputFormat]
|
|
1765
|
-
* The format string to parse `date` if it is a non-ISO string.
|
|
1766
|
-
* Required together with `inputLocale`.
|
|
1767
|
-
*
|
|
1768
|
-
* @returns {string | null} A formatted date string or `null` if input is invalid.
|
|
1769
|
-
*
|
|
1770
|
-
* @example
|
|
1771
|
-
* formatDateFns(new Date());
|
|
1772
|
-
* // "14 Jul 2025 - 17:25:42"
|
|
1773
|
-
*
|
|
1774
|
-
* formatDateFns("2025-07-14T10:25:42Z", { format: "dd/MM/yyyy", locale: "en" });
|
|
1775
|
-
* // "14/07/2025"
|
|
1776
|
-
*
|
|
1777
|
-
* formatDateFns("14 Juli 2025 10:25:42", {
|
|
1778
|
-
* inputFormat: "dd MMMM yyyy HH:mm:ss",
|
|
1779
|
-
* inputLocale: "id",
|
|
1780
|
-
* format: "yyyy-MM-dd"
|
|
1781
|
-
* });
|
|
1782
|
-
* // "2025-07-14"
|
|
1783
|
-
*
|
|
1784
|
-
* formatDateFns(null);
|
|
1785
|
-
* // null
|
|
1786
|
-
*/
|
|
1787
|
-
declare const formatDateFns:(date?:string | Date | null,
|
|
1788
|
-
/**
|
|
1789
|
-
* Options for formatting and parsing a date using `date-fns`.
|
|
1790
|
-
*/
|
|
1791
|
-
options?:OmitStrict<FormatOptions,"locale",true,false>&{
|
|
1792
|
-
/**
|
|
1793
|
-
* Output format string using `date-fns/format`.
|
|
1794
|
-
* @default "dd MMM yyyy - HH:mm:ss"
|
|
1795
|
-
* @example "dd MMMM yyyy, HH:mm:ss"
|
|
1796
|
-
*/
|
|
1797
|
-
format?:string;
|
|
1798
|
-
/**
|
|
1799
|
-
* The locale to be used for formatting.
|
|
1800
|
-
* If `string` Only Accepts "id" for Indonesian or "en" for English.
|
|
1801
|
-
* Or you can put props `Locale` from `date-fns/locale`, e.g :
|
|
1802
|
-
*
|
|
1803
|
-
* ```ts
|
|
1804
|
-
* import { ar } from "date-fns/locale";
|
|
1805
|
-
*
|
|
1806
|
-
* // then passing `ar` to this props.
|
|
1807
|
-
* formatDateFns(
|
|
1808
|
-
* // your date input...,
|
|
1809
|
-
* {
|
|
1810
|
-
* locale: ar,
|
|
1811
|
-
* //.... other options.
|
|
1812
|
-
* });
|
|
1813
|
-
*
|
|
1814
|
-
* ```
|
|
1815
|
-
* @default "id"
|
|
1816
|
-
*/
|
|
1817
|
-
locale?:"id" | "en" |(string &{})| Locale;
|
|
1818
|
-
/**
|
|
1819
|
-
* The Input locale to be used for parsing `inputFormat`.
|
|
1820
|
-
* If `string` Only Accepts "id" for Indonesian or "en" for English.
|
|
1821
|
-
* Required if `date` is a non-standard string like "03 Mei 2025 10:25:42").
|
|
1822
|
-
*
|
|
1823
|
-
* Or you can put props `Locale` from `date-fns/locale`, e.g :
|
|
1824
|
-
*
|
|
1825
|
-
* ```ts
|
|
1826
|
-
* import { ar } from "date-fns/locale";
|
|
1827
|
-
*
|
|
1828
|
-
* // then passing `ar` to this props.
|
|
1829
|
-
* formatDateFns(
|
|
1830
|
-
* // your date input...,
|
|
1831
|
-
* {
|
|
1832
|
-
* inputLocale: ar,
|
|
1833
|
-
* //.... other options.
|
|
1834
|
-
* });
|
|
1835
|
-
*```
|
|
1836
|
-
|
|
1837
|
-
* @default undefined
|
|
1838
|
-
*/
|
|
1839
|
-
inputLocale?:"id" | "en" |(string &{})| Locale;
|
|
1840
|
-
/**
|
|
1841
|
-
* Input format string for parsing non-ISO string dates
|
|
1842
|
-
* (e.g., localized strings like "03 Mei 2025 10:25:42").
|
|
1843
|
-
* Required if `date` is a non-standard string.
|
|
1844
|
-
* @example "dd MMMM yyyy HH:mm:ss"
|
|
1845
|
-
*/
|
|
1846
|
-
inputFormat?:string;})=>string | null;
|
|
1847
|
-
/** ----------------------------------------------------------
|
|
1848
|
-
* * ***Returns the formatted GMT offset (e.g., `+0700`, `-0500`) for a given date.***
|
|
1849
|
-
* ----------------------------------------------------------
|
|
1850
|
-
*
|
|
1851
|
-
* - If `date` is **not provided** or empty string, it defaults to the current date/time.
|
|
1852
|
-
* - If `date` is **invalid** or of wrong type (like object or number), it returns `"0"`.
|
|
1853
|
-
* - The returned string follows the **GMT offset format** (`±HHMM`), where:
|
|
1854
|
-
* - `±` is `+` if ahead of UTC, `-` if behind.
|
|
1855
|
-
* - `HH` is two-digit hours.
|
|
1856
|
-
* - `MM` is two-digit minutes.
|
|
1857
|
-
*
|
|
1858
|
-
* @param {string | Date | null} [date] - The date to get the GMT offset from.
|
|
1859
|
-
* - Accepts `Date` object or ISO date string (e.g., `"2024-01-01T12:00:00Z"`).
|
|
1860
|
-
* - If `null`, `undefined`, or empty string, uses current system date.
|
|
1861
|
-
* - If invalid date or wrong type (like `123` or `{}`), returns `"0"`.
|
|
1862
|
-
*
|
|
1863
|
-
* @returns {string} The GMT offset string in format `±HHMM`,
|
|
1864
|
-
* e.g. `"+0700"`, `"-0530"`, or `"0"` if invalid.
|
|
1865
|
-
*
|
|
1866
|
-
* @example
|
|
1867
|
-
* getGMTOffset();
|
|
1868
|
-
* // => "+0700" (depends on system timezone)
|
|
1869
|
-
*
|
|
1870
|
-
* getGMTOffset(new Date("2024-02-09T12:00:00Z"));
|
|
1871
|
-
* // => "+0000"
|
|
1872
|
-
*
|
|
1873
|
-
* getGMTOffset("2024-02-09");
|
|
1874
|
-
* // => "+0700" (depends on your timezone)
|
|
1875
|
-
*
|
|
1876
|
-
* getGMTOffset("invalid-date");
|
|
1877
|
-
* // => "0"
|
|
1878
|
-
*
|
|
1879
|
-
* getGMTOffset(123);
|
|
1880
|
-
* // => "0"
|
|
1881
|
-
*/
|
|
1882
|
-
declare const getGMTOffset:(date?:string | Date | null)=>string;
|
|
1883
|
-
/** ----------------------------------------------------------
|
|
1884
|
-
* * Censors an email by replacing characters with "*", with support for random or fixed mode.
|
|
1885
|
-
* ----------------------------------------------------------
|
|
1886
|
-
*
|
|
1887
|
-
* In "random" mode (default), characters are randomly replaced each time.
|
|
1888
|
-
* In "fixed" mode, censorship is deterministic based on a hash of the email,
|
|
1889
|
-
* resulting in the same output for the same input.
|
|
1890
|
-
*
|
|
1891
|
-
* @param email - The email to censor.
|
|
1892
|
-
* @param mode - Censoring mode: "random" or "fixed". Default is "random".
|
|
1893
|
-
* @returns The censored email or an empty string if invalid.
|
|
1894
|
-
*
|
|
1895
|
-
* @example
|
|
1896
|
-
* censorEmail("john.doe@gmail.com", "random"); // -> j***.d*@g***l.com (varies)
|
|
1897
|
-
* censorEmail("john.doe@gmail.com", "fixed"); // -> j**n.**e@g***l.com (always the same)
|
|
1898
|
-
* censorEmail("invalid-email"); // -> ""
|
|
1899
|
-
*/
|
|
1900
|
-
declare const censorEmail:(email?:string | null,mode?:"random" | "fixed")=>string;
|
|
1901
|
-
/** ----------------------------------------------
|
|
1902
|
-
* * ***Chunks a string by inserting a separator every `limiter` characters.***
|
|
1903
|
-
* ----------------------------------------------
|
|
1904
|
-
*
|
|
1905
|
-
* This function handles two main behaviors based on `reCountAfterSpace`:
|
|
1906
|
-
*
|
|
1907
|
-
* 1. If `reCountAfterSpace` is `false` (default):
|
|
1908
|
-
* The separator is inserted strictly every `limiter` characters throughout the entire string,
|
|
1909
|
-
* regardless of spaces. Spaces are treated as regular characters in the count.
|
|
1910
|
-
* Example: `chunkString("1234567890", 3, "-")` returns `"123-456-789-0"`.
|
|
1911
|
-
* Example: `chunkString("Hello World", 3, "-")` returns `"Hel-lo -Wor-ld"`.
|
|
1912
|
-
*
|
|
1913
|
-
* 2. If `reCountAfterSpace` is `true`:
|
|
1914
|
-
* The function first processes the input string to replace any multiple consecutive spaces
|
|
1915
|
-
* with a single space (e.g., "A B" becomes "A B").
|
|
1916
|
-
* Then, it treats the string as a sequence of "words" (segments separated by single spaces).
|
|
1917
|
-
* - Each word is processed independently: if a word's length exceeds the `limiter`,
|
|
1918
|
-
* separators are inserted internally within that word.
|
|
1919
|
-
* - Words are then grouped. Each group will contain `limiter` number of words.
|
|
1920
|
-
* Words within the same group are joined by the specified `separator`.
|
|
1921
|
-
* - Finally, these groups are joined by a single space, preserving the original word separation structure
|
|
1922
|
-
* between groups.
|
|
1923
|
-
*
|
|
1924
|
-
* @param {string} subject - The target string where the separator will be added.
|
|
1925
|
-
* @param {number} limiter - The interval (number of characters) at which the separator should be inserted.
|
|
1926
|
-
* @param {string} [separator=" "] - The separator string to insert (default is a single space `" "`).
|
|
1927
|
-
* @param {boolean} [reCountAfterSpace=false] - If `true`, the counting for `limiter`
|
|
1928
|
-
* resets after each space, and words are grouped as described above. If `false`,
|
|
1929
|
-
* the counting is continuous throughout the string.
|
|
1930
|
-
* @returns {string} - The formatted string with separators added according to the specified rules.
|
|
1931
|
-
*
|
|
1932
|
-
* @example
|
|
1933
|
-
* // Basic usage (reCountAfterSpace = false)
|
|
1934
|
-
* chunkString("1234567890", 3, "-"); // Returns: "123-456-789-0"
|
|
1935
|
-
* chunkString("HelloWorld", 2, "_"); // Returns: "He_ll_oW_or_ld"
|
|
1936
|
-
*
|
|
1937
|
-
* @example
|
|
1938
|
-
* // Usage with reCountAfterSpace = true:
|
|
1939
|
-
* // Multiple spaces are normalized to single spaces before processing.
|
|
1940
|
-
* chunkString("AB CD EF GH", 2, "-", true); // Returns: "AB-CD EF-GH" (after normalization to "AB CD EF GH")
|
|
1941
|
-
* // Words "AB" and "CD" form a group and are joined by "-", "EF" and "GH" form another group.
|
|
1942
|
-
* // The groups "AB-CD" and "EF-GH" are then joined by a space.
|
|
1943
|
-
*
|
|
1944
|
-
* @example
|
|
1945
|
-
* // Another usage with reCountAfterSpace = true:
|
|
1946
|
-
* chunkString("ABC DEF GHI JKL", 3, "-", true); // Returns: "ABC-DEF-GHI JKL"
|
|
1947
|
-
* // Words "ABC", "DEF", "GHI" form a group and are joined by "-".
|
|
1948
|
-
* // The word "JKL" forms its own group (as it's the last word and completes no other group).
|
|
1949
|
-
* // The groups "ABC-DEF-GHI" and "JKL" are then joined by a space.
|
|
1950
|
-
*/
|
|
1951
|
-
declare function chunkString(subject:string,limiter:number,separator?:string,reCountAfterSpace?:boolean):string;
|
|
1952
|
-
/** ----------------------------------------------------------
|
|
1953
|
-
* * ***Truncates a string to a specified length and optionally appends an ending.***
|
|
1954
|
-
* * ***Also provides an option to trim the string before truncation.***
|
|
1955
|
-
* * ***If truncation occurs, trailing spaces before the ending are removed.***
|
|
1956
|
-
* * ***The `ending` parameter is always trimmed first; if it becomes empty, it defaults to `"..."`.***
|
|
1957
|
-
* ----------------------------------------------------------
|
|
1958
|
-
*
|
|
1959
|
-
* @param {string|null|undefined} text - The input string to truncate.
|
|
1960
|
-
* If `null`, `undefined`, or empty after trim, returns `""`.
|
|
1961
|
-
* @param {number} [length=10] - The maximum length of the truncated string **(default: `10`)**.
|
|
1962
|
-
* @param {string} [ending="..."] - The string to append if truncation occurs **(default: `"..."`)**.
|
|
1963
|
-
* This value is always passed through `ending.trim()`.
|
|
1964
|
-
* If `ending.trim().length < 1`, it automatically becomes `"..."`.
|
|
1965
|
-
* @param {boolean} [trim=true] - Whether to trim the string before truncation **(default: `true`)**.
|
|
1966
|
-
*
|
|
1967
|
-
* @returns {string} - The truncated string with optional trimming and ending.
|
|
1968
|
-
* If text is `null`, `undefined`, or `length < 1`, returns `""`.
|
|
1969
|
-
* If truncation happens, trailing spaces before the `ending` are automatically removed.
|
|
1970
|
-
*
|
|
1971
|
-
* @throws {TypeError} - If `length` is not a number, `ending` is not a string, or `trim` is not a boolean.
|
|
1972
|
-
*
|
|
1973
|
-
* @example
|
|
1974
|
-
* truncateString("hello world", 5); // "hello..."
|
|
1975
|
-
* truncateString("hello world", 5, "---"); // "hello---"
|
|
1976
|
-
* truncateString("hello world", 5, " "); // "hello..." (because ending.trim() -> "" -> default to "...")
|
|
1977
|
-
* truncateString("hello world", 5, " !!! "); // "hello!!!" (ending is trimmed to "!!!")
|
|
1978
|
-
* truncateString(" long data string ", 8, "...", true); // "long dat..."
|
|
1979
|
-
* truncateString(" long data string ", 8, "...", false); // " long ..."
|
|
1980
|
-
* truncateString(" text with spaces ", 10, "...", false); // " text with..."
|
|
1981
|
-
* truncateString("abc def", 7); // "abc def"
|
|
1982
|
-
* truncateString(null, 5); // ""
|
|
1983
|
-
* truncateString("short", 10); // "short"
|
|
1984
|
-
*/
|
|
1985
|
-
declare const truncateString:(text?:string | null,length?:number,ending?:string,trim?:boolean)=>string;
|
|
1986
|
-
/** ---------------------------------
|
|
1987
|
-
* * ***Returns a random element from a given array.***
|
|
1988
|
-
* ---------------------------------
|
|
1989
|
-
*
|
|
1990
|
-
* @template T The type of elements in the array (string | number).
|
|
1991
|
-
* @param {T[]} array - The input array.
|
|
1992
|
-
* @returns {T | undefined} A random element from the array, or `undefined` if the array is empty or invalid.
|
|
1993
|
-
*
|
|
1994
|
-
* @example
|
|
1995
|
-
* getRandomItem([1, 2, 3, 4]); // Returns a random number from the array
|
|
1996
|
-
* getRandomItem(["apple", "banana", "cherry"]); // Returns a random string from the array
|
|
1997
|
-
* getRandomItem([]); // Returns `undefined`
|
|
1998
|
-
*/
|
|
1999
|
-
declare const getRandomItem:<T extends string | number>(array?:T[])=>T | undefined;
|
|
2000
|
-
/** ----------------------------
|
|
2001
|
-
* * ***Generates a random integer within a specified range (inclusive).***
|
|
2002
|
-
* ----------------------------
|
|
2003
|
-
*
|
|
2004
|
-
* @description
|
|
2005
|
-
* Generates a random integer between `min` and `max` (inclusive),
|
|
2006
|
-
* with safety constraints:
|
|
2007
|
-
* - `min` will be forced to be at least `1`.
|
|
2008
|
-
* - `max` will be capped at `Number.MAX_SAFE_INTEGER`.
|
|
2009
|
-
*
|
|
2010
|
-
* Validates input parameters to ensure robust behavior.
|
|
2011
|
-
*
|
|
2012
|
-
* @param {number} min - The minimum value (inclusive). Must be an integer.
|
|
2013
|
-
* @param {number} max - The maximum value (inclusive). Must be an integer.
|
|
2014
|
-
*
|
|
2015
|
-
* @returns {number} A random integer N where `min ≤ N ≤ max`.
|
|
2016
|
-
*
|
|
2017
|
-
* @throws {Error} If:
|
|
2018
|
-
* - `min` or `max` is not an integer.
|
|
2019
|
-
* - `min` is greater than `max`.
|
|
2020
|
-
*
|
|
2021
|
-
* @example
|
|
2022
|
-
* randomInt(1, 10); // → returns 1 to 10
|
|
2023
|
-
* randomInt(50, 100); // → returns 50 to 100
|
|
2024
|
-
* randomInt(5, 5); // → always returns 5
|
|
2025
|
-
*
|
|
2026
|
-
* @example
|
|
2027
|
-
* randomInt(-5, 3); // → always returns ≥ 1, since min is adjusted
|
|
2028
|
-
*
|
|
2029
|
-
* @example
|
|
2030
|
-
* randomInt(1, Number.MAX_SAFE_INTEGER + 10000);
|
|
2031
|
-
* // → still safely capped at MAX_SAFE_INTEGER
|
|
2032
|
-
*/
|
|
2033
|
-
declare const randomInt:(min:number,max:number)=>number;
|
|
2034
|
-
/** ----------------------------------------------------------
|
|
2035
|
-
* * ***Generates a random integer within a specified range of digit lengths.***
|
|
2036
|
-
* ----------------------------------------------------------
|
|
2037
|
-
*
|
|
2038
|
-
* @description
|
|
2039
|
-
* This function allows generating random integers that strictly conform to
|
|
2040
|
-
* a specified minimum and maximum digit length. It is useful for scenarios
|
|
2041
|
-
* such as generating realistic-looking IDs, codes, or random test data.
|
|
2042
|
-
*
|
|
2043
|
-
* The function ensures:
|
|
2044
|
-
* - `minLength` is at least 1 and not greater than `maxLength`.
|
|
2045
|
-
* - `maxLength` is no more than 16 (due to JavaScript's Number.MAX_SAFE_INTEGER).
|
|
2046
|
-
* - If `avoidZero` is `true`, ensures that `0` is never returned.
|
|
2047
|
-
*
|
|
2048
|
-
* @param {object} [options] - Configuration options.
|
|
2049
|
-
* @param {number} [options.minLength=1] - Minimum number of digits (must be ≥1 and ≤ `maxLength`).
|
|
2050
|
-
* @param {number} [options.maxLength=16] - Maximum number of digits (must be ≤16).
|
|
2051
|
-
* @param {boolean} [options.avoidZero=false] - If true, will ensure the result is never zero.
|
|
2052
|
-
*
|
|
2053
|
-
* @returns {number} A randomly generated integer within the specified constraints.
|
|
2054
|
-
*
|
|
2055
|
-
* @throws {Error} If parameters are invalid, such as:
|
|
2056
|
-
* - `minLength` < 1
|
|
2057
|
-
* - `maxLength` > 16
|
|
2058
|
-
* - `minLength` > `maxLength`
|
|
2059
|
-
* - non-integer values for `minLength` or `maxLength`
|
|
2060
|
-
*
|
|
2061
|
-
* @example
|
|
2062
|
-
* randomIntByLength({ minLength: 3, maxLength: 5 }); // → (`4829` << random), (`192` << random) or (`71492` << random).
|
|
2063
|
-
* randomIntByLength({ minLength: 4, maxLength: 4 }); // → `5930` (exact 4 digits)
|
|
2064
|
-
* randomIntByLength({ avoidZero: true }); // → never 0
|
|
2065
|
-
*/
|
|
2066
|
-
declare const randomIntByLength:(options?:{
|
|
2067
|
-
/** * Minimum length of the random number, the `allowed` `minimal` `value` `integer` is `1` `and` `not` `bigger` `than` `value` `of` `maxLength`.
|
|
2068
|
-
* @default 1
|
|
2069
|
-
*/
|
|
2070
|
-
minLength?:number;
|
|
2071
|
-
/** * Maximum length of the random number, the `allowed` `maximal` `value` `integer` is `16`.
|
|
2072
|
-
*
|
|
2073
|
-
* @default 16
|
|
2074
|
-
*/
|
|
2075
|
-
maxLength?:number;
|
|
2076
|
-
/** * If true, prevents the result from being zero.
|
|
2077
|
-
* @default false
|
|
2078
|
-
*/
|
|
2079
|
-
avoidZero?:boolean;})=>number;
|
|
2080
|
-
/** ---------------------------------------------------------------------------------
|
|
2081
|
-
* * ***Generates a random alphanumeric string or number with a specified length range.***
|
|
2082
|
-
* ---------------------------------------------------------------------------------
|
|
2083
|
-
*
|
|
2084
|
-
* @description
|
|
2085
|
-
* This function allows you to generate random strings or numbers with fully customizable options,
|
|
2086
|
-
* such as length range, character sets, inclusion of additional characters, and whether to avoid whitespace.
|
|
2087
|
-
*
|
|
2088
|
-
* @param {Object} [options] - Configuration options for generating the string.
|
|
2089
|
-
* @param {number} [options.minLength=40] - Minimum length of the generated string (must be ≥ 1).
|
|
2090
|
-
* @param {number} [options.maxLength=40] - Maximum length of the generated string (must be ≤ 5000).
|
|
2091
|
-
* @param {"string" | "number"} [options.type="string"] - Whether to generate a general alphanumeric string or purely numeric string.
|
|
2092
|
-
* @param {boolean} [options.avoidWhiteSpace=true] - If true, removes all whitespace, tabs, and newlines from the character set before generating.
|
|
2093
|
-
* @param {string} [options.replaceGenStr] - A custom character set to use when `type` is `"string"`.
|
|
2094
|
-
* @param {string} [options.replaceGenInt] - A custom character set to use when `type` is `"number"`.
|
|
2095
|
-
* @param {string} [options.addChar] - Additional characters to always include in the character set.
|
|
2096
|
-
*
|
|
2097
|
-
* @returns {string} The randomly generated string or numeric string of the desired length.
|
|
2098
|
-
*
|
|
2099
|
-
* @throws {Error} If provided options are invalid (such as minLength > maxLength, invalid type, or empty character set).
|
|
2100
|
-
*
|
|
2101
|
-
* @example
|
|
2102
|
-
* randomStr(); // → Generates a 40-character random alphanumeric string
|
|
2103
|
-
* randomStr({ minLength: 10, maxLength: 20 }); // → Generates a string between 10 and 20 characters
|
|
2104
|
-
* randomStr({ type: "number", minLength: 5, maxLength: 5 }); // → "48302"
|
|
2105
|
-
* randomStr({ replaceGenStr: "ABC ", avoidWhiteSpace: false }); // → String using A, B, C and space
|
|
2106
|
-
* randomStr({ addChar: "!@#", minLength: 15, maxLength: 15 }); // → Guaranteed to include !@# in the set
|
|
2107
|
-
*/
|
|
2108
|
-
declare const randomStr:(options?:RandomStringOptions)=>string;
|
|
2109
|
-
/** --------------------------------------------------
|
|
2110
|
-
* * ***This method returns `undefined`.***
|
|
2111
|
-
* --------------------------------------------------
|
|
2112
|
-
*
|
|
2113
|
-
* @example
|
|
2114
|
-
* console.log(noop) // => undefined
|
|
2115
|
-
* isUndefined(noop) // => true
|
|
2116
|
-
*
|
|
2117
|
-
*/
|
|
2118
|
-
declare const noop:()=>void;
|
|
2119
|
-
/** ----------------------------------------
|
|
2120
|
-
* * ***Checks if the current environment is a server-side (Node.js) or a client-side (browser).***
|
|
2121
|
-
* ----------------------------------------
|
|
2122
|
-
*
|
|
2123
|
-
* @returns {boolean} `true` if running on the server-side, `false` if running in the client-side (browser).
|
|
2124
|
-
*/
|
|
2125
|
-
declare const isServer:()=>boolean;
|
|
2126
|
-
/** ----------------------------------------------------------------------
|
|
2127
|
-
* * ***Finds duplicate values in an array by deep equality comparison.***
|
|
2128
|
-
* ----------------------------------------------------------------------
|
|
2129
|
-
*
|
|
2130
|
-
* - ✔ Uses `isEqual` to compare elements (handles objects, arrays, dates, NaN, etc.)
|
|
2131
|
-
* - ✔ Returns a new array containing only the *first occurrences* of duplicated values.
|
|
2132
|
-
* - ✔ Does **not mutate** the original array.
|
|
2133
|
-
* - ✔ Throws `TypeError` if input is not an array.
|
|
2134
|
-
*
|
|
2135
|
-
* @template T Type of elements in the input array.
|
|
2136
|
-
* @param {T[]} values - The array to check for duplicates.
|
|
2137
|
-
* @returns {T[]} An array of the duplicate values found in the input,
|
|
2138
|
-
* preserving order of their first duplicate appearance.
|
|
2139
|
-
*
|
|
2140
|
-
* @throws {TypeError} If the provided `values` argument is not an array.
|
|
2141
|
-
*
|
|
2142
|
-
* @example
|
|
2143
|
-
* findDuplicates([1, 2, 2, 3, 4, 4]); // => [2, 4]
|
|
2144
|
-
* findDuplicates(["apple", "banana", "apple", "orange"]); // => ["apple"]
|
|
2145
|
-
* findDuplicates([{ a: 1 }, { a: 1 }, { a: 2 }]); // => [{ a: 1 }]
|
|
2146
|
-
* findDuplicates([NaN, NaN, 1]); // => [NaN]
|
|
2147
|
-
* findDuplicates([true, false, true]); // => [true]
|
|
2148
|
-
* findDuplicates([1, 2, 3]); // => []
|
|
2149
|
-
*/
|
|
2150
|
-
declare const findDuplicates:<T>(values:T[])=>T[];
|
|
2151
|
-
/** --------------------------------
|
|
2152
|
-
* * ***Creates a new object excluding specified keys.***
|
|
2153
|
-
* --------------------------------
|
|
2154
|
-
* This function creates a shallow copy of the given object
|
|
2155
|
-
* omitting the specified keys. It will return a new object
|
|
2156
|
-
* without mutating the original.
|
|
2157
|
-
*
|
|
2158
|
-
* It also validates that `keysToOmit` does not contain duplicate keys.
|
|
2159
|
-
*
|
|
2160
|
-
* Internally, it uses `isEqual` to check for duplicates in the `keysToOmit` array.
|
|
2161
|
-
*
|
|
2162
|
-
* @template I The type of the input object.
|
|
2163
|
-
* @template K The keys to omit from the object.
|
|
2164
|
-
* @param {I} object - The source object to omit keys from.
|
|
2165
|
-
* @param {K[]} keysToOmit - An array of keys to exclude from the returned object.
|
|
2166
|
-
* @returns {Omit<I, K>} A new object without the specified keys.
|
|
2167
|
-
*
|
|
2168
|
-
* @throws {TypeError} If `keysToOmit` is not an array.
|
|
2169
|
-
* @throws {Error} If duplicate keys are found in `keysToOmit`.
|
|
2170
|
-
*
|
|
2171
|
-
* @example
|
|
2172
|
-
* omitKeys({ a: 1, b: 2, c: 3 }, ["b", "c"]);
|
|
2173
|
-
* // => { a: 1 }
|
|
2174
|
-
*
|
|
2175
|
-
* @example
|
|
2176
|
-
* omitKeys({ name: "John", age: 30 }, ["age"]);
|
|
2177
|
-
* // => { name: "John" }
|
|
2178
|
-
*
|
|
2179
|
-
* @example
|
|
2180
|
-
* omitKeys({ a: 1, b: 2 }, []);
|
|
2181
|
-
* // => { a: 1, b: 2 } (no changes)
|
|
2182
|
-
*/
|
|
2183
|
-
declare const omitKeys:<I extends Record<string,unknown>,K extends keyof I>(object:I,keysToOmit:K[])=>Omit<I,K>;type DotPath$1<T,Prev extends string="">=T extends Array<infer U>? DotPath$1<U,`${Prev}${Prev extends "" ? "":"."}${number}`>:T extends object ?{[K in keyof T & string]:`${Prev}${Prev extends "" ? "":"."}${K}` | DotPath$1<T[K],`${Prev}${Prev extends "" ? "":"."}${K}`>;}[keyof T & string]:never;
|
|
2184
|
-
/** ------------------------------------------------------
|
|
2185
|
-
* * Recursively omits properties from an object using dot notation paths.
|
|
2186
|
-
* * Also removes resulting empty objects (`{}`) and arrays (`[]`),
|
|
2187
|
-
* * cascading upwards to remove empty parents until root if needed.
|
|
2188
|
-
* ------------------------------------------------------
|
|
2189
|
-
*
|
|
2190
|
-
* @template I - Type of the input object
|
|
2191
|
-
*
|
|
2192
|
-
* @param {I} object
|
|
2193
|
-
* The object to process. Should be a plain nested object or array structure.
|
|
2194
|
-
*
|
|
2195
|
-
* @param {DotPath<I>[]} keysToOmit
|
|
2196
|
-
* An array of string paths in dot notation indicating the properties to remove.
|
|
2197
|
-
* Paths can include numeric indices to target array elements, e.g. `"arr.0.x"` to remove `x`
|
|
2198
|
-
* from the first object inside the `arr` array.
|
|
2199
|
-
*
|
|
2200
|
-
* @returns {Partial<I>}
|
|
2201
|
-
* A new deeply cloned object with the specified keys omitted,
|
|
2202
|
-
* with resulting empty objects or arrays fully removed (even if it collapses to `{}`).
|
|
2203
|
-
*
|
|
2204
|
-
* @throws {TypeError}
|
|
2205
|
-
* If `keysToOmit` is not an array will throw TypeError.
|
|
2206
|
-
*
|
|
2207
|
-
* @throws {Error}
|
|
2208
|
-
* If `keysToOmit` contains duplicate paths will throw Error.
|
|
2209
|
-
*
|
|
2210
|
-
* @remarks
|
|
2211
|
-
* ⚠️ Be careful: if after omission an object or array becomes empty, it will be removed entirely
|
|
2212
|
-
* including all the way up to the root if necessary, resulting in `{}`.
|
|
2213
|
-
*
|
|
2214
|
-
* @example
|
|
2215
|
-
* omitKeysDeep({ a: { b: { c: 1 }, d: 2 }, e: 3 }, ["a.b.c"]);
|
|
2216
|
-
* // → { a: { d: 2 }, e: 3 }
|
|
2217
|
-
*
|
|
2218
|
-
* @example
|
|
2219
|
-
* omitKeysDeep({ a: [{ b: 1 }, { c: 2 }] }, ["a.0.b"]);
|
|
2220
|
-
* // → { a: [{ c: 2 }] }
|
|
2221
|
-
*
|
|
2222
|
-
* @example
|
|
2223
|
-
* omitKeysDeep({ a: [{ b: 1 }] }, ["a.0.b"]);
|
|
2224
|
-
* // → {} (array becomes empty and removed)
|
|
2225
|
-
*
|
|
2226
|
-
* @example
|
|
2227
|
-
* omitKeysDeep({ complex: [{ deep: [{ x: 1, y: 2 }] }] }, ["complex.0.deep.0.x"]);
|
|
2228
|
-
* // → { complex: [{ deep: [{ y: 2 }] }] }
|
|
2229
|
-
*
|
|
2230
|
-
* @example
|
|
2231
|
-
* omitKeysDeep({ complex: [{ deep: [{ x: 1 }] }] }, ["complex.0.deep.0.x"]);
|
|
2232
|
-
* // → {} (deep chain emptied and collapsed)
|
|
2233
|
-
*
|
|
2234
|
-
* @example
|
|
2235
|
-
* omitKeysDeep({ data: [[{ foo: 1, bar: 2 }]] }, ["data.0.0.foo"]);
|
|
2236
|
-
* // → { data: [[{ bar: 2 }]] }
|
|
2237
|
-
*
|
|
2238
|
-
* @example
|
|
2239
|
-
* omitKeysDeep({ data: [[{ foo: 1 }]] }, ["data.0.0.foo"]);
|
|
2240
|
-
* // → {} (nested arrays emptied completely)
|
|
2241
|
-
*
|
|
2242
|
-
* @example
|
|
2243
|
-
* omitKeysDeep({ x: [{ y: [{ z: 1 }, { w: 2 }] }] }, ["x.0.y.0.z"]);
|
|
2244
|
-
* // → { x: [{ y: [{ w: 2 }] }] }
|
|
2245
|
-
*
|
|
2246
|
-
* @example
|
|
2247
|
-
* omitKeysDeep({ x: [{ y: [{ z: 1 }] }] }, ["x.0.y.0.z"]);
|
|
2248
|
-
* // → {} (entire nested arrays removed)
|
|
2249
|
-
*
|
|
2250
|
-
* @example
|
|
2251
|
-
* omitKeysDeep({ p: { q: { r: 5 } }, s: 6 }, ["p.q.r"]);
|
|
2252
|
-
* // → { s: 6 } (`p` removed because it becomes empty)
|
|
2253
|
-
*
|
|
2254
|
-
* @example
|
|
2255
|
-
* omitKeysDeep({ arr: [{ a: 1, b: 2 }, { c: 3 }] }, ["arr.0.a"]);
|
|
2256
|
-
* // → { arr: [{ b: 2 }, { c: 3 }] }
|
|
2257
|
-
*
|
|
2258
|
-
* @example
|
|
2259
|
-
* omitKeysDeep({ root: [{ sub: [{ leaf: 10 }] }] }, ["root.0.sub.0.leaf"]);
|
|
2260
|
-
* // → {} (deep nested arrays emptied to root)
|
|
2261
|
-
*
|
|
2262
|
-
* @example
|
|
2263
|
-
* omitKeysDeep({ meta: { tags: ["x", "y"], count: 2 } }, ["meta.count"]);
|
|
2264
|
-
* // → { meta: { tags: ["x", "y"] } }
|
|
2265
|
-
*
|
|
2266
|
-
* @example
|
|
2267
|
-
* omitKeysDeep({ arr: [[{ a: 1 }, { b: 2 }]] }, ["arr.0.0.a"]);
|
|
2268
|
-
* // → { arr: [[{ b: 2 }]] }
|
|
2269
|
-
*
|
|
2270
|
-
* @example
|
|
2271
|
-
* omitKeysDeep({ arr: [[{ a: 1 }]] }, ["arr.0.0.a"]);
|
|
2272
|
-
* // → {} (double nested emptied)
|
|
2273
|
-
*
|
|
2274
|
-
* @example
|
|
2275
|
-
* omitKeysDeep({ nested: [{ list: [{ id: 1, val: 2 }] }] }, ["nested.0.list.0.val"]);
|
|
2276
|
-
* // → { nested: [{ list: [{ id: 1 }] }] }
|
|
2277
|
-
*
|
|
2278
|
-
* @example
|
|
2279
|
-
* omitKeysDeep({ nested: [{ list: [{ id: 1 }] }] }, ["nested.0.list.0.id"]);
|
|
2280
|
-
* // → {} (full collapse to empty)
|
|
2281
|
-
*
|
|
2282
|
-
* @example
|
|
2283
|
-
* omitKeysDeep({ mixed: { a: [1, 2, 3], b: { c: 4 } } }, ["mixed.b.c"]);
|
|
2284
|
-
* // → { mixed: { a: [1, 2, 3] } }
|
|
2285
|
-
*/
|
|
2286
|
-
declare const omitKeysDeep:<I extends Record<string,unknown>>(object:I,keysToOmit:DotPath$1<I>[])=>Partial<I>;
|
|
2287
|
-
/** --------------------------------
|
|
2288
|
-
* * Removes Property from PROPS Collection
|
|
2289
|
-
* --------------------------------
|
|
2290
|
-
* @description Becarefull put array in arrayException, If array is duplicated it will be throw an exception error
|
|
2291
|
-
* @param object is Record as object (string,any)
|
|
2292
|
-
* @param arrayExcept is Array exception []
|
|
2293
|
-
* @returns
|
|
2294
|
-
*
|
|
2295
|
-
* @deprecated - Use `omitKeys` instead, this function will remove a next update.
|
|
2296
|
-
*/
|
|
2297
|
-
declare const omitProps:<I extends Record<string,unknown>,S extends(keyof I)[]>(object:I,arrayExcept:S)=>Omit<I,S[number]>| undefined;
|
|
2298
|
-
/** ----------------------------------------------------------
|
|
2299
|
-
* * ***Extracts the base file name (without extension) from a given URL, file path, or file name.***
|
|
2300
|
-
* ----------------------------------------------------------
|
|
2301
|
-
*
|
|
2302
|
-
* - ✅ Strips known extensions (including multi-part extensions such as `.tar.gz`, `.tar.bz2`, etc.).
|
|
2303
|
-
* - ✅ Handles plain file names, local file paths, and full URLs seamlessly.
|
|
2304
|
-
* - ✅ If the path ends with a `/`, returns an empty string `""` (represents a directory or empty segment).
|
|
2305
|
-
* - ✅ If the input is empty, whitespace, or not a string, returns `undefined`.
|
|
2306
|
-
* - ✅ Leaves unknown or unrecognized extensions intact (does not attempt to strip unknown file extensions).
|
|
2307
|
-
*
|
|
2308
|
-
* Behavior summary:
|
|
2309
|
-
* - `extractFileName("https://example.com/file.txt")` → `"file"`
|
|
2310
|
-
* - `extractFileName("/local/path/image.jpeg")` → `"image"`
|
|
2311
|
-
* - `extractFileName("backup.archive.tar.gz")` → `"backup.archive"`
|
|
2312
|
-
* - `extractFileName("folder/")` → `""`
|
|
2313
|
-
* - `extractFileName("")` → `undefined`
|
|
2314
|
-
* - `extractFileName("unknownfile.weirdext")` → `"unknownfile.weirdext"` (keeps unknown extension)
|
|
2315
|
-
*
|
|
2316
|
-
* This is particularly useful for displaying or logging file names
|
|
2317
|
-
* without cluttering them with redundant extensions, while being careful
|
|
2318
|
-
* not to accidentally truncate unfamiliar formats.
|
|
2319
|
-
*
|
|
2320
|
-
* @param {string} url - The URL, file system path, or plain file name to process.
|
|
2321
|
-
* @returns {string | undefined} The file name without its extension(s),
|
|
2322
|
-
* or `undefined` if input is invalid,
|
|
2323
|
-
* or an empty string `""` if the path ends with `/`.
|
|
2324
|
-
*
|
|
2325
|
-
* @example
|
|
2326
|
-
* extractFileName("document.pdf"); // "document"
|
|
2327
|
-
* extractFileName("/files/archive.tar.gz"); // "archive"
|
|
2328
|
-
* extractFileName("https://cdn.site.com/video.mp4"); // "video"
|
|
2329
|
-
* extractFileName("folder/"); // ""
|
|
2330
|
-
* extractFileName("strangefile.unknownext"); // "strangefile.unknownext"
|
|
2331
|
-
* extractFileName(""); // undefined
|
|
2332
|
-
*/
|
|
2333
|
-
declare const extractFileName:(url:string)=>string | undefined;
|
|
2334
|
-
/** ---------------------------------
|
|
2335
|
-
* * ***Compares two objects for deep equality.***
|
|
2336
|
-
* ---------------------------------
|
|
2337
|
-
* * This Function using `lodash` library.
|
|
2338
|
-
*
|
|
2339
|
-
* @template T1 The type of the first object.
|
|
2340
|
-
* @template T2 The type of the second object.
|
|
2341
|
-
* @param {T1} object1 - The first object to compare.
|
|
2342
|
-
* @param {T2} object2 - The second object to compare.
|
|
2343
|
-
* @returns {boolean} `true` if both objects are deeply equal, otherwise `false`.
|
|
2344
|
-
*
|
|
2345
|
-
* @example
|
|
2346
|
-
* areObjectsEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // Returns true
|
|
2347
|
-
* areObjectsEqual({ a: 1 }, { a: 1, b: undefined }); // Returns false
|
|
2348
|
-
* areObjectsEqual([1, 2, 3], [1, 2, 3]); // Returns true
|
|
2349
|
-
*/
|
|
2350
|
-
declare const areObjectsEqual:(object1:unknown,object2:unknown)=>boolean;
|
|
2351
|
-
/** ---------------------------------
|
|
2352
|
-
* * ***Checks if two URLs are the same, ignoring query parameters.***
|
|
2353
|
-
* ---------------------------------
|
|
2354
|
-
*
|
|
2355
|
-
* This function compares only the protocol, host, and pathname.
|
|
2356
|
-
*
|
|
2357
|
-
* @param {URL} urlA - The first URL to compare.
|
|
2358
|
-
* @param {URL} urlB - The second URL to compare.
|
|
2359
|
-
* @returns {boolean} Returns `true` if both URLs are the same (ignoring search parameters), otherwise `false`.
|
|
2360
|
-
*/
|
|
2361
|
-
declare const areURLsEqualPath:(urlA:URL,urlB:URL)=>boolean;
|
|
2362
|
-
/** ---------------------------------
|
|
2363
|
-
* * ***Checks if two URLs are exactly the same, including protocol, host, pathname, and query parameters.***
|
|
2364
|
-
* ---------------------------------
|
|
2365
|
-
*
|
|
2366
|
-
* @param {URL} urlA - The first URL to compare.
|
|
2367
|
-
* @param {URL} urlB - The second URL to compare.
|
|
2368
|
-
* @returns {boolean} Returns `true` if both URLs are identical, otherwise `false`.
|
|
2369
|
-
*/
|
|
2370
|
-
declare const areURLsIdentical:(urlA:URL,urlB:URL)=>boolean;
|
|
2371
|
-
/** ----------------------------------------------------------
|
|
2372
|
-
* * ***Checks if at least one element from `targetArray` exists in `sourceArray`.***
|
|
2373
|
-
* ----------------------------------------------------------
|
|
2374
|
-
*
|
|
2375
|
-
* - ✅ Uses `Set` for **faster lookup** compared to `Array.prototype.includes()`.
|
|
2376
|
-
* - ✅ Supports **any data type** (`number`, `string`, `boolean`, `object`, `array`, `function`, etc.).
|
|
2377
|
-
* - ✅ Uses **reference equality** for non-primitive values (object, array, function).
|
|
2378
|
-
* - ✅ Returns `false` if either array is missing, empty, or not an array.
|
|
2379
|
-
*
|
|
2380
|
-
* @template T - The expected type of array elements.
|
|
2381
|
-
*
|
|
2382
|
-
* @param {T[]} [sourceArray] - The array to search within.
|
|
2383
|
-
* @param {T[]} [targetArray] - The array containing elements to match.
|
|
2384
|
-
*
|
|
2385
|
-
* @returns {boolean}
|
|
2386
|
-
* - `true` if **at least one element from `targetArray` is strictly found in `sourceArray`**.
|
|
2387
|
-
* - Comparison uses:
|
|
2388
|
-
* - **Value equality** for primitives (`number`, `string`, `boolean`, `null`, `undefined`).
|
|
2389
|
-
* - **Reference equality** for objects, arrays, and functions.
|
|
2390
|
-
* - `false` if:
|
|
2391
|
-
* - No matching elements exist,
|
|
2392
|
-
* - Either array is not provided, not an actual array, or is empty.
|
|
2393
|
-
*
|
|
2394
|
-
* @example
|
|
2395
|
-
* arrayHasAnyMatch(["apple", "banana", "cherry"], ["banana", "grape"]); // → true
|
|
2396
|
-
* arrayHasAnyMatch(["red", "blue"], ["green", "yellow"]); // → false
|
|
2397
|
-
* arrayHasAnyMatch([1, 2, 3], [3, 4, 5]); // → true
|
|
2398
|
-
* arrayHasAnyMatch([], ["test"]); // → false
|
|
2399
|
-
* arrayHasAnyMatch(["A", "B", "C"], []); // → false
|
|
2400
|
-
*
|
|
2401
|
-
* @example
|
|
2402
|
-
* const obj = { x: 1 };
|
|
2403
|
-
* arrayHasAnyMatch([obj], [obj]); // → true (same reference)
|
|
2404
|
-
* arrayHasAnyMatch([{ x: 1 }], [{ x: 1 }]); // → false (different reference)
|
|
2405
|
-
*
|
|
2406
|
-
* @example
|
|
2407
|
-
* const fn = () => "hello";
|
|
2408
|
-
* arrayHasAnyMatch([fn], [fn]); // → true
|
|
2409
|
-
* arrayHasAnyMatch([() => "hello"], [() => "hello"]); // → false (different function reference)
|
|
2410
|
-
*
|
|
2411
|
-
* @example
|
|
2412
|
-
* const arr = [1, 2];
|
|
2413
|
-
* arrayHasAnyMatch([arr], [arr]); // → true
|
|
2414
|
-
* arrayHasAnyMatch([[1, 2]], [[1, 2]]); // → false (different array object)
|
|
2415
|
-
*/
|
|
2416
|
-
declare const arrayHasAnyMatch:<T>(sourceArray?:T[],targetArray?:T[])=>boolean;
|
|
2417
|
-
/** ----------------------------------------------------------
|
|
2418
|
-
* * ***Recursively checks if a given key exists in an object or array.***
|
|
2419
|
-
* ----------------------------------------------------------
|
|
2420
|
-
*
|
|
2421
|
-
* - ✅ **Supports deeply nested objects and arrays**, searching recursively.
|
|
2422
|
-
* - ✅ Uses `Object.prototype.hasOwnProperty.call()` to safely check if the key exists at each level,
|
|
2423
|
-
* even if its value is `null` or `undefined`.
|
|
2424
|
-
* - ✅ Optimized to return `true` immediately when the key is found (short-circuits).
|
|
2425
|
-
* - ✅ Handles edge cases gracefully:
|
|
2426
|
-
* - Returns `false` for `null`, `undefined`, or non-object inputs.
|
|
2427
|
-
* - Returns `false` if key is not found anywhere, even in deeply nested structures.
|
|
2428
|
-
*
|
|
2429
|
-
* ⚠️ Note: This function only checks for **the existence of the key itself**,
|
|
2430
|
-
* not whether its value is non-null or non-undefined.
|
|
2431
|
-
* If you need to check for both existence and meaningful value, write a stricter function.
|
|
2432
|
-
*
|
|
2433
|
-
* @template T - The type of the input object or array.
|
|
2434
|
-
* @param {T | Record<string, unknown> | unknown[]} object - The object or array to search.
|
|
2435
|
-
* @param {PropertyKey} key - The key to look for (string, number, or symbol).
|
|
2436
|
-
* @returns {boolean} Returns `true` if the key exists anywhere in the object or array (even with `null` / `undefined` value), otherwise `false`.
|
|
2437
|
-
*
|
|
2438
|
-
* @example
|
|
2439
|
-
* doesKeyExist({ name: "John", age: 30 }, "age"); // true
|
|
2440
|
-
* doesKeyExist({ user: { profile: { email: "test@example.com" } } }, "email"); // true
|
|
2441
|
-
* doesKeyExist([{ id: 1 }, { id: 2 }], "id"); // true
|
|
2442
|
-
* doesKeyExist({ a: { b: { c: 10 } } }, "d"); // false
|
|
2443
|
-
* doesKeyExist(null, "name"); // false
|
|
2444
|
-
* doesKeyExist(undefined, "test"); // false
|
|
2445
|
-
*
|
|
2446
|
-
* @example
|
|
2447
|
-
* // Key exists even if value is null or undefined:
|
|
2448
|
-
* doesKeyExist({ a: null, b: undefined, c: { d: null } }, "a"); // true
|
|
2449
|
-
* doesKeyExist({ a: null, b: undefined, c: { d: null } }, "b"); // true
|
|
2450
|
-
* doesKeyExist({ a: null, b: undefined, c: { d: null } }, "d"); // true
|
|
2451
|
-
*
|
|
2452
|
-
* @example
|
|
2453
|
-
* doesKeyExist({ a: 1 }, true); // ❌ Throws TypeError
|
|
2454
|
-
* doesKeyExist({ a: 1 }, ["not", "valid"]); // ❌ Throws TypeError
|
|
2455
|
-
*/
|
|
2456
|
-
declare const doesKeyExist:<T>(object:T | Record<string,unknown>| unknown[],key:PropertyKey)=>boolean;
|
|
2457
|
-
/** ---------------------------------
|
|
2458
|
-
* * ***Extracts all valid URLs from a given string.***
|
|
2459
|
-
* ---------------------------------
|
|
2460
|
-
*
|
|
2461
|
-
* This function scans the input url and returns an array of URLs
|
|
2462
|
-
* that match a valid `http` or `https` format.
|
|
2463
|
-
*
|
|
2464
|
-
* Supports:
|
|
2465
|
-
* - Internationalized domain names (IDN), e.g. `https://münich.de`
|
|
2466
|
-
* - Unicode & emoji paths, e.g. `https://example.com/🎉/page`
|
|
2467
|
-
* - Long URLs with multiple queries & fragments, e.g. `https://example.com/path?foo=1#hash`
|
|
2468
|
-
*
|
|
2469
|
-
* Ignores:
|
|
2470
|
-
* - Non-string inputs
|
|
2471
|
-
* - Empty or whitespace-only strings
|
|
2472
|
-
* - Non-HTTP(S) protocols (ftp, mailto, etc)
|
|
2473
|
-
*
|
|
2474
|
-
* @example
|
|
2475
|
-
* extractURLs("Visit https://example.com and https://例子.公司");
|
|
2476
|
-
* // => ["https://example.com", "https://例子.公司"]
|
|
2477
|
-
*
|
|
2478
|
-
* @example
|
|
2479
|
-
* extractURLs("Here: https://example.com/🎉/page");
|
|
2480
|
-
* // => ["https://example.com/🎉/page"]
|
|
2481
|
-
*
|
|
2482
|
-
* @example
|
|
2483
|
-
* extractURLs("ftp://example.com http://example.com");
|
|
2484
|
-
* // => ["http://example.com"]
|
|
2485
|
-
*
|
|
2486
|
-
*
|
|
2487
|
-
* @param {string} [url] - The input string containing potential URLs.
|
|
2488
|
-
* @returns {string[] | null} An array of extracted URLs or `null` if no URLs are found.
|
|
2489
|
-
*/
|
|
2490
|
-
declare const extractURLs:(url:string)=>string[] | null;
|
|
2491
|
-
/** ----------------------------------------------------------
|
|
2492
|
-
* * ***Type guard: Checks if a value is an array.***
|
|
2493
|
-
* ----------------------------------------------------------
|
|
2494
|
-
*
|
|
2495
|
-
* - ✅ Uses `Array.isArray()` for reliable and safe type checking.
|
|
2496
|
-
* - ✅ Supports TypeScript **type narrowing** using `value is T[]`.
|
|
2497
|
-
* - ✅ Handles edge cases like `null`, `undefined`, and non-array objects.
|
|
2498
|
-
*
|
|
2499
|
-
* @template T - The expected type of array elements.
|
|
2500
|
-
* @param {unknown} value - The value to check.
|
|
2501
|
-
* @returns {value is T[]} Returns `true` if the value is an array, otherwise `false`.
|
|
2502
|
-
*
|
|
2503
|
-
* @example
|
|
2504
|
-
* isArray([1, 2, 3]); // true
|
|
2505
|
-
* isArray([]); // true
|
|
2506
|
-
* isArray("hello"); // false
|
|
2507
|
-
* isArray({ key: "value" }); // false
|
|
2508
|
-
* isArray(null); // false
|
|
2509
|
-
* isArray(undefined); // false
|
|
2510
|
-
*/
|
|
2511
|
-
declare function isArray<T>(value:T[]):value is T[];declare function isArray(value:unknown):value is unknown[];
|
|
2512
|
-
/** ----------------------------------------------------------
|
|
2513
|
-
* * ***Type guard: Checks if a value is of type bigint.***
|
|
2514
|
-
* ----------------------------------------------------------
|
|
2515
|
-
*
|
|
2516
|
-
* - ✅ Uses `typeof value === "bigint"` for strict type checking.
|
|
2517
|
-
* - ✅ Supports TypeScript type narrowing with `value is bigint`.
|
|
2518
|
-
* - ❗ Returns `false` for `BigInt` object (object-wrapped), e.g. `Object(BigInt(123))`
|
|
2519
|
-
*
|
|
2520
|
-
* @param value - The value to check.
|
|
2521
|
-
* @returns {value is bigint} - `true` if value is a primitive `bigint`.
|
|
2522
|
-
*
|
|
2523
|
-
* @example
|
|
2524
|
-
* isBigInt(123n); // true
|
|
2525
|
-
* isBigInt(BigInt(123)); // true
|
|
2526
|
-
* isBigInt("123"); // false
|
|
2527
|
-
* isBigInt(Object(BigInt(1))); // false
|
|
2528
|
-
*/
|
|
2529
|
-
declare const isBigInt:(value:unknown)=>value is bigint;
|
|
2530
|
-
/** ---------------------------------------------------------
|
|
2531
|
-
* * ***Type guard: Checks if a value is of type `boolean`.***
|
|
2532
|
-
* ---------------------------------------------------------
|
|
2533
|
-
*
|
|
2534
|
-
* @param {unknown} value - The value to check.
|
|
2535
|
-
* @returns {boolean} Returns `true` if the value is a boolean, otherwise `false`.
|
|
2536
|
-
*
|
|
2537
|
-
* @example
|
|
2538
|
-
* isBoolean(true); // true
|
|
2539
|
-
* isBoolean(false); // true
|
|
2540
|
-
* isBoolean("true"); // false
|
|
2541
|
-
*/
|
|
2542
|
-
declare const isBoolean:(value:unknown)=>value is boolean;
|
|
2543
|
-
/** -----------------------------------------------------------
|
|
2544
|
-
* * Checks whether an input looks like a currency or number string,
|
|
2545
|
-
* * using the same smart multi-locale parsing logic as `parseCurrencyString`.
|
|
2546
|
-
* -----------------------------------------------------------
|
|
2547
|
-
*
|
|
2548
|
-
* ✅ Highlights:
|
|
2549
|
-
* - Supports strings or numbers like:
|
|
2550
|
-
* - "15.000,10" (European)
|
|
2551
|
-
* - "15,000.10" (US)
|
|
2552
|
-
* - "15'000.10" (Swiss)
|
|
2553
|
-
* - "15 000,10" (French)
|
|
2554
|
-
* - "Rp 15.000,10" or "$15,000.10"
|
|
2555
|
-
* - Also accepts simple numbers (15300.95).
|
|
2556
|
-
*
|
|
2557
|
-
* 🚀 Uses the same core logic as `parseCurrencyString` but
|
|
2558
|
-
* just checks if a final parsed float is sensible.
|
|
2559
|
-
*
|
|
2560
|
-
* @param {string|number} input
|
|
2561
|
-
* The input value to check.
|
|
2562
|
-
*
|
|
2563
|
-
* @returns {boolean}
|
|
2564
|
-
* `true` if it can be reasonably parsed into a currency-like number,
|
|
2565
|
-
* `false` otherwise.
|
|
2566
|
-
*
|
|
2567
|
-
* @example
|
|
2568
|
-
* isCurrencyLike("Rp 15.000,10");
|
|
2569
|
-
* // ➔ true
|
|
2570
|
-
*
|
|
2571
|
-
* isCurrencyLike("$15,000.10");
|
|
2572
|
-
* // ➔ true
|
|
2573
|
-
*
|
|
2574
|
-
* isCurrencyLike("(15'000.10)");
|
|
2575
|
-
* // ➔ true
|
|
2576
|
-
*
|
|
2577
|
-
* isCurrencyLike("abc");
|
|
2578
|
-
* // ➔ false
|
|
2579
|
-
*
|
|
2580
|
-
* isCurrencyLike(15300.95);
|
|
2581
|
-
* // ➔ true
|
|
2582
|
-
*
|
|
2583
|
-
* isCurrencyLike("");
|
|
2584
|
-
* // ➔ false
|
|
2585
|
-
*/
|
|
2586
|
-
declare const isCurrencyLike:(input:string | number)=>boolean;
|
|
2587
|
-
/** ----------------------------------------------------------
|
|
2588
|
-
* * ***Type guard: Checks if a value is a valid `Date` object.***
|
|
2589
|
-
* ----------------------------------------------------------
|
|
2590
|
-
*
|
|
2591
|
-
* - ✅ Checks if value is an instance of `Date`
|
|
2592
|
-
* - ✅ Ensures the date is valid (`!isNaN(date.getTime())`)
|
|
2593
|
-
* - ❗ Returns false for strings or invalid date objects
|
|
2594
|
-
*
|
|
2595
|
-
* @param value - The value to check.
|
|
2596
|
-
* @returns {boolean} - `true` if value is a valid Date object.
|
|
2597
|
-
*
|
|
2598
|
-
* @example
|
|
2599
|
-
* isDate(new Date()); // true
|
|
2600
|
-
* isDate(new Date("invalid")); // false
|
|
2601
|
-
* isDate("2024-01-01"); // false
|
|
2602
|
-
*/
|
|
2603
|
-
declare const isDate:(value:unknown)=>value is Date;
|
|
2604
|
-
/**
|
|
2605
|
-
* ----------------------------------------------------------
|
|
2606
|
-
* *** Performs a deep equality check between two values. ***
|
|
2607
|
-
* ----------------------------------------------------------
|
|
2608
|
-
*
|
|
2609
|
-
* - Compares nested arrays, objects, Dates, RegExp, NaN, Symbols, Set, and Map.
|
|
2610
|
-
* - Handles special cases:
|
|
2611
|
-
* - `NaN` is considered equal to `NaN`.
|
|
2612
|
-
* - `Date` objects are equal if `.getTime()` is equal.
|
|
2613
|
-
* - `RegExp` objects are equal if `.toString()` is equal.
|
|
2614
|
-
* - `Symbol("x")` and `Symbol("x")` are treated equal if `.toString()` matches.
|
|
2615
|
-
* - `Set` and `Map` are deeply compared by content (order-insensitive).
|
|
2616
|
-
* - Does not support circular references.
|
|
2617
|
-
*/
|
|
2618
|
-
declare const isDeepEqual:(a:unknown,b:unknown)=>boolean;
|
|
2619
|
-
/** ----------------------------------------------------------
|
|
2620
|
-
* * ***Checks whether a given value is an empty array.***
|
|
2621
|
-
* ----------------------------------------------------------
|
|
2622
|
-
*
|
|
2623
|
-
* This utility checks if a value is an array and whether it's empty.
|
|
2624
|
-
* Non-array inputs are considered "empty" by default (defensive strategy).
|
|
2625
|
-
*
|
|
2626
|
-
* @param {unknown} [value] - The value to check.
|
|
2627
|
-
* @returns {boolean} - Returns `true` if it's not an array or an empty array.
|
|
2628
|
-
*
|
|
2629
|
-
* @example
|
|
2630
|
-
* isEmptyArray([]); // true
|
|
2631
|
-
* isEmptyArray([1, 2, 3]); // false
|
|
2632
|
-
* isEmptyArray("not an array"); // true
|
|
2633
|
-
* isEmptyArray(null); // true
|
|
2634
|
-
* isEmptyArray(undefined); // true
|
|
2635
|
-
*
|
|
2636
|
-
* @example
|
|
2637
|
-
* if (isEmptyArray(data.items)) {
|
|
2638
|
-
* console.log("No items to display.");
|
|
2639
|
-
* }
|
|
2640
|
-
*/
|
|
2641
|
-
declare const isEmptyArray:(value?:unknown)=>boolean;
|
|
2642
|
-
/** ----------------------------------------------------------
|
|
2643
|
-
* * ***Recursively checks if a value is "deeply empty".***
|
|
2644
|
-
* ----------------------------------------------------------
|
|
2645
|
-
*
|
|
2646
|
-
* - Returns `true` for:
|
|
2647
|
-
* - Empty objects: `{}`
|
|
2648
|
-
* - Empty arrays: `[]`
|
|
2649
|
-
* - Nested empty structures: `{ a: [], b: {} }`
|
|
2650
|
-
* - Falsy values (except numbers): `null`, `undefined`, `false`, `""`, `NaN`
|
|
2651
|
-
*
|
|
2652
|
-
* - Returns `false` for:
|
|
2653
|
-
* - Non-zero numbers
|
|
2654
|
-
* - Objects or arrays containing non-empty values
|
|
2655
|
-
* - Non-empty strings, `true`, functions, symbols, etc.
|
|
2656
|
-
*
|
|
2657
|
-
* @param {unknown} value - The value to deeply check.
|
|
2658
|
-
* @returns {boolean} `true` if the value is deeply empty, otherwise `false`.
|
|
2659
|
-
*
|
|
2660
|
-
* @example
|
|
2661
|
-
* isEmptyDeep({}); // true
|
|
2662
|
-
* isEmptyDeep([]); // true
|
|
2663
|
-
* isEmptyDeep({ a: {} }); // true
|
|
2664
|
-
* isEmptyDeep([[], {}]); // true
|
|
2665
|
-
* isEmptyDeep({ a: [1] }); // false
|
|
2666
|
-
* isEmptyDeep([0]); // false
|
|
2667
|
-
* isEmptyDeep("test"); // false
|
|
2668
|
-
* isEmptyDeep(""); // true
|
|
2669
|
-
* isEmptyDeep(0); // false
|
|
2670
|
-
* isEmptyDeep(NaN); // true
|
|
2671
|
-
*/
|
|
2672
|
-
declare const isEmptyDeep:(value:unknown)=>boolean;
|
|
2673
|
-
/** ----------------------------------------------------------
|
|
2674
|
-
* * ***Checks whether a given value is an empty string.***
|
|
2675
|
-
* ----------------------------------------------------------
|
|
2676
|
-
*
|
|
2677
|
-
* This utility checks if a string is empty (`""`) or consists only of whitespace
|
|
2678
|
-
* (if `trim` is enabled, which is the default). Non-string inputs are considered empty.
|
|
2679
|
-
*
|
|
2680
|
-
* @param {string} [value] - The value to check.
|
|
2681
|
-
* @param {Object} [options] - Optional settings.
|
|
2682
|
-
* @param {boolean} [options.trim=true] - Whether to trim the string before checking, defaultValue `true`.
|
|
2683
|
-
* @returns {boolean} - Returns `true` if the value is string not a string or value string is considered empty.
|
|
2684
|
-
*
|
|
2685
|
-
* @example
|
|
2686
|
-
* isEmptyString(""); // true
|
|
2687
|
-
* isEmptyString(" "); // true (default trims)
|
|
2688
|
-
* isEmptyString(" ", { trim: false }); // false
|
|
2689
|
-
* isEmptyString("hello"); // false
|
|
2690
|
-
* isEmptyString(undefined); // true
|
|
2691
|
-
* isEmptyString(null); // true
|
|
2692
|
-
* isEmptyString(123 as any); // true
|
|
2693
|
-
*
|
|
2694
|
-
* @example
|
|
2695
|
-
* // Used in validation
|
|
2696
|
-
* if (isEmptyString(form.name)) {
|
|
2697
|
-
* throw new Error("Name cannot be empty.");
|
|
2698
|
-
* }
|
|
2699
|
-
*/
|
|
2700
|
-
declare const isEmptyString:(value?:string | null,options?:{
|
|
2701
|
-
/**
|
|
2702
|
-
* Whether to trim the string before checking.
|
|
2703
|
-
*
|
|
2704
|
-
* @default `true` */
|
|
2705
|
-
trim?:boolean;})=>boolean;
|
|
2706
|
-
/** ----------------------------------------------------------
|
|
2707
|
-
* * ***Determines if a value is an empty object (`{}`), empty array (`[]`), or generally falsy.***
|
|
2708
|
-
* ----------------------------------------------------------
|
|
2709
|
-
*
|
|
2710
|
-
* - Returns `true` for `{}`, `[]`, `null`, `undefined`, `""`, `false`, and `NaN`.
|
|
2711
|
-
* - Returns `false` for objects with properties, non-empty arrays, numbers, functions, and other non-empty values.
|
|
2712
|
-
* - Safely handles `null`, `undefined`, and non-object types without throwing.
|
|
2713
|
-
*
|
|
2714
|
-
* @param {unknown} value - The value to evaluate.
|
|
2715
|
-
* @returns {boolean} `true` if the value is considered empty, otherwise `false`.
|
|
2716
|
-
*
|
|
2717
|
-
* @example
|
|
2718
|
-
* isEmptyValue({}); // true
|
|
2719
|
-
* isEmptyValue([]); // true
|
|
2720
|
-
* isEmptyValue({ key: "value" }); // false
|
|
2721
|
-
* isEmptyValue([1, 2, 3]); // false
|
|
2722
|
-
* isEmptyValue(null); // true
|
|
2723
|
-
* isEmptyValue(undefined); // true
|
|
2724
|
-
* isEmptyValue(""); // true
|
|
2725
|
-
* isEmptyValue(" "); // true
|
|
2726
|
-
* isEmptyValue(0); // false
|
|
2727
|
-
* isEmptyValue(-1); // false
|
|
2728
|
-
* isEmptyValue(2); // false
|
|
2729
|
-
* isEmptyValue(() => {}); // false
|
|
2730
|
-
*/
|
|
2731
|
-
declare const isEmptyValue:(value:unknown)=>boolean;
|
|
2732
|
-
/** ----------------------------------------------------------
|
|
2733
|
-
* * ***Checks if a given value is an instance of the `Error` object.***
|
|
2734
|
-
* ----------------------------------------------------------
|
|
2735
|
-
*
|
|
2736
|
-
* - ✅ This function helps ensure that the provided value is a valid JavaScript error.
|
|
2737
|
-
* - ✅ Useful for error handling in TypeScript.
|
|
2738
|
-
*
|
|
2739
|
-
* @param {unknown} error - The value to check.
|
|
2740
|
-
* @returns {boolean} - Returns `true` if the value is an `Error`, otherwise `false`.
|
|
2741
|
-
*
|
|
2742
|
-
* @example
|
|
2743
|
-
* isError(new Error("Something went wrong")); // true
|
|
2744
|
-
* isError("Error message"); // false
|
|
2745
|
-
* isError(null); // false
|
|
2746
|
-
*/
|
|
2747
|
-
declare const isError:(error:unknown)=>error is Error;
|
|
2748
|
-
/**
|
|
2749
|
-
* ----------------------------------------------------------
|
|
2750
|
-
* * ***Type guard: Checks if a value is a function.***
|
|
2751
|
-
* ----------------------------------------------------------
|
|
2752
|
-
*
|
|
2753
|
-
* - ✅ Uses `typeof value === "function"` for strict type checking.
|
|
2754
|
-
* - ✅ Supports TypeScript type narrowing with `value is (...args: any[]) => any`.
|
|
2755
|
-
* - ✅ Safe alternative to `Function` type (doesn't trigger ESLint warning).
|
|
2756
|
-
*
|
|
2757
|
-
* @param value - The value to check.
|
|
2758
|
-
* @returns {boolean} - `true` if the value is a function.
|
|
2759
|
-
*
|
|
2760
|
-
* @example
|
|
2761
|
-
* isFunction(() => {}); // true
|
|
2762
|
-
* isFunction(async () => {}); // true
|
|
2763
|
-
* isFunction(null); // false
|
|
2764
|
-
* isFunction({}); // false
|
|
2765
|
-
*/
|
|
2766
|
-
declare const isFunction:(value:unknown)=>value is AnyFunction;
|
|
2767
|
-
/** ----------------------------------------------------------
|
|
2768
|
-
* * ***Type guard: Checks if a value is a non-empty array.***
|
|
2769
|
-
* ----------------------------------------------------------
|
|
2770
|
-
*
|
|
2771
|
-
* - ✅ Ensures the value is an actual array using `Array.isArray`.
|
|
2772
|
-
* - ✅ Ensures the array contains at least one item.
|
|
2773
|
-
* - ✅ Narrows type to `T[]` (non-empty array) when true.
|
|
2774
|
-
*
|
|
2775
|
-
* @param value - The value to check.
|
|
2776
|
-
* @returns {value is T[]} - `true` if value is a non-empty array.
|
|
2777
|
-
*
|
|
2778
|
-
* @example
|
|
2779
|
-
* isNonEmptyArray([1, 2, 3]); // true
|
|
2780
|
-
* isNonEmptyArray([]); // false
|
|
2781
|
-
* isNonEmptyArray(null); // false
|
|
2782
|
-
* isNonEmptyArray("test"); // false
|
|
2783
|
-
*/
|
|
2784
|
-
declare function isNonEmptyArray(value:unknown):value is unknown[];declare function isNonEmptyArray<T>(value:T):value is NonNullable<Extract<T,unknown[]>>;
|
|
2785
|
-
/**
|
|
2786
|
-
* ----------------------------------------------------------
|
|
2787
|
-
* * ***Type guard: Checks if a value is a non-empty string.***
|
|
2788
|
-
* ----------------------------------------------------------
|
|
2789
|
-
*
|
|
2790
|
-
* Determines whether the given `value` is a string containing at least one non-whitespace character,
|
|
2791
|
-
* with optional trimming behavior.
|
|
2792
|
-
*
|
|
2793
|
-
* - ✅ Validates that `value` is a string.
|
|
2794
|
-
* - ✅ Optionally trims the string before checking (`trim` defaults to `true`).
|
|
2795
|
-
* - ✅ Returns `true` only if the resulting string is not empty.
|
|
2796
|
-
*
|
|
2797
|
-
* @param value - The value to test.
|
|
2798
|
-
* @param options - Optional settings.
|
|
2799
|
-
* @param options.trim - If `true`, trims the string before checking. Defaults to `true`.
|
|
2800
|
-
*
|
|
2801
|
-
* @returns `true` if `value` is a non-empty string, otherwise `false`.
|
|
2802
|
-
*
|
|
2803
|
-
* @example
|
|
2804
|
-
* isNonEmptyString("hello"); // true
|
|
2805
|
-
* isNonEmptyString(" ", { trim: true }); // false
|
|
2806
|
-
* isNonEmptyString(" ", { trim: false }); // true
|
|
2807
|
-
* isNonEmptyString(""); // false
|
|
2808
|
-
* isNonEmptyString(123); // false
|
|
2809
|
-
* isNonEmptyString(undefined); // false
|
|
2810
|
-
* isNonEmptyString(null); // false
|
|
2811
|
-
* isNonEmptyString({}); // false
|
|
2812
|
-
* isNonEmptyString([]); // false
|
|
2813
|
-
*/
|
|
2814
|
-
declare const isNonEmptyString:(value:unknown,options?:{trim?:boolean;})=>value is string;
|
|
2815
|
-
/** ---------------------------------------------------------
|
|
2816
|
-
* * ***Type guard: Checks if a value is `null`.***
|
|
2817
|
-
* ---------------------------------------------------------
|
|
2818
|
-
*
|
|
2819
|
-
* @param {unknown} val - The value to check.
|
|
2820
|
-
* @returns {val is null} Returns `true` if the value is `null`, otherwise `false`.
|
|
2821
|
-
*
|
|
2822
|
-
* @example
|
|
2823
|
-
* isNull(null); // true
|
|
2824
|
-
* isNull(0); // false
|
|
2825
|
-
*/
|
|
2826
|
-
declare const isNull:(val:unknown)=>val is null;
|
|
2827
|
-
/** ---------------------------------------------------------
|
|
2828
|
-
* * ***Type guard: Checks if a value is of type `number`.***
|
|
2829
|
-
* ---------------------------------------------------------
|
|
2830
|
-
*
|
|
2831
|
-
* **Note**: To exclude Infinity, -Infinity, and NaN, which are classified as numbers, use the `isFinite(...)`.
|
|
2832
|
-
* @param {unknown} value - The value to check.
|
|
2833
|
-
* @returns {boolean} Returns `true` if the value is a number (excluding NaN), otherwise `false`.
|
|
2834
|
-
*
|
|
2835
|
-
* @example
|
|
2836
|
-
* isNumber(42); // true
|
|
2837
|
-
* isNumber(NaN); // false
|
|
2838
|
-
* isNumber("42"); // false
|
|
2839
|
-
*/
|
|
2840
|
-
declare const isNumber:(value:unknown)=>value is number;type IsObject<T=unknown>=unknown extends T ? Record<string,unknown>& unknown:T extends object ? T extends NonPlainObject ? never:T:never;
|
|
2841
|
-
/** ---------------------------------------------------------
|
|
2842
|
-
* * ***Type guard: Checks if a value is a plain object.***
|
|
2843
|
-
* ---------------------------------------------------------
|
|
2844
|
-
*
|
|
2845
|
-
* Will return `false` for arrays, undefined and `null`.
|
|
2846
|
-
*
|
|
2847
|
-
* @param {unknown} val - The value to check.
|
|
2848
|
-
* @returns {val is Record<string, unknown>} Returns `true` if the value is a plain object, otherwise `false`.
|
|
2849
|
-
*
|
|
2850
|
-
* @example
|
|
2851
|
-
* isObject({ name: "Alice" }); // true
|
|
2852
|
-
* isObject([1,2,3]); // false
|
|
2853
|
-
* isObject(null); // false
|
|
2854
|
-
* isObject(undefined); // false
|
|
2855
|
-
*/
|
|
2856
|
-
declare function isObject<T>(val:T):val is IsObject<T>;
|
|
2857
|
-
/** ----------------------------------------------------------
|
|
2858
|
-
* * ***Type guard: Checks if a value is a RegExp instance.***
|
|
2859
|
-
* ----------------------------------------------------------
|
|
2860
|
-
*
|
|
2861
|
-
* @param value - The value to check.
|
|
2862
|
-
* @returns {boolean} - `true` if value is an instance of RegExp.
|
|
2863
|
-
*
|
|
2864
|
-
* @example
|
|
2865
|
-
* isRegExp(/abc/); // true
|
|
2866
|
-
* isRegExp(new RegExp("abc")); // true
|
|
2867
|
-
* isRegExp("abc"); // false
|
|
2868
|
-
*/
|
|
2869
|
-
declare const isRegExp:(value:unknown)=>value is RegExp;
|
|
2870
|
-
/** ---------------------------------------------------------
|
|
2871
|
-
* * ***Type guard: Checks if a value is of type `string`.***
|
|
2872
|
-
* ---------------------------------------------------------
|
|
2873
|
-
*
|
|
2874
|
-
* This function is a type guard that determines if the provided value
|
|
2875
|
-
* is a `string`. It can be used to narrow types in TypeScript.
|
|
2876
|
-
*
|
|
2877
|
-
* @param {unknown} value - The value to check.
|
|
2878
|
-
* @returns {boolean} `true` if the value is a string, otherwise `false`.
|
|
2879
|
-
*
|
|
2880
|
-
* @example
|
|
2881
|
-
* isString("hello"); // true
|
|
2882
|
-
* isString(123); // false
|
|
2883
|
-
*
|
|
2884
|
-
* // Usage in type narrowing
|
|
2885
|
-
* const value: unknown = getValue();
|
|
2886
|
-
* if (isString(value)) {
|
|
2887
|
-
* // TypeScript now knows `value` is a string
|
|
2888
|
-
* console.log(value.toUpperCase());
|
|
2889
|
-
* }
|
|
2890
|
-
*/
|
|
2891
|
-
declare const isString:(value:unknown)=>value is string;
|
|
2892
|
-
/** ----------------------------------------------------------
|
|
2893
|
-
* * ***Checks whether a value is a symbol.***
|
|
2894
|
-
* ----------------------------------------------------------
|
|
2895
|
-
*
|
|
2896
|
-
* @param value - The value to check.
|
|
2897
|
-
* @returns `true` if the value is of type symbol.
|
|
2898
|
-
*
|
|
2899
|
-
* @example
|
|
2900
|
-
* isSymbol(Symbol("id")); // true
|
|
2901
|
-
* isSymbol("not a symbol"); // false
|
|
2902
|
-
* isSymbol(123); // false
|
|
2903
|
-
* isSymbol(undefined); // false
|
|
2904
|
-
*/
|
|
2905
|
-
declare const isSymbol:(value:unknown)=>value is symbol;
|
|
2906
|
-
/** ---------------------------------------------------------
|
|
2907
|
-
* * ***Type guard: Checks if a value is an instance of the `URL` class.***
|
|
2908
|
-
* ---------------------------------------------------------
|
|
2909
|
-
*
|
|
2910
|
-
* @param {unknown} val - The value to check.
|
|
2911
|
-
* @returns {val is URL} Returns `true` if the value is a `URL` instance, otherwise `false`.
|
|
2912
|
-
*
|
|
2913
|
-
* @example
|
|
2914
|
-
* isURL(new URL("https://example.com")); // true
|
|
2915
|
-
* isURL("https://example.com"); // false
|
|
2916
|
-
*/
|
|
2917
|
-
declare const isURL:(val:unknown)=>val is URL;
|
|
2918
|
-
/** ---------------------------------------------------------
|
|
2919
|
-
* * ***Type guard: Checks if a value is `undefined`.***
|
|
2920
|
-
* ---------------------------------------------------------
|
|
2921
|
-
*
|
|
2922
|
-
* @param {unknown} val - The value to check.
|
|
2923
|
-
* @returns {val is undefined} Returns `true` if the value is `undefined`, otherwise `false`.
|
|
2924
|
-
*
|
|
2925
|
-
* @example
|
|
2926
|
-
* isUndefined(undefined); // true
|
|
2927
|
-
* isUndefined(null); // false
|
|
2928
|
-
*/
|
|
2929
|
-
declare const isUndefined:(val:unknown)=>val is undefined;
|
|
2930
|
-
/** ---------------------------------
|
|
2931
|
-
* * ***Validates whether a given string is a properly formatted URL.***
|
|
2932
|
-
* ---------------------------------
|
|
2933
|
-
*
|
|
2934
|
-
* This function checks if the input string follows a valid URL format,
|
|
2935
|
-
* including `http` or `https` protocols.
|
|
2936
|
-
*
|
|
2937
|
-
* @param {string} [url] - The URL string to validate.
|
|
2938
|
-
* @returns {boolean} `true` if the URL is valid, otherwise `false`.
|
|
2939
|
-
*/
|
|
2940
|
-
declare const isValidURL:(url?:string | null)=>boolean;
|
|
2941
|
-
/** ----------------------------------------------------------
|
|
2942
|
-
* * ***Checks if the given `text` contains all of the specified `searchWords`.***
|
|
2943
|
-
* ----------------------------------------------------------
|
|
2944
|
-
*
|
|
2945
|
-
* - ✅ Uses **regular expressions** for flexible pattern matching.
|
|
2946
|
-
* - ✅ **Escapes special characters** to prevent regex injection attacks.
|
|
2947
|
-
* - ✅ **Trims input** to avoid false positives with empty spaces.
|
|
2948
|
-
* - ✅ **Supports exact word matching** (optional).
|
|
2949
|
-
*
|
|
2950
|
-
* @param {string} text - The text to search within.
|
|
2951
|
-
* @param {string[]} searchWords - An array of words/phrases to match against the text.
|
|
2952
|
-
* @param {boolean} [options.exactMatch=false] - If `true`, matches whole words only, defaultValue is `false`.
|
|
2953
|
-
* @param {string} [options.flags="i"] - Optional regex flags (default: `"i"` for case-insensitive).
|
|
2954
|
-
* @returns {boolean} - `true` if all `searchWords` are found in `text`, otherwise `false`.
|
|
2955
|
-
*
|
|
2956
|
-
* @example
|
|
2957
|
-
* textContainsAll("Hello world, WithAI APP", ["Hello", "world"]); // true
|
|
2958
|
-
* textContainsAll("JavaScript and TypeScript", ["Java", "Script"]); // true
|
|
2959
|
-
* textContainsAll("Machine Learning", ["AI", "Learning"]); // false
|
|
2960
|
-
* textContainsAll("open-source", ["open"], { exactMatch: true }); // false (because options `exactMatch=true`)
|
|
2961
|
-
*/
|
|
2962
|
-
declare const textContainsAll:<T extends string>(text:T,searchWords:T[] | string[],options?:{
|
|
2963
|
-
/** If `true`, matches whole words only, defaultValue is `false`. */
|
|
2964
|
-
exactMatch?:boolean;
|
|
2965
|
-
/** Optional regex flags (default: `"i"` for case-insensitive). */
|
|
2966
|
-
flags?:string;})=>boolean;
|
|
2967
|
-
/** ----------------------------------------------------------
|
|
2968
|
-
* * ***Checks if the given `text` contains at least one of the specified `searchWords`.***
|
|
2969
|
-
* ----------------------------------------------------------
|
|
2970
|
-
*
|
|
2971
|
-
* - ✅ Uses **regular expressions** for flexible pattern matching.
|
|
2972
|
-
* - ✅ **Escapes special characters** to prevent regex injection attacks.
|
|
2973
|
-
* - ✅ **Trims input** to avoid false positives with empty spaces.
|
|
2974
|
-
* - ✅ **Supports exact word matching** (optional).
|
|
2975
|
-
*
|
|
2976
|
-
* @param {string} text - The text to search within.
|
|
2977
|
-
* @param {string[]} searchWords - An array of words/phrases to match against the text.
|
|
2978
|
-
* @param {boolean} [options.exactMatch=false] - If `true`, matches whole words only, defaultValue is `false`.
|
|
2979
|
-
* @param {string} [options.flags="i"] - Optional regex flags (default: `"i"` for case-insensitive).
|
|
2980
|
-
* @returns {boolean} - `true` if at least one `searchWord` is found in `text`, otherwise `false`.
|
|
2981
|
-
*
|
|
2982
|
-
* @example
|
|
2983
|
-
* textContainsAny("Hello world", ["hello", "test"]); // true
|
|
2984
|
-
* textContainsAny("withAI APP", ["chat", "ai"]); // false
|
|
2985
|
-
* textContainsAny("TypeScript is great!", ["script", "java"]); // true
|
|
2986
|
-
* textContainsAny("open-source", ["open"], { exactMatch: true }); // false (because options `exactMatch=true`)
|
|
2987
|
-
*/
|
|
2988
|
-
declare const textContainsAny:<T extends string>(text:T,searchWords:T[] | string[],options?:{
|
|
2989
|
-
/** If `true`, matches whole words only, defaultValue is `false`. */
|
|
2990
|
-
exactMatch?:boolean;
|
|
2991
|
-
/** Optional regex flags (default: `"i"` for case-insensitive). */
|
|
2992
|
-
flags?:string;})=>boolean;type IsObjectOrArray<T>=unknown extends T ? Record<string,unknown>| unknown[]:T extends object ? T extends unknown[] ? T:T extends NonPlainObject ? never:T:never;
|
|
2993
|
-
/** ---------------------------------------------------------
|
|
2994
|
-
* * ***Type guard: Checks if a value is an object or array.***
|
|
2995
|
-
* ---------------------------------------------------------
|
|
2996
|
-
*
|
|
2997
|
-
* Will return `false` for `null`, `undefined`, and primitives.
|
|
2998
|
-
*
|
|
2999
|
-
* @param {unknown} value - The value to check.
|
|
3000
|
-
* @returns {value is object} Returns `true` if the value is an object or array.
|
|
3001
|
-
*
|
|
3002
|
-
* @example
|
|
3003
|
-
* isObjectOrArray({ name: "Alice" }); // true
|
|
3004
|
-
* isObjectOrArray([1,2,3]); // true
|
|
3005
|
-
* isObjectOrArray(null); // false
|
|
3006
|
-
* isObjectOrArray(undefined); // false
|
|
3007
|
-
* isObjectOrArray("hello"); // false
|
|
3008
|
-
*/
|
|
3009
|
-
declare function isObjectOrArray<T>(value:T):value is IsObjectOrArray<T>;
|
|
3010
|
-
/** -------------------
|
|
3011
|
-
* * ***Checks if `value` is likely an `arguments` object.***
|
|
3012
|
-
* -------------------
|
|
3013
|
-
*
|
|
3014
|
-
* @param {*} value The value to check.
|
|
3015
|
-
*
|
|
3016
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
3017
|
-
* else `false`.
|
|
3018
|
-
*
|
|
3019
|
-
* @example
|
|
3020
|
-
*
|
|
3021
|
-
* isArguments(function() { return arguments; }());
|
|
3022
|
-
* // => true
|
|
3023
|
-
*
|
|
3024
|
-
* isArguments([1, 2, 3]);
|
|
3025
|
-
* // => false
|
|
3026
|
-
*/
|
|
3027
|
-
declare const isArguments:(value:unknown)=>value is IArguments;
|
|
3028
|
-
/** ----------------------------------------------------
|
|
3029
|
-
* * ***Checks if `value` is classified as an `ArrayBuffer` object.***
|
|
3030
|
-
* ----------------------------------------------------
|
|
3031
|
-
*
|
|
3032
|
-
* @param {*} value The value to check.
|
|
3033
|
-
* @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
|
|
3034
|
-
*
|
|
3035
|
-
* @example
|
|
3036
|
-
*
|
|
3037
|
-
* isArrayBuffer(new ArrayBuffer(2));
|
|
3038
|
-
* // => true
|
|
3039
|
-
*
|
|
3040
|
-
* isArrayBuffer(new Array(2));
|
|
3041
|
-
* // => false
|
|
3042
|
-
*/
|
|
3043
|
-
declare function isArrayBuffer(value:unknown):value is ArrayBuffer;
|
|
3044
|
-
/** ----------------------------------------------------
|
|
3045
|
-
* * ***Checks if `value` is array-like. A value is considered array-like if it's
|
|
3046
|
-
* not a function and has a `value.length` that's an integer greater than or
|
|
3047
|
-
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.***
|
|
3048
|
-
* ----------------------------------------------------
|
|
3049
|
-
*
|
|
3050
|
-
* @param {*} value The value to check.
|
|
3051
|
-
*
|
|
3052
|
-
* @returns Returns `true` if `value` is array-like, else `false`.
|
|
3053
|
-
*
|
|
3054
|
-
* @example
|
|
3055
|
-
* isArrayLike([1, 2, 3]);
|
|
3056
|
-
* // => true
|
|
3057
|
-
*
|
|
3058
|
-
* isArrayLike(document.body.children);
|
|
3059
|
-
* // => true
|
|
3060
|
-
*
|
|
3061
|
-
* isArrayLike('abc');
|
|
3062
|
-
* // => false
|
|
3063
|
-
*
|
|
3064
|
-
* isArrayLike(noop);
|
|
3065
|
-
* // => false
|
|
3066
|
-
*/
|
|
3067
|
-
declare function isArrayLike<T extends{__anyHack:unknown;}>(value:T):boolean;declare function isArrayLike(value:((...args:any[])=>any)| null | undefined):value is never;declare function isArrayLike(value:unknown):value is{length:number;};
|
|
3068
|
-
/** ----------------------------------------------------
|
|
3069
|
-
* * ***This method is like `isArrayLike` except that it also checks if `value` is an object.***
|
|
3070
|
-
* ----------------------------------------------------
|
|
3071
|
-
*
|
|
3072
|
-
* @param {*} value The value to check.
|
|
3073
|
-
*
|
|
3074
|
-
* @returns Returns `true` if `value` is array-like object, else `false`.
|
|
3075
|
-
*
|
|
3076
|
-
* @example
|
|
3077
|
-
* isArrayLikeObject([1, 2, 3]);
|
|
3078
|
-
* // => true
|
|
3079
|
-
*
|
|
3080
|
-
* isArrayLikeObject(document.body.children);
|
|
3081
|
-
* // => true
|
|
3082
|
-
*
|
|
3083
|
-
* isArrayLikeObject('abc');
|
|
3084
|
-
* // => false
|
|
3085
|
-
*
|
|
3086
|
-
* isArrayLikeObject(noop);
|
|
3087
|
-
* // => false
|
|
3088
|
-
*/
|
|
3089
|
-
declare function isArrayLikeObject<T extends{__anyHack:unknown;}>(value:T):boolean;declare function isArrayLikeObject(value:AnyFunction | string | boolean | number | null | undefined):value is never;declare function isArrayLikeObject(value:unknown):value is object &{length:number;};
|
|
3090
|
-
/** ----------------------------------------------------
|
|
3091
|
-
* * ***Checks if value is a buffer.***
|
|
3092
|
-
* ----------------------------------------------------
|
|
3093
|
-
*
|
|
3094
|
-
* @param {*} value The value to check.
|
|
3095
|
-
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
3096
|
-
* @example
|
|
3097
|
-
*
|
|
3098
|
-
* isBuffer(new Buffer(2));
|
|
3099
|
-
* // => true
|
|
3100
|
-
*
|
|
3101
|
-
* isBuffer(new Uint8Array(2));
|
|
3102
|
-
* // => false
|
|
3103
|
-
*/
|
|
3104
|
-
declare const isBuffer:(value:unknown)=>value is Buffer;
|
|
3105
|
-
/** ----------------------------------------------------
|
|
3106
|
-
* * ***Checks if `value` is likely a DOM element.***
|
|
3107
|
-
* ----------------------------------------------------
|
|
3108
|
-
*
|
|
3109
|
-
* @param {*} value The value to check.
|
|
3110
|
-
* @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
|
|
3111
|
-
* @example
|
|
3112
|
-
*
|
|
3113
|
-
* isElement(document.body);
|
|
3114
|
-
* // => true
|
|
3115
|
-
*
|
|
3116
|
-
* isElement('<body>');
|
|
3117
|
-
* // => false
|
|
3118
|
-
*
|
|
3119
|
-
* isElement(document.createElement("div"));
|
|
3120
|
-
* // => true
|
|
3121
|
-
*/
|
|
3122
|
-
declare function isElement(value:unknown):boolean;type EmptyObject<T>={[K in keyof T]?:never;};type EmptyObjectOf<T>=EmptyObject<T>extends T ? EmptyObject<T>:never;type List<T>=ArrayLike<T>;
|
|
3123
|
-
/** ----------------------------------------------------
|
|
3124
|
-
* * ***Checks if `value` is an empty object, collection, map, or set.***
|
|
3125
|
-
* ----------------------------------------------------
|
|
3126
|
-
*
|
|
3127
|
-
* Objects are considered empty if they have no own enumerable string keyed
|
|
3128
|
-
* properties.
|
|
3129
|
-
*
|
|
3130
|
-
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
|
3131
|
-
* jQuery-like collections are considered empty if they have a `length` of `0`.
|
|
3132
|
-
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
|
3133
|
-
*
|
|
3134
|
-
* @param {*} value The value to check.
|
|
3135
|
-
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
|
3136
|
-
* @example
|
|
3137
|
-
*
|
|
3138
|
-
* isEmpty(null);
|
|
3139
|
-
* // => true
|
|
3140
|
-
*
|
|
3141
|
-
* isEmpty(true);
|
|
3142
|
-
* // => true
|
|
3143
|
-
*
|
|
3144
|
-
* isEmpty(1);
|
|
3145
|
-
* // => true
|
|
3146
|
-
*
|
|
3147
|
-
* isEmpty([1, 2, 3]);
|
|
3148
|
-
* // => false
|
|
3149
|
-
*
|
|
3150
|
-
* isEmpty({ 'a': 1 });
|
|
3151
|
-
* // => false
|
|
3152
|
-
*/
|
|
3153
|
-
declare function isEmpty<T extends{__trapAny:any;}>(value?:T):boolean;declare function isEmpty(value:string):value is "";declare function isEmpty(value:Map<any,any>| Set<any>| List<any>| null | undefined):boolean;declare function isEmpty(value:object):boolean;declare function isEmpty<T extends object>(value:T | null | undefined):value is EmptyObjectOf<T>| null | undefined;declare function isEmpty(value:any):boolean;
|
|
3154
|
-
/** ----------------------------------------------------
|
|
3155
|
-
* * ***Performs a deep comparison between two values to determine if they are equivalent.***
|
|
3156
|
-
* ----------------------------------------------------
|
|
3157
|
-
*
|
|
3158
|
-
* **Note:** This method supports comparing arrays, array buffers, booleans,
|
|
3159
|
-
* date objects, error objects, maps, numbers, `Object` objects, regexes,
|
|
3160
|
-
* sets, strings, symbols, and typed arrays. `Object` objects are compared
|
|
3161
|
-
* by their own, not inherited, enumerable properties. Functions and DOM
|
|
3162
|
-
* nodes are **not** supported.
|
|
3163
|
-
*
|
|
3164
|
-
*
|
|
3165
|
-
* @param value The value to compare.
|
|
3166
|
-
* @param other The other value to compare.
|
|
3167
|
-
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
3168
|
-
*
|
|
3169
|
-
* @example
|
|
3170
|
-
*
|
|
3171
|
-
* const object = { user: "fred" };
|
|
3172
|
-
* const other = { user: "fred" };
|
|
3173
|
-
*
|
|
3174
|
-
* isEqual(object, other);
|
|
3175
|
-
* // => true
|
|
3176
|
-
*
|
|
3177
|
-
* object === other;
|
|
3178
|
-
* // => false
|
|
3179
|
-
*/
|
|
3180
|
-
declare function isEqual(value:unknown,other:unknown):boolean;type IsEqualCustomizer=(value:any,other:any,indexOrKey:PropertyKey | undefined,parent:any,otherParent:any,stack:any)=>boolean | undefined;
|
|
3181
|
-
/** ----------------------------------------------------
|
|
3182
|
-
* * ***This method is like `isEqual` except that it accepts `customizer` which
|
|
3183
|
-
* is invoked to compare values. If `customizer` returns `undefined`, comparisons
|
|
3184
|
-
* are handled by the method instead. The `customizer` is invoked with up to
|
|
3185
|
-
* six arguments: (objValue, othValue [, index|key, object, other, stack]).***
|
|
3186
|
-
* ----------------------------------------------------
|
|
3187
|
-
*
|
|
3188
|
-
* @param {*} value The value to compare.
|
|
3189
|
-
* @param {*} other The other value to compare.
|
|
3190
|
-
* @param {Function} [customizer] The function to customize comparisons.
|
|
3191
|
-
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
3192
|
-
* @example
|
|
3193
|
-
*
|
|
3194
|
-
* function isGreeting(value) {
|
|
3195
|
-
* return /^h(?:i|ello)$/.test(value);
|
|
3196
|
-
* }
|
|
3197
|
-
*
|
|
3198
|
-
* function customizer(objValue, othValue) {
|
|
3199
|
-
* if (isGreeting(objValue) && isGreeting(othValue)) {
|
|
3200
|
-
* return true;
|
|
3201
|
-
* }
|
|
3202
|
-
* }
|
|
3203
|
-
*
|
|
3204
|
-
* var array = ['hello', 'goodbye'];
|
|
3205
|
-
* var other = ['hi', 'goodbye'];
|
|
3206
|
-
*
|
|
3207
|
-
* isEqualWith(array, other, customizer);
|
|
3208
|
-
* // => true
|
|
3209
|
-
*/
|
|
3210
|
-
declare function isEqualWith(value:unknown,other:unknown,customizer?:IsEqualCustomizer):boolean;
|
|
3211
|
-
/** -----------------------------------------------------------------------------
|
|
3212
|
-
* * Checks if `value` is a finite number (not `Infinity`, `-Infinity`, or `NaN`).
|
|
3213
|
-
* -----------------------------------------------------------------------------
|
|
3214
|
-
*
|
|
3215
|
-
* This method is based on
|
|
3216
|
-
* [`Number.isFinite()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite).
|
|
3217
|
-
* It returns `true` only for values that are of type `number` and are finite.
|
|
3218
|
-
*
|
|
3219
|
-
* @param {*} value - The value to check.
|
|
3220
|
-
* @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
|
|
3221
|
-
*
|
|
3222
|
-
* @example
|
|
3223
|
-
*
|
|
3224
|
-
* isFinite(3);
|
|
3225
|
-
* // => true
|
|
3226
|
-
*
|
|
3227
|
-
* isFinite(Number.MIN_VALUE);
|
|
3228
|
-
* // => true
|
|
3229
|
-
*
|
|
3230
|
-
* isFinite(Infinity);
|
|
3231
|
-
* // => false
|
|
3232
|
-
*
|
|
3233
|
-
* isFinite("3");
|
|
3234
|
-
* // => false
|
|
3235
|
-
*/
|
|
3236
|
-
declare function isFinite$1(value?:unknown):boolean;
|
|
3237
|
-
/** ----------------------------------------------------
|
|
3238
|
-
* * ***Checks if `value` is a integer.***
|
|
3239
|
-
* ----------------------------------------------------
|
|
3240
|
-
*
|
|
3241
|
-
* **Note:** This method is based on
|
|
3242
|
-
* [`Number.isInteger`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger).
|
|
3243
|
-
*
|
|
3244
|
-
* @param {*} value The value to check.
|
|
3245
|
-
* @returns {boolean} Returns `true` if `value` is an integer, else `false`.
|
|
3246
|
-
* @example
|
|
3247
|
-
*
|
|
3248
|
-
* isInteger(3);
|
|
3249
|
-
* // => true
|
|
3250
|
-
*
|
|
3251
|
-
* isInteger(Number.MIN_VALUE);
|
|
3252
|
-
* // => false
|
|
3253
|
-
*
|
|
3254
|
-
* isInteger(Infinity);
|
|
3255
|
-
* // => false
|
|
3256
|
-
*
|
|
3257
|
-
* isInteger('3');
|
|
3258
|
-
* // => false
|
|
3259
|
-
*/
|
|
3260
|
-
declare function isInteger(value?:unknown):boolean;
|
|
3261
|
-
/** ----------------------------------------
|
|
3262
|
-
* * ***Checks if `value` is a valid array-like length.***
|
|
3263
|
-
* ----------------------------------------
|
|
3264
|
-
*
|
|
3265
|
-
* **Note:** This method is loosely based on
|
|
3266
|
-
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
3267
|
-
*
|
|
3268
|
-
* @param {*} value The value to check.
|
|
3269
|
-
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
3270
|
-
* @example
|
|
3271
|
-
*
|
|
3272
|
-
* isLength(3); // => true
|
|
3273
|
-
* isLength(Number.MIN_VALUE); // => false
|
|
3274
|
-
* isLength(Infinity); // => false
|
|
3275
|
-
* isLength('3'); // => false
|
|
3276
|
-
* isLength(4294967296); // => true
|
|
3277
|
-
*
|
|
3278
|
-
*/
|
|
3279
|
-
declare function isLength(value:unknown):boolean;
|
|
3280
|
-
/** ----------------------------------------------------
|
|
3281
|
-
* * ***Performs a partial deep comparison between `object` and `source` to determine if `object` contains equivalent property values.***
|
|
3282
|
-
* ----------------------------------------------------
|
|
3283
|
-
*
|
|
3284
|
-
* - This method returns `true` if all the properties in `source` exist in `object` and are deeply equal.
|
|
3285
|
-
* - It does **not** require `object` and `source` to be the same shape—only that `object` contains a subset that matches `source`.
|
|
3286
|
-
*
|
|
3287
|
-
* ⚠️ Arrays are treated as objects: only the matching indexed keys are compared.
|
|
3288
|
-
*
|
|
3289
|
-
* @remarks
|
|
3290
|
-
* - This method is equivalent to a partially applied `matches(source)` predicate.
|
|
3291
|
-
* - Partial comparisons will match:
|
|
3292
|
-
* - An empty array (`[]`) in `source` with any array in `object`.
|
|
3293
|
-
* - An empty object (`{}`) in `source` with any object in `object`.
|
|
3294
|
-
*
|
|
3295
|
-
* @param object - The object to inspect.
|
|
3296
|
-
* @param source - The object containing property values to match.
|
|
3297
|
-
* @returns Returns `true` if `object` is a match, else `false`.
|
|
3298
|
-
*
|
|
3299
|
-
* @example
|
|
3300
|
-
* const object = { a: 1, b: 2 };
|
|
3301
|
-
*
|
|
3302
|
-
* isMatch(object, { b: 2 });
|
|
3303
|
-
* // => true
|
|
3304
|
-
*
|
|
3305
|
-
* isMatch(object, { b: 1 });
|
|
3306
|
-
* // => false
|
|
3307
|
-
*
|
|
3308
|
-
* isMatch([1, 2, 3], [1, 2]);
|
|
3309
|
-
* // => true (treats arrays as objects with index keys)
|
|
3310
|
-
*/
|
|
3311
|
-
declare function isMatch(object:object,source:object):boolean;type isMatchWithCustomizer=(value:any,other:any,indexOrKey:PropertyKey,object:object,source:object)=>boolean | undefined;
|
|
3312
|
-
/** ----------------------------------------------------
|
|
3313
|
-
* * ***Performs a partial deep comparison between `object` and `source`,
|
|
3314
|
-
* like `isMatch`, but with a `customizer` function to control comparisons.***
|
|
3315
|
-
* ----------------------------------------------------
|
|
3316
|
-
*
|
|
3317
|
-
* If `customizer` returns a value other than `undefined`, that value is used
|
|
3318
|
-
* as the result of the comparison for the current property. Otherwise,
|
|
3319
|
-
* the comparison falls back to the default deep equality logic.
|
|
3320
|
-
*
|
|
3321
|
-
* @remarks
|
|
3322
|
-
* - The `customizer` function is invoked with up to **five** arguments:
|
|
3323
|
-
* `(objValue, srcValue, keyOrIndex, object, source)`.
|
|
3324
|
-
* - Returning `true` from `customizer` will short-circuit further comparison
|
|
3325
|
-
* for that key.
|
|
3326
|
-
* - Returning `false` will cause `isMatchWith` to return `false` immediately.
|
|
3327
|
-
* - Returning `undefined` allows default comparison to proceed.
|
|
3328
|
-
*
|
|
3329
|
-
* @category Lang
|
|
3330
|
-
*
|
|
3331
|
-
* @param object - The object to inspect.
|
|
3332
|
-
* @param source - The object of property values to match.
|
|
3333
|
-
* @param customizer - The function to customize comparisons.
|
|
3334
|
-
* @returns Returns `true` if `object` is a match, else `false`.
|
|
3335
|
-
*
|
|
3336
|
-
* @example
|
|
3337
|
-
* function isGreeting(value: unknown) {
|
|
3338
|
-
* return typeof value === 'string' && /^h(?:i|ello)$/.test(value);
|
|
3339
|
-
* }
|
|
3340
|
-
*
|
|
3341
|
-
* function customizer(objValue: unknown, srcValue: unknown) {
|
|
3342
|
-
* if (isGreeting(objValue) && isGreeting(srcValue)) {
|
|
3343
|
-
* return true;
|
|
3344
|
-
* }
|
|
3345
|
-
* }
|
|
3346
|
-
*
|
|
3347
|
-
* const object = { greeting: 'hello' };
|
|
3348
|
-
* const source = { greeting: 'hi' };
|
|
3349
|
-
*
|
|
3350
|
-
* isMatchWith(object, source, customizer);
|
|
3351
|
-
* // => true
|
|
3352
|
-
*/
|
|
3353
|
-
declare function isMatchWith(value:object,other:object,customizer?:isMatchWithCustomizer):boolean;
|
|
3354
|
-
/** ----------------------------------------------------
|
|
3355
|
-
* * ***Checks if `value` is `NaN`.***
|
|
3356
|
-
* ----------------------------------------------------
|
|
3357
|
-
*
|
|
3358
|
-
* **Note:** This method is based on
|
|
3359
|
-
* [`Number.isNaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) and is not the same as
|
|
3360
|
-
* global [`isNaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN) which returns `true` for
|
|
3361
|
-
* `undefined` and other non-number values.
|
|
3362
|
-
*
|
|
3363
|
-
* @param {*} value The value to check.
|
|
3364
|
-
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|
3365
|
-
* @example
|
|
3366
|
-
*
|
|
3367
|
-
* import * as RzlUtilsJs from "@rzl-zone/utils-js";
|
|
3368
|
-
*
|
|
3369
|
-
* RzlUtilsJs.isNaN(NaN); // => true
|
|
3370
|
-
*
|
|
3371
|
-
* RzlUtilsJs.isNaN(new Number(NaN)); // => true
|
|
3372
|
-
*
|
|
3373
|
-
* RzlUtilsJs.isNaN(undefined); // => false
|
|
3374
|
-
*
|
|
3375
|
-
* // This global isNaN:
|
|
3376
|
-
* isNaN(undefined); // => true
|
|
3377
|
-
*/
|
|
3378
|
-
declare function isNaN$1(value?:unknown):boolean;
|
|
3379
|
-
/** ----------------------------------------------------
|
|
3380
|
-
* * ***Checks if `value` is a pristine native function.***
|
|
3381
|
-
* ----------------------------------------------------
|
|
3382
|
-
*
|
|
3383
|
-
* **Note:** This method can't reliably detect native functions in the presence
|
|
3384
|
-
* of the core-js package because core-js circumvents this kind of detection.
|
|
3385
|
-
* Despite multiple requests, the core-js maintainer has made it clear: any
|
|
3386
|
-
* attempt to fix the detection will be obstructed. As a result, we're left
|
|
3387
|
-
* with little choice but to throw an error. Unfortunately, this also affects
|
|
3388
|
-
* packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
|
|
3389
|
-
* which rely on core-js.
|
|
3390
|
-
*
|
|
3391
|
-
* @param {*} value The value to check.
|
|
3392
|
-
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
3393
|
-
* else `false`.
|
|
3394
|
-
* @example
|
|
3395
|
-
*
|
|
3396
|
-
* isNative(Array.prototype.push);
|
|
3397
|
-
* // => true
|
|
3398
|
-
*
|
|
3399
|
-
* import * as RzlUtilsJs from "@rzl-zone/utils-js";
|
|
3400
|
-
* isNative(RzlUtilsJs);
|
|
3401
|
-
* // => false
|
|
3402
|
-
*/
|
|
3403
|
-
declare function isNative(value?:unknown):value is AnyFunction;
|
|
3404
|
-
/** ----------------------------------------------------
|
|
3405
|
-
* * ***Checks if `value` is `null` or `undefined`.***
|
|
3406
|
-
* ----------------------------------------------------
|
|
3407
|
-
*
|
|
3408
|
-
* @param {*} value The value to check.
|
|
3409
|
-
* @returns {boolean} Returns `true` if `value` is nullish, else `false`.
|
|
3410
|
-
* @example
|
|
3411
|
-
*
|
|
3412
|
-
* isNil(null);
|
|
3413
|
-
* // => true
|
|
3414
|
-
*
|
|
3415
|
-
* isNil(void 0);
|
|
3416
|
-
* // => true
|
|
3417
|
-
*
|
|
3418
|
-
* isNil(NaN);
|
|
3419
|
-
* // => false
|
|
3420
|
-
*/
|
|
3421
|
-
declare function isNil(value?:unknown):value is null | undefined;
|
|
3422
|
-
/** --------------------------------------------------
|
|
3423
|
-
* * ***Checks if `value` is the
|
|
3424
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
3425
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)***
|
|
3426
|
-
* --------------------------------------------------
|
|
3427
|
-
*
|
|
3428
|
-
* @note
|
|
3429
|
-
* ⚠ **For More Strict Object Use `isObject` instead.**
|
|
3430
|
-
*
|
|
3431
|
-
* @param {*} value The value to check.
|
|
3432
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
3433
|
-
* @example
|
|
3434
|
-
*
|
|
3435
|
-
* isObjectLoose({});
|
|
3436
|
-
* // => true
|
|
3437
|
-
*
|
|
3438
|
-
* isObjectLoose([1, 2, 3]);
|
|
3439
|
-
* // => true
|
|
3440
|
-
*
|
|
3441
|
-
* isObjectLoose(noop);
|
|
3442
|
-
* // => true
|
|
3443
|
-
*
|
|
3444
|
-
* isObjectLoose(null);
|
|
3445
|
-
* // => false
|
|
3446
|
-
*
|
|
3447
|
-
* isObjectLoose(undefined);
|
|
3448
|
-
* // => false
|
|
3449
|
-
*/
|
|
3450
|
-
declare function isObjectLoose<T=object>(value:unknown):value is T;
|
|
3451
|
-
/** ----------------------------------------------------
|
|
3452
|
-
* * ***Checks if `value` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`..***
|
|
3453
|
-
* ----------------------------------------------------
|
|
3454
|
-
*
|
|
3455
|
-
* @param {*} value The value to check.
|
|
3456
|
-
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
3457
|
-
* @example
|
|
3458
|
-
*
|
|
3459
|
-
* function Foo() {
|
|
3460
|
-
* this.a = 1;
|
|
3461
|
-
* }
|
|
3462
|
-
*
|
|
3463
|
-
* isPlainObject(new Foo);
|
|
3464
|
-
* // => false
|
|
3465
|
-
*
|
|
3466
|
-
* isPlainObject([1, 2, 3]);
|
|
3467
|
-
* // => false
|
|
3468
|
-
*
|
|
3469
|
-
* isPlainObject({ 'x': 0, 'y': 0 });
|
|
3470
|
-
* // => true
|
|
3471
|
-
*
|
|
3472
|
-
* isPlainObject(Object.create(null));
|
|
3473
|
-
* // => true
|
|
3474
|
-
*/
|
|
3475
|
-
declare function isPlainObject(value:unknown):value is Record<string,unknown>;declare function isPlainObject<T>(value:T):value is NonNullable<Extract<T,Record<string,unknown>>>;
|
|
3476
|
-
/** --------------------------------------------------
|
|
3477
|
-
* * ***Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 double precision number which isn't the result of a rounded unsafe integer.***
|
|
3478
|
-
* --------------------------------------------------
|
|
3479
|
-
*
|
|
3480
|
-
* **Note:** This method is based on
|
|
3481
|
-
* [`Number.isSafeInteger`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
|
3482
|
-
*
|
|
3483
|
-
* @param {*} value The value to check.
|
|
3484
|
-
* @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
|
|
3485
|
-
* @example
|
|
3486
|
-
*
|
|
3487
|
-
* isSafeInteger(3);
|
|
3488
|
-
* // => true
|
|
3489
|
-
*
|
|
3490
|
-
* isSafeInteger(Number.MIN_VALUE);
|
|
3491
|
-
* // => false
|
|
3492
|
-
*
|
|
3493
|
-
* isSafeInteger(Infinity);
|
|
3494
|
-
* // => false
|
|
3495
|
-
*
|
|
3496
|
-
* isSafeInteger('3');
|
|
3497
|
-
* // => false
|
|
3498
|
-
*/
|
|
3499
|
-
declare function isSafeInteger(value:unknown):value is number;
|
|
3500
|
-
/** --------------------------------------------------
|
|
3501
|
-
* * ***Checks if `value` is classified as a `Set` object.***
|
|
3502
|
-
* --------------------------------------------------
|
|
3503
|
-
*
|
|
3504
|
-
* @param {*} value The value to check.
|
|
3505
|
-
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
|
|
3506
|
-
* @example
|
|
3507
|
-
*
|
|
3508
|
-
* isSet(new Set);
|
|
3509
|
-
* // => true
|
|
3510
|
-
*
|
|
3511
|
-
* isSet(new WeakSet);
|
|
3512
|
-
* // => false
|
|
3513
|
-
*/
|
|
3514
|
-
declare function isSet<T=any>(value:Set<T>):value is Set<T>;declare function isSet(value:unknown):value is Set<any>;
|
|
3515
|
-
/** --------------------------------------------------
|
|
3516
|
-
* * ***Checks if `value` is classified as a typed array.***
|
|
3517
|
-
* --------------------------------------------------
|
|
3518
|
-
*
|
|
3519
|
-
* @param {*} value The value to check.
|
|
3520
|
-
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
3521
|
-
* @example
|
|
3522
|
-
*
|
|
3523
|
-
*
|
|
3524
|
-
* isTypedArray(new Uint8Array); // => true
|
|
3525
|
-
* isTypedArray(new Uint8Array()); // => true
|
|
3526
|
-
* isTypedArray(new Float32Array()); // => true
|
|
3527
|
-
* isTypedArray(new Uint8ClampedArray()); // => true
|
|
3528
|
-
* isTypedArray([]); // => false
|
|
3529
|
-
* isTypedArray(Buffer.from("hi")); // => false
|
|
3530
|
-
*/
|
|
3531
|
-
declare function isTypedArray(value:unknown):value is TypedArray;
|
|
3532
|
-
/** --------------------------------------------------
|
|
3533
|
-
* * ***Checks if `value` is classified as a `WeakMap` object.***
|
|
3534
|
-
* --------------------------------------------------
|
|
3535
|
-
*
|
|
3536
|
-
* @param {*} value The value to check.
|
|
3537
|
-
* @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
|
|
3538
|
-
* @example
|
|
3539
|
-
*
|
|
3540
|
-
* isWeakMap(new WeakMap);
|
|
3541
|
-
* // => true
|
|
3542
|
-
*
|
|
3543
|
-
* isWeakMap(new Map);
|
|
3544
|
-
* // => false
|
|
3545
|
-
*/
|
|
3546
|
-
declare function isWeakMap<K extends object=object,V=unknown>(value:unknown):value is WeakMap<K,V>;
|
|
3547
|
-
/** ----------------------------------------
|
|
3548
|
-
* * ***Creates a delay for a specified duration.***
|
|
3549
|
-
* ----------------------------------------
|
|
3550
|
-
*
|
|
3551
|
-
* @param {number} [milliSeconds=1000] - The duration of the delay in milliSeconds (default: 1000ms).
|
|
3552
|
-
* @param {AbortSignal} [signal] - An optional AbortSignal to cancel the delay.
|
|
3553
|
-
* @returns {Promise<void>} A promise that resolves after the specified delay or rejects if aborted.
|
|
3554
|
-
*
|
|
3555
|
-
* @throws {TypeError} If `milliSeconds` is not a valid non-negative number.
|
|
3556
|
-
* @throws {TypeError} If `signal` is not a valid AbortSignal.
|
|
3557
|
-
* @throws {DOMException} If aborted, rejects with `AbortError`.
|
|
3558
|
-
*
|
|
3559
|
-
* @example
|
|
3560
|
-
* await delay(2000); // waits for 2 seconds
|
|
3561
|
-
*
|
|
3562
|
-
* // With AbortSignal
|
|
3563
|
-
* const controller = new AbortController();
|
|
3564
|
-
* delay(5000, controller.signal).catch(err => console.log(err.name)); // "AbortError"
|
|
3565
|
-
* controller.abort();
|
|
3566
|
-
*/
|
|
3567
|
-
declare const delay:(milliSeconds?:number,signal?:AbortSignal)=>Promise<void>;
|
|
3568
|
-
/** ----------------------------------------------------------
|
|
3569
|
-
* * Capitalizes the first letter of a string.
|
|
3570
|
-
* * Optionally lowercases the rest and trims whitespace.
|
|
3571
|
-
* ----------------------------------------------------------
|
|
3572
|
-
*
|
|
3573
|
-
* @param string - The string to be processed.
|
|
3574
|
-
* @param options - Options to control behavior.
|
|
3575
|
-
* @param options.lowerCaseNextRest - If true, lowercases the rest (next first letter) (default: true).
|
|
3576
|
-
* @param options.trim - If true, trims the string before processing (default: false).
|
|
3577
|
-
* @returns The processed string. Returns "" if input is null, undefined, or not a valid string.
|
|
3578
|
-
*
|
|
3579
|
-
* @example
|
|
3580
|
-
* capitalizeFirst(" hello WORLD ") // " Hello world"
|
|
3581
|
-
* capitalizeFirst(" hello WORLD ", { trim: true }) // "Hello world"
|
|
3582
|
-
* capitalizeFirst("FOO", { lowerCaseNextRest: false }) // "FOO"
|
|
3583
|
-
* capitalizeFirst(" foo BAR ", { trim: true, lowerCaseNextRest: false }) // "Foo BAR"
|
|
3584
|
-
*/
|
|
3585
|
-
declare const capitalizeFirst:(string?:string | null,options?:{
|
|
3586
|
-
/**
|
|
3587
|
-
* @description If true, the rest of the string will be converted to lowercase after capitalizing the first letter.
|
|
3588
|
-
* @default true
|
|
3589
|
-
*/
|
|
3590
|
-
lowerCaseNextRest?:boolean;
|
|
3591
|
-
/**
|
|
3592
|
-
* @description If true, the string will trimmed.
|
|
3593
|
-
* @default false
|
|
3594
|
-
*/
|
|
3595
|
-
trim?:boolean;})=>string;
|
|
3596
|
-
/** ----------------------------------------------------------
|
|
3597
|
-
* * ***Capitalizes the first letter of each word in a string
|
|
3598
|
-
* while converting the rest to lowercase.***
|
|
3599
|
-
* ----------------------------------------------------------
|
|
3600
|
-
*
|
|
3601
|
-
* @param value - The input string to be processed. If `null` or `undefined`, returns an empty string.
|
|
3602
|
-
* @param options - Optional settings to control the output:
|
|
3603
|
-
* - `trim`: If `true`, removes leading and trailing spaces.
|
|
3604
|
-
* - `collapseSpaces`: If `true`, collapses multiple spaces **between words** into a single space (while preserving leading/trailing spaces).
|
|
3605
|
-
*
|
|
3606
|
-
* @returns A new string where each word starts with an uppercase letter
|
|
3607
|
-
* and the remaining letters are lowercase. If `value` is empty, `null`, or `undefined`,
|
|
3608
|
-
* returns an empty string.
|
|
3609
|
-
*
|
|
3610
|
-
* @example
|
|
3611
|
-
* capitalizeWords(" hello world ");
|
|
3612
|
-
* // => " Hello World "
|
|
3613
|
-
*
|
|
3614
|
-
* capitalizeWords(" hello world ", { trim: true });
|
|
3615
|
-
* // => "Hello World"
|
|
3616
|
-
*
|
|
3617
|
-
* capitalizeWords(" hello world ", { collapseSpaces: true });
|
|
3618
|
-
* // => " Hello World "
|
|
3619
|
-
*
|
|
3620
|
-
* capitalizeWords(" hello world ", { trim: true, collapseSpaces: true });
|
|
3621
|
-
* // => "Hello World"
|
|
3622
|
-
*/
|
|
3623
|
-
declare const capitalizeWords:(value?:string | null,options?:{
|
|
3624
|
-
/** If `true`, removes leading and trailing spaces, default `false`. */
|
|
3625
|
-
trim?:boolean;
|
|
3626
|
-
/** If `true`, collapses multiple spaces **between words** into a single space (while preserving leading/trailing spaces), default `false`. */
|
|
3627
|
-
collapseSpaces?:boolean;})=>string;
|
|
3628
|
-
/** ----------------------------------------------------------
|
|
3629
|
-
* * ***Converts a string to `camelCase`.***
|
|
3630
|
-
* ----------------------------------------------------------
|
|
3631
|
-
*
|
|
3632
|
-
* @description
|
|
3633
|
-
* - Splits the string by any sequence of non-alphanumeric characters
|
|
3634
|
-
* (including spaces, punctuation, symbols, hyphens, underscores, emojis, etc).
|
|
3635
|
-
* - The first word is fully lowercase.
|
|
3636
|
-
* - Each subsequent word starts with an uppercase letter and the rest is lowercase.
|
|
3637
|
-
* - Joins all words without separators to form camelCase.
|
|
3638
|
-
* - If input is `null` or `undefined`, returns an empty string.
|
|
3639
|
-
* - Ignores empty segments (multiple delimiters are collapsed).
|
|
3640
|
-
*
|
|
3641
|
-
* @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
|
|
3642
|
-
* @returns {string} The camelCase formatted string.
|
|
3643
|
-
*
|
|
3644
|
-
* @example
|
|
3645
|
-
* toCamelCase("hello world"); // "helloWorld"
|
|
3646
|
-
* toCamelCase("convert_to-camel case"); // "convertToCamelCase"
|
|
3647
|
-
* toCamelCase("___hello--world__ again!!"); // "helloWorldAgain"
|
|
3648
|
-
* toCamelCase("🔥fire_and-ice❄️"); // "fireAndIce"
|
|
3649
|
-
* toCamelCase(null); // ""
|
|
3650
|
-
*/
|
|
3651
|
-
declare const toCamelCase:(value?:string | null)=>string;
|
|
3652
|
-
/** ----------------------------------------------------------
|
|
3653
|
-
* * ***Converts a string to `PascalCase`.***
|
|
3654
|
-
* ----------------------------------------------------------
|
|
3655
|
-
*
|
|
3656
|
-
* @description
|
|
3657
|
-
* - Splits the string by any sequence of non-alphanumeric characters
|
|
3658
|
-
* (including spaces, punctuation, symbols, hyphens, underscores, emojis, etc).
|
|
3659
|
-
* - Each resulting word starts with an uppercase letter, followed by lowercase.
|
|
3660
|
-
* - Joins all words without separators (PascalCase).
|
|
3661
|
-
* - If input is `null` or `undefined`, returns an empty string.
|
|
3662
|
-
* - Ignores empty segments (multiple delimiters are collapsed).
|
|
3663
|
-
*
|
|
3664
|
-
* @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
|
|
3665
|
-
* @returns {string} The PascalCase formatted string.
|
|
3666
|
-
*
|
|
3667
|
-
* @example
|
|
3668
|
-
* toPascalCase("hello world"); // "HelloWorld"
|
|
3669
|
-
* toPascalCase("convert_to-pascal case"); // "ConvertToPascalCase"
|
|
3670
|
-
* toPascalCase("___hello--world__ again!!"); // "HelloWorldAgain"
|
|
3671
|
-
* toPascalCase("🔥fire_and-ice❄️"); // "FireAndIce"
|
|
3672
|
-
* toPascalCase(null); // ""
|
|
3673
|
-
*/
|
|
3674
|
-
declare const toPascalCase:(value?:string | null)=>string;
|
|
3675
|
-
/** ----------------------------------------------------------
|
|
3676
|
-
* * ***Converts a string to `kebab-case`.***
|
|
3677
|
-
* ----------------------------------------------------------
|
|
3678
|
-
*
|
|
3679
|
-
* @description
|
|
3680
|
-
* - Splits the string by any sequence of non-alphanumeric characters
|
|
3681
|
-
* (spaces, hyphens, underscores, symbols, emojis, etc).
|
|
3682
|
-
* - Joins all words with hyphens (-).
|
|
3683
|
-
* - Converts entire string to lowercase.
|
|
3684
|
-
* - If input is `null` or `undefined`, returns an empty string.
|
|
3685
|
-
* - Ignores empty segments (multiple delimiters are collapsed).
|
|
3686
|
-
*
|
|
3687
|
-
* @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
|
|
3688
|
-
* @returns {string} The kebab-case formatted string.
|
|
3689
|
-
*
|
|
3690
|
-
* @example
|
|
3691
|
-
* toKebabCase("Hello World"); // "hello-world"
|
|
3692
|
-
* toKebabCase("convert_to-kebab case"); // "convert-to-kebab-case"
|
|
3693
|
-
* toKebabCase("🔥fire___and--ice❄️"); // "fire-and-ice"
|
|
3694
|
-
* toKebabCase(null); // ""
|
|
3695
|
-
*/
|
|
3696
|
-
declare const toKebabCase:(value?:string | null)=>string;
|
|
3697
|
-
/** ----------------------------------------------------------
|
|
3698
|
-
* * ***Converts a string to `snake_case`.***
|
|
3699
|
-
* ----------------------------------------------------------
|
|
3700
|
-
*
|
|
3701
|
-
* @description
|
|
3702
|
-
* - Lowercases all letters.
|
|
3703
|
-
* - Joins words with `_`.
|
|
3704
|
-
* - Removes special characters, treating them as word separators.
|
|
3705
|
-
* - If input is `null` or `undefined`, returns "".
|
|
3706
|
-
*
|
|
3707
|
-
* @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
|
|
3708
|
-
* @returns {string} snake_case string
|
|
3709
|
-
*
|
|
3710
|
-
* @example
|
|
3711
|
-
* toSnakeCase("Hello World") => "hello_world"
|
|
3712
|
-
* toSnakeCase("convert-to_snake case") => "convert_to_snake_case"
|
|
3713
|
-
*/
|
|
3714
|
-
declare const toSnakeCase:(value?:string | null)=>string;
|
|
3715
|
-
/** ----------------------------------------------------------
|
|
3716
|
-
* * ***Converts a string to `dot.case`.***
|
|
3717
|
-
* ----------------------------------------------------------
|
|
3718
|
-
*
|
|
3719
|
-
* @description
|
|
3720
|
-
* - Lowercases all letters.
|
|
3721
|
-
* - Joins words with `.`.
|
|
3722
|
-
* - Removes special characters, treating them as word separators.
|
|
3723
|
-
* - If input is `null` or `undefined`, returns "".
|
|
3724
|
-
*
|
|
3725
|
-
* @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
|
|
3726
|
-
* @returns {string} dot.case string
|
|
3727
|
-
*
|
|
3728
|
-
* @example
|
|
3729
|
-
* toDotCase("Hello World") => "hello.world"
|
|
3730
|
-
* toDotCase("convert-to_dot case") => "convert.to.dot.case"
|
|
3731
|
-
*/
|
|
3732
|
-
declare const toDotCase:(value?:string | null)=>string;
|
|
3733
|
-
/** ----------------------------------------------------------
|
|
3734
|
-
* * ***Slugifies a string for use in URLs.***
|
|
3735
|
-
* ----------------------------------------------------------
|
|
3736
|
-
*
|
|
3737
|
-
* @description
|
|
3738
|
-
* - Lowercases all letters.
|
|
3739
|
-
* - Joins words with `-`.
|
|
3740
|
-
* - Removes special characters and trims leading/trailing dashes.
|
|
3741
|
-
* - If input is `null` or `undefined`, returns "".
|
|
3742
|
-
*
|
|
3743
|
-
* @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
|
|
3744
|
-
* @returns {string} slug string
|
|
3745
|
-
*
|
|
3746
|
-
* @example
|
|
3747
|
-
* slugify("Hello World!") => "hello-world"
|
|
3748
|
-
* slugify(" --- Convert to Slug? --- ") => "convert-to-slug"
|
|
3749
|
-
*/
|
|
3750
|
-
declare const slugify:(value?:string | null)=>string;
|
|
3751
|
-
/** ----------------------------------------------------------
|
|
3752
|
-
* * ***Normalizes whitespace in a string by reducing multiple spaces
|
|
3753
|
-
* to a single space, optionally trims, or only trims based on options.***
|
|
3754
|
-
* ----------------------------------------------------------
|
|
3755
|
-
*
|
|
3756
|
-
* - ✅ Collapses all consecutive whitespace (spaces, tabs, newlines) into a single space.
|
|
3757
|
-
* - ✅ Can trim leading/trailing spaces (default behavior), or preserve them with `withTrim: false`.
|
|
3758
|
-
* - ✅ Can skip normalization entirely and only trim using `trimOnly: true`.
|
|
3759
|
-
* - ✅ Returns an empty string if input is `null` or `undefined`.
|
|
3760
|
-
*
|
|
3761
|
-
* @param {string} [value] - The input string to be processed. If `null` or `undefined`, returns an empty string.
|
|
3762
|
-
* @param {object} [options] - Configuration options.
|
|
3763
|
-
* @param {boolean} [options.trimOnly=false] - If `true`, skips normalization and only trims the string.
|
|
3764
|
-
* @param {boolean} [options.withTrim=true] - If `false`, preserves leading/trailing whitespace.
|
|
3765
|
-
*
|
|
3766
|
-
* @returns {string} The processed string.
|
|
3767
|
-
*
|
|
3768
|
-
* @example
|
|
3769
|
-
* normalizeSpaces(" Hello World\tthis is\n\nok ");
|
|
3770
|
-
* // "Hello World this is ok"
|
|
3771
|
-
*
|
|
3772
|
-
* normalizeSpaces(" Hello World\tthis is\n\nok ", { trimOnly: true });
|
|
3773
|
-
* // "Hello World this is\n\nok"
|
|
3774
|
-
*
|
|
3775
|
-
* normalizeSpaces(" Hello World ", { withTrim: false });
|
|
3776
|
-
* // " Hello World "
|
|
3777
|
-
*
|
|
3778
|
-
* normalizeSpaces(null);
|
|
3779
|
-
* // ""
|
|
3780
|
-
*/
|
|
3781
|
-
declare const normalizeSpaces:(value?:string | null,options?:{
|
|
3782
|
-
/**
|
|
3783
|
-
* If `true`, skips normalization and only trims whitespace from start & end.
|
|
3784
|
-
* @default false */
|
|
3785
|
-
trimOnly?:boolean;
|
|
3786
|
-
/**
|
|
3787
|
-
* If `false`, skips trimming value.
|
|
3788
|
-
* @default true */
|
|
3789
|
-
withTrim?:boolean;})=>string;
|
|
3790
|
-
/** ----------------------------------------------------------
|
|
3791
|
-
* * ***Normalizes a string by ensuring it is a valid string and trimming whitespace.***
|
|
3792
|
-
* ----------------------------------------------------------
|
|
3793
|
-
*
|
|
3794
|
-
* @description
|
|
3795
|
-
* If the input is `undefined`, `null`, or an `empty string` after trimming,
|
|
3796
|
-
* it returns an empty string `("")`.
|
|
3797
|
-
*
|
|
3798
|
-
* @param {string | undefined | null} input - The input string to be normalize. If `null` or `undefined`, returns an empty string.
|
|
3799
|
-
* @returns {string} A trimmed string or an empty string if the input is invalid.
|
|
3800
|
-
*
|
|
3801
|
-
* @example
|
|
3802
|
-
* normalizeString(" Hello World ");
|
|
3803
|
-
* // → "Hello World"
|
|
3804
|
-
*
|
|
3805
|
-
* normalizeString("");
|
|
3806
|
-
* // → ""
|
|
3807
|
-
*
|
|
3808
|
-
* normalizeString(null);
|
|
3809
|
-
* // → ""
|
|
3810
|
-
*
|
|
3811
|
-
* normalizeString(undefined);
|
|
3812
|
-
* // → ""
|
|
3813
|
-
*/
|
|
3814
|
-
declare const normalizeString:(input?:string | null)=>string;
|
|
3815
|
-
/** ----------------------------------------------------------
|
|
3816
|
-
* * ***Removes all spaces from a string or trims only, based on the options provided.***
|
|
3817
|
-
* ----------------------------------------------------------
|
|
3818
|
-
*
|
|
3819
|
-
* @description
|
|
3820
|
-
* - If `trimOnly` is `true`, the string is simply trimmed.
|
|
3821
|
-
* - Otherwise, removes **all spaces**, tabs, newlines, etc.
|
|
3822
|
-
* - If the input is `null` or `undefined`, returns an empty string `("")`.
|
|
3823
|
-
*
|
|
3824
|
-
* @param {string | null | undefined} value - The input string to be processed. If `null` or `undefined`, returns an empty string.
|
|
3825
|
-
* @param {object} [options] - The options object.
|
|
3826
|
-
* @param {boolean} [options.trimOnly=false] - If `true`, only trims the string without removing spaces inside.
|
|
3827
|
-
* @returns {string} The processed string.
|
|
3828
|
-
*
|
|
3829
|
-
* @example
|
|
3830
|
-
* removeSpaces(" Hello World ");
|
|
3831
|
-
* // → "HelloWorld"
|
|
3832
|
-
*
|
|
3833
|
-
* removeSpaces(" Hello World ", { trimOnly: true });
|
|
3834
|
-
* // → "Hello World"
|
|
3835
|
-
*
|
|
3836
|
-
* removeSpaces(null);
|
|
3837
|
-
* // → ""
|
|
3838
|
-
*/
|
|
3839
|
-
declare const removeSpaces:(value?:string | null,options?:{
|
|
3840
|
-
/**
|
|
3841
|
-
* @description If true, only trims the string.
|
|
3842
|
-
*
|
|
3843
|
-
* @default false */
|
|
3844
|
-
trimOnly?:boolean;})=>string;
|
|
3845
|
-
/** ----------------------------------------------------------
|
|
3846
|
-
* * ***Removes all HTML tags from a given string.***
|
|
3847
|
-
* ----------------------------------------------------------
|
|
3848
|
-
*
|
|
3849
|
-
* This function removes valid HTML tags (including nested and self-closing ones)
|
|
3850
|
-
* by replacing them with spaces, then collapses multiple whitespaces into a single space.
|
|
3851
|
-
*
|
|
3852
|
-
* It handles the following cases:
|
|
3853
|
-
* - If the input is not a string (`null`, `undefined`, or any non-string), it is returned as undefined.
|
|
3854
|
-
* - If the input is an empty or whitespace-only string, it returns an empty string (`""`).
|
|
3855
|
-
* - Otherwise, it returns the cleaned string with tags removed and normalized whitespace.
|
|
3856
|
-
*
|
|
3857
|
-
* @template T - Input string type (string | null | undefined).
|
|
3858
|
-
* @param {T} [input] - A string potentially containing HTML tags.
|
|
3859
|
-
* @returns {T extends string ? string : T} - Cleaned string if input is string, or original input otherwise.
|
|
3860
|
-
*
|
|
3861
|
-
* @example
|
|
3862
|
-
* stripHtmlTags("<p>Hello</p>"); // "Hello"
|
|
3863
|
-
* stripHtmlTags("<div><b>Bold</b> text</div>"); // "Bold text"
|
|
3864
|
-
* stripHtmlTags("Line<br/>Break"); // "Line Break"
|
|
3865
|
-
* stripHtmlTags("2 < 5 and 5 > 2"); // "2 < 5 and 5 > 2"
|
|
3866
|
-
* stripHtmlTags(""); // ""
|
|
3867
|
-
* stripHtmlTags(" "); // ""
|
|
3868
|
-
* stripHtmlTags(null); // undefined
|
|
3869
|
-
* stripHtmlTags(undefined); // undefined
|
|
3870
|
-
*/
|
|
3871
|
-
declare const stripHtmlTags:<T extends string | null | undefined=undefined>(input?:T)=>T extends string ? string:undefined;
|
|
3872
|
-
/** ----------------------------------------------------------
|
|
3873
|
-
* * ***Replaces a substring at a specified index within a string.***
|
|
3874
|
-
* ----------------------------------------------------------
|
|
3875
|
-
*
|
|
3876
|
-
* @description
|
|
3877
|
-
* Replaces exactly one character at the specified index in the original string
|
|
3878
|
-
* with the provided `replaceTo` string. If `replaceTo` has more than one character,
|
|
3879
|
-
* the result will expand accordingly.
|
|
3880
|
-
*
|
|
3881
|
-
* @param {number} index - The starting index where the replacement should occur.
|
|
3882
|
-
* @param {string} originalString - The original string to modify.
|
|
3883
|
-
* @param {string} replaceTo - The string to insert at the specified index.
|
|
3884
|
-
* @returns {string} - The modified string with the replacement applied.
|
|
3885
|
-
*
|
|
3886
|
-
* @example
|
|
3887
|
-
* replaceAt(3, "hello", "X");
|
|
3888
|
-
* // → "helXo"
|
|
3889
|
-
*
|
|
3890
|
-
* replaceAt(1, "world", "AB");
|
|
3891
|
-
* // → "wABrld"
|
|
3892
|
-
*
|
|
3893
|
-
* replaceAt(0, "cat", "br");
|
|
3894
|
-
* // → "brat"
|
|
3895
|
-
*
|
|
3896
|
-
* replaceAt(2, "12345", "-");
|
|
3897
|
-
* // → "12-45"
|
|
3898
|
-
*
|
|
3899
|
-
* replaceAt(4, "ABCDE", "Z");
|
|
3900
|
-
* // → "ABCDZ"
|
|
3901
|
-
*
|
|
3902
|
-
* // ❌ Examples that throw:
|
|
3903
|
-
* replaceAt(10, "short", "X");
|
|
3904
|
-
* // → ❌ RangeError: Index parameter is out of range at function `replaceAt`
|
|
3905
|
-
*
|
|
3906
|
-
* replaceAt(-1, "test", "X");
|
|
3907
|
-
* // → ❌ RangeError: Index parameter is out of range at function `replaceAt`
|
|
3908
|
-
*
|
|
3909
|
-
* replaceAt("1", "test", "X");
|
|
3910
|
-
* // → ❌ TypeError: Expected 'index' to be a number, and 'replaceTo' and 'originalString' to be strings
|
|
3911
|
-
*
|
|
3912
|
-
* replaceAt(2, null, "X");
|
|
3913
|
-
* // → ❌ TypeError: Expected 'index' to be a number, and 'replaceTo' and 'originalString' to be strings
|
|
3914
|
-
*/
|
|
3915
|
-
declare const replaceAt:(index:number,originalString:string,replaceTo:string)=>string;
|
|
3916
|
-
/** ----------------------------------------------------------
|
|
3917
|
-
* * ***Extracts initials from a given name.***
|
|
3918
|
-
* ----------------------------------------------------------
|
|
3919
|
-
*
|
|
3920
|
-
* @description
|
|
3921
|
-
* Extracts initials from the given name string.
|
|
3922
|
-
* - For names with two or more words, returns the first letter of the first and second words.
|
|
3923
|
-
* - For a single word with 2+ characters, returns the first two letters.
|
|
3924
|
-
* - For a single character, returns that character.
|
|
3925
|
-
* - For empty, null, or whitespace-only input, returns an empty string.
|
|
3926
|
-
*
|
|
3927
|
-
* @param {string} [name=""] - The name to extract initials from.
|
|
3928
|
-
* @returns {string} The extracted initials (e.g., "JD" for "John Doe").
|
|
3929
|
-
*
|
|
3930
|
-
* @example
|
|
3931
|
-
* getInitialsName("John Doe"); // "JD"
|
|
3932
|
-
* getInitialsName("Alice"); // "AL"
|
|
3933
|
-
* getInitialsName(" Bob Marley "); // "BM"
|
|
3934
|
-
* getInitialsName("John Ronald Donal"); // "JR"
|
|
3935
|
-
* getInitialsName("Lord John Doe Moe"); // "LJ"
|
|
3936
|
-
* getInitialsName("X"); // "X"
|
|
3937
|
-
* getInitialsName(" "); // "" (empty string)
|
|
3938
|
-
* getInitialsName(""); // "" (empty string)
|
|
3939
|
-
* getInitialsName(null); // "" (null input)
|
|
3940
|
-
* getInitialsName(undefined); // "" (undefined input)
|
|
3941
|
-
*/
|
|
3942
|
-
declare const getInitialsName:(name?:string | null)=>string;type UnionToIntersectionStrict<U>=(U extends never ? never:(arg:U)=>never)extends(arg:infer I)=>void ? I:never;type UnionToTupleStrict<T>=UnionToIntersectionStrict<T extends never ? never:(t:T)=>T>extends(_:never)=>infer W ? [...UnionToTupleStrict<Exclude<T,W>>,W]:[];
|
|
3943
|
-
/** ----------------------------------------------------------
|
|
3944
|
-
* * ***Creates a helper for styled-components `shouldForwardProp`.***
|
|
3945
|
-
* ----------------------------------------------------------
|
|
3946
|
-
*
|
|
3947
|
-
* @description
|
|
3948
|
-
* This utility returns a predicate function that determines
|
|
3949
|
-
* whether a given prop should be forwarded to the DOM.
|
|
3950
|
-
* Useful for filtering out internal props (e.g., `$size`, `$active`)
|
|
3951
|
-
* so they don't end up as invalid HTML attributes.
|
|
3952
|
-
*
|
|
3953
|
-
* - Accepts a tuple (strict) of prop keys to exclude from forwarding.
|
|
3954
|
-
* - Automatically coerces prop names to string for consistent checking.
|
|
3955
|
-
* - Supports string, number, or symbol keys (via PropertyKey).
|
|
3956
|
-
* - Will throw an error if the provided `props` argument is not an array.
|
|
3957
|
-
*
|
|
3958
|
-
* @template CustomProps - The type of the component's props.
|
|
3959
|
-
* @param {UnionToTupleStrict<keyof CustomProps>} props
|
|
3960
|
-
* The list of prop names (keys of `CustomProps`) to exclude from forwarding.
|
|
3961
|
-
*
|
|
3962
|
-
* @returns {(propName: PropertyKey) => boolean}
|
|
3963
|
-
* A function that takes a prop name and returns `true` if it should be forwarded, `false` if it should be blocked.
|
|
3964
|
-
*
|
|
3965
|
-
* @throws {Error} If `props` is not an array.
|
|
3966
|
-
*
|
|
3967
|
-
* @example
|
|
3968
|
-
* type Props = { $size: string; color: string; visible: boolean };
|
|
3969
|
-
* const filter = shouldForwardProp<Props>(["$size"]);
|
|
3970
|
-
* filter("$size"); // false (blocked)
|
|
3971
|
-
* filter("color"); // true (forwarded)
|
|
3972
|
-
*
|
|
3973
|
-
* @example
|
|
3974
|
-
* // Using with styled-components:
|
|
3975
|
-
* styled.div.withConfig({
|
|
3976
|
-
* shouldForwardProp: shouldForwardProp<CustomProps>(["$internal"])
|
|
3977
|
-
* })
|
|
3978
|
-
*/
|
|
3979
|
-
declare const shouldForwardProp:<CustomProps>(props:UnionToTupleStrict<keyof CustomProps>)=>(propName:PropertyKey)=>boolean;
|
|
3980
|
-
/** ---------------------------------
|
|
3981
|
-
* * ***Constructs a valid URL with optional query parameters and allows selective removal of duplicate parameters.***
|
|
3982
|
-
* ---------------------------------
|
|
3983
|
-
*
|
|
3984
|
-
*
|
|
3985
|
-
* @param {string | URL} baseUrl
|
|
3986
|
-
* The base URL to build upon. Must include protocol (e.g., "https://"),
|
|
3987
|
-
* domain, and may include port and existing query parameters.
|
|
3988
|
-
*
|
|
3989
|
-
* @param {Iterable<[string, string]>|URLSearchParamsIterator<[string, string]>} [queryParams]
|
|
3990
|
-
* Additional query parameters to append or overwrite on the URL.
|
|
3991
|
-
* Accepts any iterable of key-value pairs (like `new URLSearchParams().entries()`).
|
|
3992
|
-
*
|
|
3993
|
-
* @param {string[]} [removeParams]
|
|
3994
|
-
* A list of query parameter keys to remove from the final URL,
|
|
3995
|
-
* whether they were in the base URL or provided queryParams.
|
|
3996
|
-
*
|
|
3997
|
-
* @returns {URL}
|
|
3998
|
-
* A new URL object representing the constructed URL with merged
|
|
3999
|
-
* and cleaned query parameters.
|
|
4000
|
-
*
|
|
4001
|
-
* @throws {TypeError}
|
|
4002
|
-
* Throws if `baseUrl` is not a valid non-empty string or URL object,
|
|
4003
|
-
* or if `queryParams` is not iterable, or if `removeParams` is not an array of strings.
|
|
4004
|
-
*
|
|
4005
|
-
* @example
|
|
4006
|
-
* // Basic usage
|
|
4007
|
-
* constructURL("https://example.com/path", new URLSearchParams({ a: "1", b: "2" }).entries());
|
|
4008
|
-
* // => URL { href: "https://example.com/path?a=1&b=2", ... }
|
|
4009
|
-
*
|
|
4010
|
-
* @example
|
|
4011
|
-
* // Remove parameters from base and added
|
|
4012
|
-
* constructURL("https://example.com/path?foo=1&bar=2", new URLSearchParams({ bar: "ignored", baz: "3" }).entries(), ["bar"]);
|
|
4013
|
-
* // => URL { href: "https://example.com/path?foo=1&baz=3", ... }
|
|
4014
|
-
*/
|
|
4015
|
-
declare const constructURL:(baseUrl:string | URL,queryParams?:URLSearchParamsIterator<[string,string]>,removeParams?:string[])=>URL;
|
|
4016
|
-
/** --------------------------------------------------------
|
|
4017
|
-
* * ***Get Prefix from URL with Optional Base or Auto-detection (Supports String or Array of URLs).***
|
|
4018
|
-
* --------------------------------------------------------
|
|
4019
|
-
*
|
|
4020
|
-
* @description
|
|
4021
|
-
* This function extracts the prefix from one or more URLs. It can either:
|
|
4022
|
-
* - Use a provided `base` string or an array of strings to check and return the matching prefix.
|
|
4023
|
-
* - Automatically detect the prefix if no `base` is provided by analyzing the first part of the URL.
|
|
4024
|
-
*
|
|
4025
|
-
* The function is flexible and can handle both scenarios:
|
|
4026
|
-
* 1. **When the base is provided as a single string or an array of strings**: The function will check if the URL starts with one of the provided base(s) and return the matching base.
|
|
4027
|
-
* 2. **When the base is not provided**: The function will automatically detect the prefix by splitting the URL or using a regex.
|
|
4028
|
-
*
|
|
4029
|
-
* **Important Notes**:
|
|
4030
|
-
* - If a base (or an array of bases) is provided, the URL must start with one of the given base(s).
|
|
4031
|
-
* - If no base is provided, the function will attempt to detect the prefix automatically.
|
|
4032
|
-
* - The `url` parameter can be either a string or an array of strings.
|
|
4033
|
-
* - Supports deduplication of results (enabled by default).
|
|
4034
|
-
* - Automatically returns a single string if only one unique result exists after processing.
|
|
4035
|
-
*
|
|
4036
|
-
* ---
|
|
4037
|
-
*
|
|
4038
|
-
* @param {string|string[]} url The full URL(s) from which the prefix should be extracted. Can be a string or an array of strings.
|
|
4039
|
-
* @param {string|string[]|null} [base=null] The base URL(s) (e.g., "/settings"). It can be a string, an array of strings, or `null`. If provided, it will be used to check the URL(s). If not provided, the prefix will be auto-detected.
|
|
4040
|
-
* @param {{ levels?: number; removeDuplicates?: boolean }} [options] Additional options object:
|
|
4041
|
-
* - `levels` (default `1`): The number of segments to include when auto-detecting the prefix (e.g. `/foo/bar` for `levels: 2`).
|
|
4042
|
-
* - `removeDuplicates` (default `true`): Whether to remove duplicate prefixes from the final array result.
|
|
4043
|
-
*
|
|
4044
|
-
* @returns {string|string[]|null}
|
|
4045
|
-
* Returns one of:
|
|
4046
|
-
* - A single string if only one unique prefix/base is found.
|
|
4047
|
-
* - An array of strings if multiple different prefixes/bases are found.
|
|
4048
|
-
* - `null` if no matching base is found when using `base`.
|
|
4049
|
-
*
|
|
4050
|
-
* ---
|
|
4051
|
-
*
|
|
4052
|
-
* @throws {TypeError}
|
|
4053
|
-
* Throws if:
|
|
4054
|
-
* - `url` is not a string or an array of strings.
|
|
4055
|
-
* - `base` is not a string, array of strings, or `null`.
|
|
4056
|
-
* - `options` is not an object.
|
|
4057
|
-
* - `levels` is not a number.
|
|
4058
|
-
* - `removeDuplicates` is not a boolean.
|
|
4059
|
-
*
|
|
4060
|
-
* ---
|
|
4061
|
-
*
|
|
4062
|
-
* ### **🔹 Usage Examples**
|
|
4063
|
-
*
|
|
4064
|
-
* #### ✅ **Correct Usage (With an Array of URLs and Base)**
|
|
4065
|
-
* ```ts
|
|
4066
|
-
* const routes = [
|
|
4067
|
-
* "/settings/profile",
|
|
4068
|
-
* "/settings/password",
|
|
4069
|
-
* "/settings/other-path",
|
|
4070
|
-
* "/other-path/xyz",
|
|
4071
|
-
* ];
|
|
4072
|
-
*
|
|
4073
|
-
* // With base provided as a string
|
|
4074
|
-
* routes.forEach(route => {
|
|
4075
|
-
* console.log(getPrefixPathname(route, '/settings')); // Output: "/settings"
|
|
4076
|
-
* });
|
|
4077
|
-
*
|
|
4078
|
-
* // With base provided as an array
|
|
4079
|
-
* routes.forEach(route => {
|
|
4080
|
-
* console.log(getPrefixPathname(route, ['/settings', '/admin'])); // Output: "/settings" or "/admin" depending on the URL
|
|
4081
|
-
* });
|
|
4082
|
-
* ```
|
|
4083
|
-
*
|
|
4084
|
-
* #### ✅ **Correct Usage (With Single URL and Single Base)**
|
|
4085
|
-
* ```ts
|
|
4086
|
-
* const result = getPrefixPathname("/settings/profile", "/settings");
|
|
4087
|
-
* console.log(result); // Output: "/settings"
|
|
4088
|
-
* ```
|
|
4089
|
-
*
|
|
4090
|
-
* #### ✅ **Correct Usage (With Multiple URLs and Single Base)**
|
|
4091
|
-
* ```ts
|
|
4092
|
-
* const result = getPrefixPathname(["/settings/profile", "/settings/password"], "/settings");
|
|
4093
|
-
* console.log(result); // Output: "/settings"
|
|
4094
|
-
* ```
|
|
4095
|
-
*
|
|
4096
|
-
* #### ✅ **Correct Usage (With Multiple URLs and Multiple Bases)**
|
|
4097
|
-
* ```ts
|
|
4098
|
-
* const result = getPrefixPathname(["/settings/profile", "/admin/password"], ["/settings", "/admin"]);
|
|
4099
|
-
* console.log(result); // Output: ["/settings", "/admin"]
|
|
4100
|
-
* ```
|
|
4101
|
-
*
|
|
4102
|
-
* #### ✅ **Auto-detection of Prefix**
|
|
4103
|
-
* ```ts
|
|
4104
|
-
* const result = getPrefixPathname("/settings/profile");
|
|
4105
|
-
* console.log(result); // Output: "/settings"
|
|
4106
|
-
*
|
|
4107
|
-
* const result2 = getPrefixPathname("/settings/profile/info", null, { levels: 2 });
|
|
4108
|
-
* console.log(result2); // Output: "/settings/profile"
|
|
4109
|
-
* ```
|
|
4110
|
-
*
|
|
4111
|
-
* #### ✅ **Multiple URLs with Auto-detection**
|
|
4112
|
-
* ```ts
|
|
4113
|
-
* const result = getPrefixPathname(["/admin/profile", "/settings/password"]);
|
|
4114
|
-
* console.log(result); // Output: ["/admin", "/settings"]
|
|
4115
|
-
* ```
|
|
4116
|
-
*
|
|
4117
|
-
* #### ✅ **Handling Duplicates**
|
|
4118
|
-
* ```ts
|
|
4119
|
-
* const result = getPrefixPathname(["/settings/profile", "/settings/password"], "/settings");
|
|
4120
|
-
* console.log(result); // Output: "/settings" (deduped to single string)
|
|
4121
|
-
*
|
|
4122
|
-
* const result2 = getPrefixPathname(["/settings/profile", "/settings/profile"], "/settings", { removeDuplicates: false });
|
|
4123
|
-
* console.log(result2); // Output: ["/settings", "/settings"]
|
|
4124
|
-
* ```
|
|
4125
|
-
*
|
|
4126
|
-
* #### ❌ **Incorrect Usage (URL Does Not Match Base)**
|
|
4127
|
-
* ```ts
|
|
4128
|
-
* const result = getPrefixPathname("/other-path/profile", "/settings");
|
|
4129
|
-
* console.log(result); // Output: null
|
|
4130
|
-
* ```
|
|
4131
|
-
*
|
|
4132
|
-
* ---
|
|
4133
|
-
*/
|
|
4134
|
-
declare const getPrefixPathname:(url:string | string[],base?:string | string[] | null,options?:{
|
|
4135
|
-
/** The number of levels to include in the prefix (default is 1). For example, with `levels = 2`, the function will return the first two parts of the URL. */
|
|
4136
|
-
levels?:number;
|
|
4137
|
-
/** Whether to remove duplicates from the result if multiple URLs are passed (default is `true`). */
|
|
4138
|
-
removeDuplicates?:boolean;})=>string | string[] | null;
|
|
4139
|
-
/** --------------------------------------------------------
|
|
4140
|
-
* * ***Extract First Valid Prefix from Path Array or String.***
|
|
4141
|
-
* --------------------------------------------------------
|
|
4142
|
-
*
|
|
4143
|
-
* ### 🚀 **Main Purpose:**
|
|
4144
|
-
* This function helps extract the first valid URL prefix from various possible inputs.
|
|
4145
|
-
* It is especially useful in routing systems, middleware, or frontend apps that
|
|
4146
|
-
* need to decide layout, active navigation, or permissions based on the first
|
|
4147
|
-
* segment (or prefix) of a pathname.
|
|
4148
|
-
*
|
|
4149
|
-
* Typical uses include:
|
|
4150
|
-
* - Determining which layout to render (e.g., `/admin` vs `/dashboard` vs `/`).
|
|
4151
|
-
* - Highlighting the active menu item in a sidebar based on the current URL.
|
|
4152
|
-
* - Enforcing route guards or access controls depending on the URL prefix.
|
|
4153
|
-
* - Parsing multi-level route prefixes and selecting the most relevant one.
|
|
4154
|
-
*
|
|
4155
|
-
* ---
|
|
4156
|
-
*
|
|
4157
|
-
* ### 🔍 Behavior:
|
|
4158
|
-
* It works as follows:
|
|
4159
|
-
* - If `result` is an array of strings, it normalizes each element and returns
|
|
4160
|
-
* the first non-root path (i.e., not just `"/"`). If all items normalize to `"/"`,
|
|
4161
|
-
* it returns the `defaultValue` (normalized).
|
|
4162
|
-
* - If `result` is a single string, it normalizes it and returns it if valid,
|
|
4163
|
-
* otherwise falls back to the normalized `defaultValue`.
|
|
4164
|
-
* - If `result` is `null` or `undefined`, it returns the normalized `defaultValue`.
|
|
4165
|
-
*
|
|
4166
|
-
* ---
|
|
4167
|
-
*
|
|
4168
|
-
* ### 🔍 Validation & Errors:
|
|
4169
|
-
*
|
|
4170
|
-
* - Throws a `TypeError` if:
|
|
4171
|
-
* - `defaultValue` is not a non-empty string.
|
|
4172
|
-
* - `result` is an array that contains non-string elements.
|
|
4173
|
-
* - `result` is a value that is neither `string`, `string[]`, nor `null`.
|
|
4174
|
-
*
|
|
4175
|
-
* ---
|
|
4176
|
-
*
|
|
4177
|
-
* ### 🛠 Usage Examples:
|
|
4178
|
-
*
|
|
4179
|
-
* 1. #### For React: *Determining layout*
|
|
4180
|
-
* ```ts
|
|
4181
|
-
* const prefix = getFirstPrefixPathname(getPrefixPathname("/admin/settings", ["/admin", "/dashboard"]));
|
|
4182
|
-
* if (prefix === "/admin") {
|
|
4183
|
-
* renderAdminLayout();
|
|
4184
|
-
* }
|
|
4185
|
-
* ```
|
|
4186
|
-
*
|
|
4187
|
-
* 2. #### Setting active menu state
|
|
4188
|
-
* ```ts
|
|
4189
|
-
* const activeSection = getFirstPrefixPathname(["", "/dashboard", "/profile"]);
|
|
4190
|
-
* // => "/dashboard"
|
|
4191
|
-
* ```
|
|
4192
|
-
*
|
|
4193
|
-
* 3. #### Providing graceful fallback
|
|
4194
|
-
* ```ts
|
|
4195
|
-
* const section = getFirstPrefixPathname([], "/home");
|
|
4196
|
-
* // => "/home"
|
|
4197
|
-
* ```
|
|
4198
|
-
* 4. #### ✅ Using with an Array of Pathnames
|
|
4199
|
-
* ```ts
|
|
4200
|
-
* const result = getPrefixPathname([" ", "/dashboard", "/settings"]);
|
|
4201
|
-
* console.log(getFirstPrefixPathname(result)); // => "/dashboard"
|
|
4202
|
-
* ```
|
|
4203
|
-
*
|
|
4204
|
-
* 5. #### ✅ Using with Single String:
|
|
4205
|
-
* ```ts
|
|
4206
|
-
* console.log(getFirstPrefixPathname("/profile/settings")); // => "/profile/settings"
|
|
4207
|
-
* console.log(getFirstPrefixPathname(" ")); // => "/"
|
|
4208
|
-
* ```
|
|
4209
|
-
*
|
|
4210
|
-
* 6. #### ✅ Fallback to Custom Default:
|
|
4211
|
-
* ```ts
|
|
4212
|
-
* console.log(getFirstPrefixPathname([" ", ""], "/home")); // => "/home"
|
|
4213
|
-
* console.log(getFirstPrefixPathname(null, "/dashboard")); // => "/dashboard"
|
|
4214
|
-
* ```
|
|
4215
|
-
*
|
|
4216
|
-
* 7. #### ✅ Throws on Invalid Input:
|
|
4217
|
-
* ```ts
|
|
4218
|
-
* getFirstPrefixPathname([1, 2] as any); // ❌ throws TypeError
|
|
4219
|
-
* getFirstPrefixPathname({} as any); // ❌ throws TypeError
|
|
4220
|
-
* getFirstPrefixPathname(null, " "); // ❌ throws TypeError
|
|
4221
|
-
* ```
|
|
4222
|
-
*
|
|
4223
|
-
* ---
|
|
4224
|
-
*
|
|
4225
|
-
* @param {string | string[] | null} result
|
|
4226
|
-
* The pathname(s) to process. Can be:
|
|
4227
|
-
* - A string path (e.g. `"/profile"`),
|
|
4228
|
-
* - An array of string paths (e.g. `[" ", "/dashboard"]`),
|
|
4229
|
-
* - Or `null`.
|
|
4230
|
-
*
|
|
4231
|
-
* @param {string} [defaultValue="/"]
|
|
4232
|
-
* A custom default path to use if `result` is null or no valid prefix is found.
|
|
4233
|
-
* Must be a non-empty string. Defaults to `"/"`.
|
|
4234
|
-
*
|
|
4235
|
-
* @returns {string}
|
|
4236
|
-
* The first valid normalized pathname, or the normalized default.
|
|
4237
|
-
*
|
|
4238
|
-
* @throws {TypeError}
|
|
4239
|
-
* If `result` is not a valid type, or `defaultValue` is not a non-empty string.
|
|
4240
|
-
*/
|
|
4241
|
-
declare const getFirstPrefixPathname:(result?:string | string[] | null,defaultValue?:string)=>string;
|
|
4242
|
-
/** --------------------------------------------------------
|
|
4243
|
-
* * ***Normalizes a given pathname by ensuring consistent formatting.***
|
|
4244
|
-
* --------------------------------------------------------
|
|
4245
|
-
*
|
|
4246
|
-
* @description
|
|
4247
|
-
* This function processes and normalizes a given pathname:
|
|
4248
|
-
*
|
|
4249
|
-
* - If `pathname` is `null`, `undefined`, empty, or only whitespace,
|
|
4250
|
-
* the `defaultPath` will be returned instead.
|
|
4251
|
-
*
|
|
4252
|
-
* - If `pathname` is a full URL (starting with `http://` or `https://`),
|
|
4253
|
-
* it extracts and returns the pathname along with any search parameters and hash.
|
|
4254
|
-
* Example: `"https://site.com/foo/bar?x=1#sec"` becomes `"/foo/bar?x=1#sec"`.
|
|
4255
|
-
*
|
|
4256
|
-
* - All spaces inside the pathname are removed.
|
|
4257
|
-
*
|
|
4258
|
-
* - Multiple consecutive slashes (like `"//"` or `"///"`) are collapsed into a single slash `"/"`.
|
|
4259
|
-
*
|
|
4260
|
-
* - Ensures the returned string always starts with exactly one `/`.
|
|
4261
|
-
*
|
|
4262
|
-
* @param {string | null | undefined} pathname - The pathname to normalize.
|
|
4263
|
-
* @param {string} [defaultPath="/"] - A fallback value returned if `pathname` is empty or invalid. Must be a non-empty string, default `"/"`.
|
|
4264
|
-
*
|
|
4265
|
-
* @returns {string} A properly normalized pathname starting with a single `/`,
|
|
4266
|
-
* or the `defaultPath` if the input is invalid or empty.
|
|
4267
|
-
*
|
|
4268
|
-
* @throws {TypeError} If `defaultPath` is not a non-empty string.
|
|
4269
|
-
* @throws {NormalizePathnameError} If an unexpected error occurs during normalization (e.g., URL parsing failure).
|
|
4270
|
-
*
|
|
4271
|
-
* @example
|
|
4272
|
-
* normalizePathname(" /foo//bar "); // => "/foo/bar"
|
|
4273
|
-
*
|
|
4274
|
-
* normalizePathname("https://example.com//path///to/resource?x=1#hash");
|
|
4275
|
-
* // => "/path/to/resource?x=1#hash"
|
|
4276
|
-
*
|
|
4277
|
-
* normalizePathname(" "); // => "/"
|
|
4278
|
-
* normalizePathname(null, "/home"); // => "/home"
|
|
4279
|
-
* normalizePathname("/double//slashes"); // => "/double/slashes"
|
|
4280
|
-
*
|
|
4281
|
-
* normalizePathname(" nested / path / 🚀 "); // => "/nested/path/🚀"
|
|
4282
|
-
*/
|
|
4283
|
-
declare const normalizePathname:(pathname?:string | null,defaultPath?:string)=>string;
|
|
4284
|
-
/** -----------------------------------------------
|
|
4285
|
-
* * ***Retrieves and formats an environment port variable.***
|
|
4286
|
-
* -----------------------------------------------
|
|
4287
|
-
*
|
|
4288
|
-
* - Extracts only digits from the input.
|
|
4289
|
-
* - If no digits found, returns an empty string.
|
|
4290
|
-
* - By default does NOT prefix with a colon.
|
|
4291
|
-
* Use `{ prefixColon: true }` to prefix with a colon.
|
|
4292
|
-
*
|
|
4293
|
-
* @param envVar The environment variable string.
|
|
4294
|
-
* @param options Optional object: `{ prefixColon?: boolean }`.
|
|
4295
|
-
* @returns A string like ":8080" or "8080", or "" if no digits.
|
|
4296
|
-
*
|
|
4297
|
-
* @throws TypeError if `options` is not an object or `prefixColon` is not boolean.
|
|
4298
|
-
*
|
|
4299
|
-
* @example
|
|
4300
|
-
* formatEnvPort("port:8080"); // "8080"
|
|
4301
|
-
* formatEnvPort("port:8080", { prefixColon: true }); // ":8080"
|
|
4302
|
-
*/
|
|
4303
|
-
declare const formatEnvPort:(envVar?:string | null,options?:{
|
|
4304
|
-
/** Add prefix with a colon.
|
|
4305
|
-
*
|
|
4306
|
-
* @default false
|
|
4307
|
-
*/
|
|
4308
|
-
prefixColon?:boolean;})=>string;
|
|
4309
|
-
/** ---------------------------------
|
|
4310
|
-
* * ***Custom Error for Pathname Normalization Failures***
|
|
4311
|
-
* ---------------------------------
|
|
4312
|
-
*/
|
|
4313
|
-
declare class NormalizePathnameError extends Error{originalError:Error;constructor(message:string,originalError:Error);}export{NormalizePathnameError,areObjectsEqual,areURLsEqualPath,areURLsIdentical,arrayHasAnyMatch,assertIsString,capitalizeFirst,capitalizeWords,censorEmail,chunkString,cleanParsedData,constructURL,convertType,dedupeArray,delay,disableUserInteraction,doesKeyExist,enableUserInteraction,extractDigits,extractFileName,extractURLs,filterNullArray,findDuplicates,formatCurrency,formatDateFns,formatDateIntl,formatDateTime,formatEnvPort,formatNumber,formatPhoneNumber,getFirstPrefixPathname,getGMTOffset,getInitialsName,getPrefixPathname,getRandomItem,isArguments,isArray,isArrayBuffer,isArrayLike,isArrayLikeObject,isBigInt,isBoolean,isBuffer,isCurrencyLike,isDate,isDeepEqual,isElement,isEmpty,isEmptyArray,isEmptyDeep,isEmptyString,isEmptyValue,isEqual,isEqualWith,isError,isFinite$1 as isFinite,isFunction,isInteger,isLength,isMatch,isMatchWith,isNaN$1 as isNaN,isNative,isNil,isNonEmptyArray,isNonEmptyString,isNull,isNumber,isObject,isObjectLoose,isObjectOrArray,isPlainObject,isRegExp,isSafeInteger,isServer,isSet,isString,isSymbol,isTypedArray,isURL,isUndefined,isValidURL,isWeakMap,noop,normalizePathname,normalizeSpaces,normalizeString,omitKeys,omitKeysDeep,omitProps,parseCurrencyString,parseCustomDate,randomInt,randomIntByLength,randomStr,removeElementFocus,removeObjectPaths,removeSpaces,replaceAt,safeJsonParse,safeStableStringify,scrollToTop,shouldForwardProp,slugify,stripHtmlTags,textContainsAll,textContainsAny,toBooleanContent,toBooleanContentDeep,toBooleanExplicit,toBooleanLoose,toCamelCase,toDotCase,toKebabCase,toNumberArrayUnRecursive,toNumberDeep,toPascalCase,toSnakeCase,toStringArrayUnRecursive,toStringDeep,toStringDeepForce,truncateString};export type{IsObjectOrArray};
|
|
1
|
+
export{assertIsArray,assertIsBigInt,assertIsBoolean,assertIsNumber,assertIsPlainObject,assertIsString}from'./assertions/index.js';export{cleanParsedData,convertType,dedupeArray,extractDigits,filterNilArray,filterNullArray,parseCurrencyString,parseCustomDate,removeObjectPaths,safeJsonParse,safeStableStringify,toBooleanContent,toBooleanContentDeep,toBooleanExplicit,toBooleanLoose,toNumberArrayUnRecursive,toNumberDeep,toStringArrayUnRecursive,toStringDeep,toStringDeepForce}from'./conversions/index.js';export{isServer}from'./env/index.js';export{disableUserInteraction,enableUserInteraction,removeElementFocus,scrollToTop}from'./events/index.js';export{censorEmail,chunkString,formatCurrency,formatDateFns,formatDateIntl,formatDateTime,formatNumber,formatPhoneNumber,getGMTOffset,truncateString}from'./formatting/index.js';export{getRandomItem,noop,randomInt,randomIntByLength,randomStr}from'./generator/index.js';export{findDuplicates,omitKeys,omitKeysDeep,omitProps}from'./operations/index.js';export{extractFileName}from'./parsers/index.js';export{IsArrayResult,areArraysEqual,areObjectsEqual,areURLsEqualPath,areURLsIdentical,arrayHasAnyMatch,doesKeyExist,hasOwnProp,isArguments,isArray,isArrayBuffer,isArrayLike,isArrayLikeObject,isBigInt,isBoolean,isBuffer,isCurrencyLike,isDate,isDeepEqual,isElement,isEmpty,isEmptyArray,isEmptyDeep,isEmptyObject,isEmptyString,isEmptyValue,isEqual,isEqualWith,isError,isFinite,isFunction,isInteger,isLength,isMap,isMatch,isMatchWith,isNaN,isNative,isNil,isNonEmptyArray,isNonEmptyString,isNonEmptyValue,isNull,isObject,isObjectLoose,isObjectOrArray,isRegExp,isSafeInteger,isSet,isString,isSymbol,isTypedArray,isURL,isUndefined,isValidURL,isWeakMap,textContainsAll,textContainsAny}from'./predicates/index.js';export{G as GetPreciseTypeOptions,I as IsNumberOptions,a as IsPlainObjectResult,g as getPreciseType,i as isNumber,b as isPlainObject}from'./isPlainObject-BKYaI6a8.js';export{delay}from'./promise/index.js';export{capitalizeFirst,capitalizeWords,getInitialsName,normalizeSpaces,normalizeString,removeSpaces,replaceAt,slugify,stripHtmlTags,toCamelCase,toDotCase,toKebabCase,toLowerCase,toPascalCase,toPascalCaseSpace,toSnakeCase}from'./strings/index.js';export{shouldForwardProp}from'./stylings/index.js';export{QueryParamPairs,constructURL,extractURLs,formatEnvPort,getFirstPrefixPathname,getPrefixPathname,normalizePathname}from'./urls/index.js';import'./type-data-DDs-u2kq.js';import'./arrays-normalize-recursive-CnjYJ9xg.js';import'./nils-DMz3kU7M.js';import'./any-BmdI8UbK.js';import'./if-CvT4R7Kh.js';import'./extends-Mp81Hq9-.js';import'./array-CIZRbqTF.js';import'./never-BfayMBF9.js';import'./prettify-C4xLcYOP.js';import'./NumberRangeUnion-DC-C3_Kq.js';import'./omit-VvmIsZmX.js';import'date-fns/locale';import'date-fns';import'./is-array-Ckm_47hw.js';
|