@rzl-zone/utils-js 2.1.0 → 3.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +26 -0
  2. package/dist/any-BmdI8UbK.d.ts +67 -0
  3. package/dist/array-CIZRbqTF.d.ts +223 -0
  4. package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +72 -0
  5. package/dist/assertions/index.cjs +1 -0
  6. package/dist/assertions/index.d.ts +428 -0
  7. package/dist/assertions/index.js +1 -0
  8. package/dist/chunk-2TRAPBZ7.cjs +1 -0
  9. package/dist/chunk-4DK3RCC4.js +2 -0
  10. package/dist/chunk-4JOQ45HL.js +1 -0
  11. package/dist/chunk-55CZALRS.js +1 -0
  12. package/dist/chunk-56QBKKRE.js +1 -0
  13. package/dist/chunk-5SZUSNGZ.js +1 -0
  14. package/dist/chunk-62HX5Z45.cjs +1 -0
  15. package/dist/chunk-7NA6DUHR.cjs +2 -0
  16. package/dist/chunk-7YWAQOA4.cjs +1 -0
  17. package/dist/chunk-BVPMMWDL.cjs +1 -0
  18. package/dist/chunk-BYZAD3XN.cjs +1 -0
  19. package/dist/chunk-CEFYHEM4.cjs +1 -0
  20. package/dist/chunk-CN53M4QZ.cjs +1 -0
  21. package/dist/chunk-D47MHBSD.cjs +1 -0
  22. package/dist/chunk-DGH75GJD.js +1 -0
  23. package/dist/chunk-E5NUI7PN.js +1 -0
  24. package/dist/chunk-ELDDNERR.js +1 -0
  25. package/dist/chunk-EXZ47NOW.js +1 -0
  26. package/dist/chunk-FDITZ5C6.cjs +1 -0
  27. package/dist/chunk-FF76ISQ2.js +1 -0
  28. package/dist/chunk-FIEZKTAZ.cjs +1 -0
  29. package/dist/chunk-FSSV24W7.cjs +1 -0
  30. package/dist/chunk-G5LXIEFO.js +0 -0
  31. package/dist/chunk-GCGU2WB7.js +1 -0
  32. package/dist/chunk-GECI2YBP.js +1 -0
  33. package/dist/chunk-GQE4OVHC.cjs +1 -0
  34. package/dist/chunk-GRVZXQXL.cjs +1 -0
  35. package/dist/chunk-I4AVNHPA.cjs +1 -0
  36. package/dist/chunk-JWHM3WZQ.cjs +1 -0
  37. package/dist/chunk-KBKYG3IY.cjs +1 -0
  38. package/dist/chunk-KCQDDZJE.cjs +1 -0
  39. package/dist/chunk-LVKAYEZ4.js +1 -0
  40. package/dist/chunk-MBDWTK54.cjs +1 -0
  41. package/dist/chunk-MMSYCIJ2.cjs +1 -0
  42. package/dist/chunk-MNGGDB2G.js +1 -0
  43. package/dist/chunk-MY7BA4GI.cjs +1 -0
  44. package/dist/chunk-N2IJPIND.cjs +1 -0
  45. package/dist/chunk-NIMNTEGV.js +1 -0
  46. package/dist/chunk-NNM7QCNB.js +1 -0
  47. package/dist/chunk-POCPQYZS.js +1 -0
  48. package/dist/chunk-PUQXRLZH.cjs +1 -0
  49. package/dist/chunk-PVJF2JHM.js +1 -0
  50. package/dist/chunk-QCFXEUKL.js +1 -0
  51. package/dist/chunk-QFCGBBSY.js +1 -0
  52. package/dist/chunk-QQYAUPSK.cjs +1 -0
  53. package/dist/chunk-RN3TP3S3.js +1 -0
  54. package/dist/chunk-RV2VULM7.cjs +1 -0
  55. package/dist/chunk-SW6HYEW7.cjs +1 -0
  56. package/dist/chunk-SYJC7UAW.js +1 -0
  57. package/dist/chunk-TC4VBE4Y.cjs +1 -0
  58. package/dist/chunk-TUXDINHF.cjs +1 -0
  59. package/dist/chunk-U5Y2FXMN.cjs +1 -0
  60. package/dist/chunk-UUPQI6ND.cjs +1 -0
  61. package/dist/chunk-VYCGZ2S6.js +1 -0
  62. package/dist/chunk-W5EDKJK3.js +1 -0
  63. package/dist/chunk-WHAVUFEU.js +1 -0
  64. package/dist/chunk-X3GTRVVK.cjs +4 -0
  65. package/dist/chunk-XCFIOTCV.js +1 -0
  66. package/dist/chunk-XE27XPJR.js +1 -0
  67. package/dist/chunk-XH6MCRLP.js +1 -0
  68. package/dist/chunk-XVB3ZZEB.js +1 -0
  69. package/dist/chunk-YEERJDOF.js +4 -0
  70. package/dist/chunk-ZBSIGJFO.cjs +1 -0
  71. package/dist/chunk-ZYAML74V.js +1 -0
  72. package/dist/conversions/index.cjs +1 -0
  73. package/dist/conversions/index.d.ts +1633 -0
  74. package/dist/conversions/index.js +1 -0
  75. package/dist/env/index.cjs +1 -0
  76. package/dist/env/index.d.ts +19 -0
  77. package/dist/env/index.js +1 -0
  78. package/dist/events/index.cjs +1 -0
  79. package/dist/events/index.d.ts +119 -0
  80. package/dist/events/index.js +1 -0
  81. package/dist/extends-Mp81Hq9-.d.ts +145 -0
  82. package/dist/formatting/index.cjs +1 -0
  83. package/dist/formatting/index.d.ts +912 -0
  84. package/dist/formatting/index.js +1 -0
  85. package/dist/generator/index.cjs +1 -0
  86. package/dist/generator/index.d.ts +163 -0
  87. package/dist/generator/index.js +1 -0
  88. package/dist/if-CvT4R7Kh.d.ts +18 -0
  89. package/dist/index.cjs +1 -1
  90. package/dist/index.d.ts +1 -4334
  91. package/dist/index.js +1 -1
  92. package/dist/is-array-Ckm_47hw.d.ts +1557 -0
  93. package/dist/isPlainObject-BKYaI6a8.d.ts +182 -0
  94. package/dist/never-BfayMBF9.d.ts +75 -0
  95. package/dist/next/index.cjs +8 -1
  96. package/dist/next/index.d.ts +169 -169
  97. package/dist/next/index.js +8 -1
  98. package/dist/next/server/index.cjs +2 -1
  99. package/dist/next/server/index.d.ts +37 -37
  100. package/dist/next/server/index.js +2 -1
  101. package/dist/nils-DMz3kU7M.d.ts +177 -0
  102. package/dist/omit-VvmIsZmX.d.ts +28 -0
  103. package/dist/operations/index.cjs +1 -0
  104. package/dist/operations/index.d.ts +182 -0
  105. package/dist/operations/index.js +1 -0
  106. package/dist/parsers/index.cjs +1 -0
  107. package/dist/parsers/index.d.ts +37 -0
  108. package/dist/parsers/index.js +1 -0
  109. package/dist/predicates/index.cjs +1 -0
  110. package/dist/predicates/index.d.ts +1839 -0
  111. package/dist/predicates/index.js +1 -0
  112. package/dist/prettify-C4xLcYOP.d.ts +353 -0
  113. package/dist/promise/index.cjs +1 -0
  114. package/dist/promise/index.d.ts +40 -0
  115. package/dist/promise/index.js +1 -0
  116. package/dist/rzl-utils.global.js +4 -1
  117. package/dist/strings/index.cjs +1 -0
  118. package/dist/strings/index.d.ts +816 -0
  119. package/dist/strings/index.js +1 -0
  120. package/dist/stylings/index.cjs +1 -0
  121. package/dist/stylings/index.d.ts +49 -0
  122. package/dist/stylings/index.js +1 -0
  123. package/dist/type-data-DDs-u2kq.d.ts +261 -0
  124. package/dist/types/index.d.ts +3589 -2090
  125. package/dist/urls/index.cjs +1 -0
  126. package/dist/urls/index.d.ts +416 -0
  127. package/dist/urls/index.js +1 -0
  128. package/package.json +147 -21
package/dist/index.d.ts CHANGED
@@ -1,4334 +1 @@
1
- import{FormatOptions}from 'date-fns';import{Locale}from 'date-fns/locale';type If<Condition,IfTrue=true,IfFalse=false>=Condition extends true ? IfTrue:IfFalse;type Not<T extends boolean>=T extends true ? false:true;type Extends<T,Base>=[T] extends [Base] ? true:false;type NotExtends<T,Base>=Not<Extends<T,Base>>;type IfExtends<T,Base,IfTrue=true,IfFalse=false>=If<Extends<T,Base>,IfTrue,IfFalse>;type IfNotExtends<T,Base,IfTrue=true,IfFalse=false>=If<NotExtends<T,Base>,IfTrue,IfFalse>;type IsAny<T>=0 extends 1 & T ? true:false;type PrettifyOptions={recursive:boolean;};type Prettify<T,Options extends PrettifyOptions={recursive:false;}>=T extends infer R ?{[K in keyof R]:If<Options["recursive"],Prettify<R[K],Options>,R[K]>;}:never;type OmitStrict<T,K extends keyof T,WithPrettify extends boolean=true,WithPrettifyRecursive extends boolean=true>=WithPrettify extends true ? Prettify<Omit<T,K>,{recursive:WithPrettifyRecursive;}>:WithPrettify extends false ? Omit<T,K>:never;type AnyFunction=(...args:any[])=>any;type TypedArray=Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;type WebApiObjects=URL | URLSearchParams | FormData | Headers | Response | Request | ReadableStream<any>| WritableStream<any>| TransformStream<any,any>| MessageChannel | MessagePort | MessageEvent | Event | CustomEvent | HTMLElement | Node | Document | Window | AbortController | AbortSignal | TextEncoder | TextDecoder | CryptoKey | File | FileList | ImageBitmap | CanvasRenderingContext2D | WebSocket;type IntlObjects=Intl.Collator | Intl.DateTimeFormat | Intl.NumberFormat | Intl.RelativeTimeFormat | Intl.PluralRules | Intl.ListFormat | Intl.Locale;type NodeBuiltins=Buffer;type NonPlainObject=AnyFunction | Array<any>| Date | RegExp | Map<any,any>| Set<any>| WeakMap<any,any>| WeakSet<any>| Error | Promise<any>| ArrayBuffer | DataView | TypedArray | WebApiObjects | IntlObjects | NodeBuiltins | symbol |{[Symbol.toStringTag]:"Proxy";}| typeof Reflect;type Enumerate<N extends number,Acc extends number[]=[]>=Acc["length"] extends N ? Acc[number]:Enumerate<N,[...Acc,Acc["length"]]>;type RangeNumberTo999<From extends number,To extends number>=From extends To ? From:Exclude<Enumerate<To>,Enumerate<From>>extends never ? never:Exclude<Enumerate<To>,Enumerate<From>>| To;
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;
2993
- /** ----------------------------------------------------
2994
- * * ***Get the precise JavaScript type of any value.***
2995
- * ----------------------------------------------------
2996
- *
2997
- * Features:
2998
- * - Handles all ECMAScript built-in types, including edge cases and naming inconsistencies.
2999
- * - Always returns result in PascalCase with spaces (e.g., "Big Uint 64 Array").
3000
- * - Normalizes incorrect or environment-specific type names (e.g., "finalizationregistry" → "FinalizationRegistry").
3001
- *
3002
- * @param value - The value to check.
3003
- * @returns The precise type name in PascalCase with spaces.
3004
- *
3005
- * Examples:
3006
- * ```ts
3007
- * getPreciseType([]); // "Array"
3008
- * getPreciseType(new Map()); // "Map"
3009
- * getPreciseType(new FinalizationRegistry(() => {})); // "Finalization Registry"
3010
- * getPreciseType(BigInt(10)); // "Big Int"
3011
- * ```
3012
- */
3013
- declare const getPreciseType:(value:unknown)=>string;type IsObjectOrArray<T>=unknown extends T ? Record<string,unknown>| unknown[]:T extends object ? T extends unknown[] ? T:T extends NonPlainObject ? never:T:never;
3014
- /** ---------------------------------------------------------
3015
- * * ***Type guard: Checks if a value is an object or array.***
3016
- * ---------------------------------------------------------
3017
- *
3018
- * Will return `false` for `null`, `undefined`, and primitives.
3019
- *
3020
- * @param {unknown} value - The value to check.
3021
- * @returns {value is object} Returns `true` if the value is an object or array.
3022
- *
3023
- * @example
3024
- * isObjectOrArray({ name: "Alice" }); // true
3025
- * isObjectOrArray([1,2,3]); // true
3026
- * isObjectOrArray(null); // false
3027
- * isObjectOrArray(undefined); // false
3028
- * isObjectOrArray("hello"); // false
3029
- */
3030
- declare function isObjectOrArray<T>(value:T):value is IsObjectOrArray<T>;
3031
- /** -------------------
3032
- * * ***Checks if `value` is likely an `arguments` object.***
3033
- * -------------------
3034
- *
3035
- * @param {*} value The value to check.
3036
- *
3037
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
3038
- * else `false`.
3039
- *
3040
- * @example
3041
- *
3042
- * isArguments(function() { return arguments; }());
3043
- * // => true
3044
- *
3045
- * isArguments([1, 2, 3]);
3046
- * // => false
3047
- */
3048
- declare const isArguments:(value:unknown)=>value is IArguments;
3049
- /** ----------------------------------------------------
3050
- * * ***Checks if `value` is classified as an `ArrayBuffer` object.***
3051
- * ----------------------------------------------------
3052
- *
3053
- * @param {*} value The value to check.
3054
- * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
3055
- *
3056
- * @example
3057
- *
3058
- * isArrayBuffer(new ArrayBuffer(2));
3059
- * // => true
3060
- *
3061
- * isArrayBuffer(new Array(2));
3062
- * // => false
3063
- */
3064
- declare function isArrayBuffer(value:unknown):value is ArrayBuffer;
3065
- /** ----------------------------------------------------
3066
- * * ***Checks if `value` is array-like. A value is considered array-like if it's
3067
- * not a function and has a `value.length` that's an integer greater than or
3068
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.***
3069
- * ----------------------------------------------------
3070
- *
3071
- * @param {*} value The value to check.
3072
- *
3073
- * @returns Returns `true` if `value` is array-like, else `false`.
3074
- *
3075
- * @example
3076
- * isArrayLike([1, 2, 3]);
3077
- * // => true
3078
- *
3079
- * isArrayLike(document.body.children);
3080
- * // => true
3081
- *
3082
- * isArrayLike('abc');
3083
- * // => false
3084
- *
3085
- * isArrayLike(noop);
3086
- * // => false
3087
- */
3088
- 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;};
3089
- /** ----------------------------------------------------
3090
- * * ***This method is like `isArrayLike` except that it also checks if `value` is an object.***
3091
- * ----------------------------------------------------
3092
- *
3093
- * @param {*} value The value to check.
3094
- *
3095
- * @returns Returns `true` if `value` is array-like object, else `false`.
3096
- *
3097
- * @example
3098
- * isArrayLikeObject([1, 2, 3]);
3099
- * // => true
3100
- *
3101
- * isArrayLikeObject(document.body.children);
3102
- * // => true
3103
- *
3104
- * isArrayLikeObject('abc');
3105
- * // => false
3106
- *
3107
- * isArrayLikeObject(noop);
3108
- * // => false
3109
- */
3110
- 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;};
3111
- /** ----------------------------------------------------
3112
- * * ***Checks if value is a buffer.***
3113
- * ----------------------------------------------------
3114
- *
3115
- * @param {*} value The value to check.
3116
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
3117
- * @example
3118
- *
3119
- * isBuffer(new Buffer(2));
3120
- * // => true
3121
- *
3122
- * isBuffer(new Uint8Array(2));
3123
- * // => false
3124
- */
3125
- declare const isBuffer:(value:unknown)=>value is Buffer;
3126
- /** ----------------------------------------------------
3127
- * * ***Checks if `value` is likely a DOM element.***
3128
- * ----------------------------------------------------
3129
- *
3130
- * @param {*} value The value to check.
3131
- * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
3132
- * @example
3133
- *
3134
- * isElement(document.body);
3135
- * // => true
3136
- *
3137
- * isElement('<body>');
3138
- * // => false
3139
- *
3140
- * isElement(document.createElement("div"));
3141
- * // => true
3142
- */
3143
- 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>;
3144
- /** ----------------------------------------------------
3145
- * * ***Checks if `value` is an empty object, collection, map, or set.***
3146
- * ----------------------------------------------------
3147
- *
3148
- * Objects are considered empty if they have no own enumerable string keyed
3149
- * properties.
3150
- *
3151
- * Array-like values such as `arguments` objects, arrays, buffers, strings, or
3152
- * jQuery-like collections are considered empty if they have a `length` of `0`.
3153
- * Similarly, maps and sets are considered empty if they have a `size` of `0`.
3154
- *
3155
- * @param {*} value The value to check.
3156
- * @returns {boolean} Returns `true` if `value` is empty, else `false`.
3157
- * @example
3158
- *
3159
- * isEmpty(null);
3160
- * // => true
3161
- *
3162
- * isEmpty(true);
3163
- * // => true
3164
- *
3165
- * isEmpty(1);
3166
- * // => true
3167
- *
3168
- * isEmpty([1, 2, 3]);
3169
- * // => false
3170
- *
3171
- * isEmpty({ 'a': 1 });
3172
- * // => false
3173
- */
3174
- 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;
3175
- /** ----------------------------------------------------
3176
- * * ***Performs a deep comparison between two values to determine if they are equivalent.***
3177
- * ----------------------------------------------------
3178
- *
3179
- * **Note:** This method supports comparing arrays, array buffers, booleans,
3180
- * date objects, error objects, maps, numbers, `Object` objects, regexes,
3181
- * sets, strings, symbols, and typed arrays. `Object` objects are compared
3182
- * by their own, not inherited, enumerable properties. Functions and DOM
3183
- * nodes are **not** supported.
3184
- *
3185
- *
3186
- * @param value The value to compare.
3187
- * @param other The other value to compare.
3188
- * @returns Returns `true` if the values are equivalent, else `false`.
3189
- *
3190
- * @example
3191
- *
3192
- * const object = { user: "fred" };
3193
- * const other = { user: "fred" };
3194
- *
3195
- * isEqual(object, other);
3196
- * // => true
3197
- *
3198
- * object === other;
3199
- * // => false
3200
- */
3201
- 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;
3202
- /** ----------------------------------------------------
3203
- * * ***This method is like `isEqual` except that it accepts `customizer` which
3204
- * is invoked to compare values. If `customizer` returns `undefined`, comparisons
3205
- * are handled by the method instead. The `customizer` is invoked with up to
3206
- * six arguments: (objValue, othValue [, index|key, object, other, stack]).***
3207
- * ----------------------------------------------------
3208
- *
3209
- * @param {*} value The value to compare.
3210
- * @param {*} other The other value to compare.
3211
- * @param {Function} [customizer] The function to customize comparisons.
3212
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
3213
- * @example
3214
- *
3215
- * function isGreeting(value) {
3216
- * return /^h(?:i|ello)$/.test(value);
3217
- * }
3218
- *
3219
- * function customizer(objValue, othValue) {
3220
- * if (isGreeting(objValue) && isGreeting(othValue)) {
3221
- * return true;
3222
- * }
3223
- * }
3224
- *
3225
- * var array = ['hello', 'goodbye'];
3226
- * var other = ['hi', 'goodbye'];
3227
- *
3228
- * isEqualWith(array, other, customizer);
3229
- * // => true
3230
- */
3231
- declare function isEqualWith(value:unknown,other:unknown,customizer?:IsEqualCustomizer):boolean;
3232
- /** -----------------------------------------------------------------------------
3233
- * * Checks if `value` is a finite number (not `Infinity`, `-Infinity`, or `NaN`).
3234
- * -----------------------------------------------------------------------------
3235
- *
3236
- * This method is based on
3237
- * [`Number.isFinite()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite).
3238
- * It returns `true` only for values that are of type `number` and are finite.
3239
- *
3240
- * @param {*} value - The value to check.
3241
- * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
3242
- *
3243
- * @example
3244
- *
3245
- * isFinite(3);
3246
- * // => true
3247
- *
3248
- * isFinite(Number.MIN_VALUE);
3249
- * // => true
3250
- *
3251
- * isFinite(Infinity);
3252
- * // => false
3253
- *
3254
- * isFinite("3");
3255
- * // => false
3256
- */
3257
- declare function isFinite$1(value?:unknown):boolean;
3258
- /** ----------------------------------------------------
3259
- * * ***Checks if `value` is a integer.***
3260
- * ----------------------------------------------------
3261
- *
3262
- * **Note:** This method is based on
3263
- * [`Number.isInteger`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger).
3264
- *
3265
- * @param {*} value The value to check.
3266
- * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
3267
- * @example
3268
- *
3269
- * isInteger(3);
3270
- * // => true
3271
- *
3272
- * isInteger(Number.MIN_VALUE);
3273
- * // => false
3274
- *
3275
- * isInteger(Infinity);
3276
- * // => false
3277
- *
3278
- * isInteger('3');
3279
- * // => false
3280
- */
3281
- declare function isInteger(value?:unknown):boolean;
3282
- /** ----------------------------------------
3283
- * * ***Checks if `value` is a valid array-like length.***
3284
- * ----------------------------------------
3285
- *
3286
- * **Note:** This method is loosely based on
3287
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
3288
- *
3289
- * @param {*} value The value to check.
3290
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
3291
- * @example
3292
- *
3293
- * isLength(3); // => true
3294
- * isLength(Number.MIN_VALUE); // => false
3295
- * isLength(Infinity); // => false
3296
- * isLength('3'); // => false
3297
- * isLength(4294967296); // => true
3298
- *
3299
- */
3300
- declare function isLength(value:unknown):boolean;
3301
- /** ----------------------------------------------------
3302
- * * ***Performs a partial deep comparison between `object` and `source` to determine if `object` contains equivalent property values.***
3303
- * ----------------------------------------------------
3304
- *
3305
- * - This method returns `true` if all the properties in `source` exist in `object` and are deeply equal.
3306
- * - It does **not** require `object` and `source` to be the same shape—only that `object` contains a subset that matches `source`.
3307
- *
3308
- * ⚠️ Arrays are treated as objects: only the matching indexed keys are compared.
3309
- *
3310
- * @remarks
3311
- * - This method is equivalent to a partially applied `matches(source)` predicate.
3312
- * - Partial comparisons will match:
3313
- * - An empty array (`[]`) in `source` with any array in `object`.
3314
- * - An empty object (`{}`) in `source` with any object in `object`.
3315
- *
3316
- * @param object - The object to inspect.
3317
- * @param source - The object containing property values to match.
3318
- * @returns Returns `true` if `object` is a match, else `false`.
3319
- *
3320
- * @example
3321
- * const object = { a: 1, b: 2 };
3322
- *
3323
- * isMatch(object, { b: 2 });
3324
- * // => true
3325
- *
3326
- * isMatch(object, { b: 1 });
3327
- * // => false
3328
- *
3329
- * isMatch([1, 2, 3], [1, 2]);
3330
- * // => true (treats arrays as objects with index keys)
3331
- */
3332
- declare function isMatch(object:object,source:object):boolean;type isMatchWithCustomizer=(value:any,other:any,indexOrKey:PropertyKey,object:object,source:object)=>boolean | undefined;
3333
- /** ----------------------------------------------------
3334
- * * ***Performs a partial deep comparison between `object` and `source`,
3335
- * like `isMatch`, but with a `customizer` function to control comparisons.***
3336
- * ----------------------------------------------------
3337
- *
3338
- * If `customizer` returns a value other than `undefined`, that value is used
3339
- * as the result of the comparison for the current property. Otherwise,
3340
- * the comparison falls back to the default deep equality logic.
3341
- *
3342
- * @remarks
3343
- * - The `customizer` function is invoked with up to **five** arguments:
3344
- * `(objValue, srcValue, keyOrIndex, object, source)`.
3345
- * - Returning `true` from `customizer` will short-circuit further comparison
3346
- * for that key.
3347
- * - Returning `false` will cause `isMatchWith` to return `false` immediately.
3348
- * - Returning `undefined` allows default comparison to proceed.
3349
- *
3350
- * @category Lang
3351
- *
3352
- * @param object - The object to inspect.
3353
- * @param source - The object of property values to match.
3354
- * @param customizer - The function to customize comparisons.
3355
- * @returns Returns `true` if `object` is a match, else `false`.
3356
- *
3357
- * @example
3358
- * function isGreeting(value: unknown) {
3359
- * return typeof value === 'string' && /^h(?:i|ello)$/.test(value);
3360
- * }
3361
- *
3362
- * function customizer(objValue: unknown, srcValue: unknown) {
3363
- * if (isGreeting(objValue) && isGreeting(srcValue)) {
3364
- * return true;
3365
- * }
3366
- * }
3367
- *
3368
- * const object = { greeting: 'hello' };
3369
- * const source = { greeting: 'hi' };
3370
- *
3371
- * isMatchWith(object, source, customizer);
3372
- * // => true
3373
- */
3374
- declare function isMatchWith(value:object,other:object,customizer?:isMatchWithCustomizer):boolean;
3375
- /** ----------------------------------------------------
3376
- * * ***Checks if `value` is `NaN`.***
3377
- * ----------------------------------------------------
3378
- *
3379
- * **Note:** This method is based on
3380
- * [`Number.isNaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) and is not the same as
3381
- * global [`isNaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN) which returns `true` for
3382
- * `undefined` and other non-number values.
3383
- *
3384
- * @param {*} value The value to check.
3385
- * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
3386
- * @example
3387
- *
3388
- * import * as RzlUtilsJs from "@rzl-zone/utils-js";
3389
- *
3390
- * RzlUtilsJs.isNaN(NaN); // => true
3391
- *
3392
- * RzlUtilsJs.isNaN(new Number(NaN)); // => true
3393
- *
3394
- * RzlUtilsJs.isNaN(undefined); // => false
3395
- *
3396
- * // This global isNaN:
3397
- * isNaN(undefined); // => true
3398
- */
3399
- declare function isNaN$1(value?:unknown):boolean;
3400
- /** ----------------------------------------------------
3401
- * * ***Checks if `value` is a pristine native function.***
3402
- * ----------------------------------------------------
3403
- *
3404
- * **Note:** This method can't reliably detect native functions in the presence
3405
- * of the core-js package because core-js circumvents this kind of detection.
3406
- * Despite multiple requests, the core-js maintainer has made it clear: any
3407
- * attempt to fix the detection will be obstructed. As a result, we're left
3408
- * with little choice but to throw an error. Unfortunately, this also affects
3409
- * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
3410
- * which rely on core-js.
3411
- *
3412
- * @param {*} value The value to check.
3413
- * @returns {boolean} Returns `true` if `value` is a native function,
3414
- * else `false`.
3415
- * @example
3416
- *
3417
- * isNative(Array.prototype.push);
3418
- * // => true
3419
- *
3420
- * import * as RzlUtilsJs from "@rzl-zone/utils-js";
3421
- * isNative(RzlUtilsJs);
3422
- * // => false
3423
- */
3424
- declare function isNative(value?:unknown):value is AnyFunction;
3425
- /** ----------------------------------------------------
3426
- * * ***Checks if `value` is `null` or `undefined`.***
3427
- * ----------------------------------------------------
3428
- *
3429
- * @param {*} value The value to check.
3430
- * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
3431
- * @example
3432
- *
3433
- * isNil(null);
3434
- * // => true
3435
- *
3436
- * isNil(void 0);
3437
- * // => true
3438
- *
3439
- * isNil(NaN);
3440
- * // => false
3441
- */
3442
- declare function isNil(value?:unknown):value is null | undefined;
3443
- /** --------------------------------------------------
3444
- * * ***Checks if `value` is the
3445
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
3446
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)***
3447
- * --------------------------------------------------
3448
- *
3449
- * @note
3450
- * ⚠ **For More Strict Object Use `isObject` instead.**
3451
- *
3452
- * @param {*} value The value to check.
3453
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
3454
- * @example
3455
- *
3456
- * isObjectLoose({});
3457
- * // => true
3458
- *
3459
- * isObjectLoose([1, 2, 3]);
3460
- * // => true
3461
- *
3462
- * isObjectLoose(noop);
3463
- * // => true
3464
- *
3465
- * isObjectLoose(null);
3466
- * // => false
3467
- *
3468
- * isObjectLoose(undefined);
3469
- * // => false
3470
- */
3471
- declare function isObjectLoose<T=object>(value:unknown):value is T;
3472
- /** ----------------------------------------------------
3473
- * * ***Checks if `value` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`..***
3474
- * ----------------------------------------------------
3475
- *
3476
- * @param {*} value The value to check.
3477
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
3478
- * @example
3479
- *
3480
- * function Foo() {
3481
- * this.a = 1;
3482
- * }
3483
- *
3484
- * isPlainObject(new Foo);
3485
- * // => false
3486
- *
3487
- * isPlainObject([1, 2, 3]);
3488
- * // => false
3489
- *
3490
- * isPlainObject({ 'x': 0, 'y': 0 });
3491
- * // => true
3492
- *
3493
- * isPlainObject(Object.create(null));
3494
- * // => true
3495
- */
3496
- declare function isPlainObject(value:unknown):value is Record<string,unknown>;declare function isPlainObject<T>(value:T):value is NonNullable<Extract<T,Record<string,unknown>>>;
3497
- /** --------------------------------------------------
3498
- * * ***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.***
3499
- * --------------------------------------------------
3500
- *
3501
- * **Note:** This method is based on
3502
- * [`Number.isSafeInteger`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
3503
- *
3504
- * @param {*} value The value to check.
3505
- * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
3506
- * @example
3507
- *
3508
- * isSafeInteger(3);
3509
- * // => true
3510
- *
3511
- * isSafeInteger(Number.MIN_VALUE);
3512
- * // => false
3513
- *
3514
- * isSafeInteger(Infinity);
3515
- * // => false
3516
- *
3517
- * isSafeInteger('3');
3518
- * // => false
3519
- */
3520
- declare function isSafeInteger(value:unknown):value is number;
3521
- /** --------------------------------------------------
3522
- * * ***Checks if `value` is classified as a `Set` object.***
3523
- * --------------------------------------------------
3524
- *
3525
- * @param {*} value The value to check.
3526
- * @returns {boolean} Returns `true` if `value` is a set, else `false`.
3527
- * @example
3528
- *
3529
- * isSet(new Set);
3530
- * // => true
3531
- *
3532
- * isSet(new WeakSet);
3533
- * // => false
3534
- */
3535
- declare function isSet<T=any>(value:Set<T>):value is Set<T>;declare function isSet(value:unknown):value is Set<any>;
3536
- /** --------------------------------------------------
3537
- * * ***Checks if `value` is classified as a typed array.***
3538
- * --------------------------------------------------
3539
- *
3540
- * @param {*} value The value to check.
3541
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
3542
- * @example
3543
- *
3544
- *
3545
- * isTypedArray(new Uint8Array); // => true
3546
- * isTypedArray(new Uint8Array()); // => true
3547
- * isTypedArray(new Float32Array()); // => true
3548
- * isTypedArray(new Uint8ClampedArray()); // => true
3549
- * isTypedArray([]); // => false
3550
- * isTypedArray(Buffer.from("hi")); // => false
3551
- */
3552
- declare function isTypedArray(value:unknown):value is TypedArray;
3553
- /** --------------------------------------------------
3554
- * * ***Checks if `value` is classified as a `WeakMap` object.***
3555
- * --------------------------------------------------
3556
- *
3557
- * @param {*} value The value to check.
3558
- * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
3559
- * @example
3560
- *
3561
- * isWeakMap(new WeakMap);
3562
- * // => true
3563
- *
3564
- * isWeakMap(new Map);
3565
- * // => false
3566
- */
3567
- declare function isWeakMap<K extends object=object,V=unknown>(value:unknown):value is WeakMap<K,V>;
3568
- /** ----------------------------------------
3569
- * * ***Creates a delay for a specified duration.***
3570
- * ----------------------------------------
3571
- *
3572
- * @param {number} [milliSeconds=1000] - The duration of the delay in milliSeconds (default: 1000ms).
3573
- * @param {AbortSignal} [signal] - An optional AbortSignal to cancel the delay.
3574
- * @returns {Promise<void>} A promise that resolves after the specified delay or rejects if aborted.
3575
- *
3576
- * @throws {TypeError} If `milliSeconds` is not a valid non-negative number.
3577
- * @throws {TypeError} If `signal` is not a valid AbortSignal.
3578
- * @throws {DOMException} If aborted, rejects with `AbortError`.
3579
- *
3580
- * @example
3581
- * await delay(2000); // waits for 2 seconds
3582
- *
3583
- * // With AbortSignal
3584
- * const controller = new AbortController();
3585
- * delay(5000, controller.signal).catch(err => console.log(err.name)); // "AbortError"
3586
- * controller.abort();
3587
- */
3588
- declare const delay:(milliSeconds?:number,signal?:AbortSignal)=>Promise<void>;
3589
- /** ----------------------------------------------------------
3590
- * * Capitalizes the first letter of a string.
3591
- * * Optionally lowercases the rest and trims whitespace.
3592
- * ----------------------------------------------------------
3593
- *
3594
- * @param string - The string to be processed.
3595
- * @param options - Options to control behavior.
3596
- * @param options.lowerCaseNextRest - If true, lowercases the rest (next first letter) (default: true).
3597
- * @param options.trim - If true, trims the string before processing (default: false).
3598
- * @returns The processed string. Returns "" if input is null, undefined, or not a valid string.
3599
- *
3600
- * @example
3601
- * capitalizeFirst(" hello WORLD ") // " Hello world"
3602
- * capitalizeFirst(" hello WORLD ", { trim: true }) // "Hello world"
3603
- * capitalizeFirst("FOO", { lowerCaseNextRest: false }) // "FOO"
3604
- * capitalizeFirst(" foo BAR ", { trim: true, lowerCaseNextRest: false }) // "Foo BAR"
3605
- */
3606
- declare const capitalizeFirst:(string?:string | null,options?:{
3607
- /**
3608
- * @description If true, the rest of the string will be converted to lowercase after capitalizing the first letter.
3609
- * @default true
3610
- */
3611
- lowerCaseNextRest?:boolean;
3612
- /**
3613
- * @description If true, the string will trimmed.
3614
- * @default false
3615
- */
3616
- trim?:boolean;})=>string;
3617
- /** ----------------------------------------------------------
3618
- * * ***Capitalizes the first letter of each word in a string
3619
- * while converting the rest to lowercase.***
3620
- * ----------------------------------------------------------
3621
- *
3622
- * @param value - The input string to be processed. If `null` or `undefined`, returns an empty string.
3623
- * @param options - Optional settings to control the output:
3624
- * - `trim`: If `true`, removes leading and trailing spaces.
3625
- * - `collapseSpaces`: If `true`, collapses multiple spaces **between words** into a single space (while preserving leading/trailing spaces).
3626
- *
3627
- * @returns A new string where each word starts with an uppercase letter
3628
- * and the remaining letters are lowercase. If `value` is empty, `null`, or `undefined`,
3629
- * returns an empty string.
3630
- *
3631
- * @example
3632
- * capitalizeWords(" hello world ");
3633
- * // => " Hello World "
3634
- *
3635
- * capitalizeWords(" hello world ", { trim: true });
3636
- * // => "Hello World"
3637
- *
3638
- * capitalizeWords(" hello world ", { collapseSpaces: true });
3639
- * // => " Hello World "
3640
- *
3641
- * capitalizeWords(" hello world ", { trim: true, collapseSpaces: true });
3642
- * // => "Hello World"
3643
- */
3644
- declare const capitalizeWords:(value?:string | null,options?:{
3645
- /** If `true`, removes leading and trailing spaces, default `false`. */
3646
- trim?:boolean;
3647
- /** If `true`, collapses multiple spaces **between words** into a single space (while preserving leading/trailing spaces), default `false`. */
3648
- collapseSpaces?:boolean;})=>string;
3649
- /** ----------------------------------------------------------
3650
- * * ***Converts a string to `camelCase`.***
3651
- * ----------------------------------------------------------
3652
- *
3653
- * @description
3654
- * - Splits the string by any sequence of non-alphanumeric characters
3655
- * (including spaces, punctuation, symbols, hyphens, underscores, emojis, etc).
3656
- * - The first word is fully lowercase.
3657
- * - Each subsequent word starts with an uppercase letter and the rest is lowercase.
3658
- * - Joins all words without separators to form camelCase.
3659
- * - If input is `null` or `undefined`, returns an empty string.
3660
- * - Ignores empty segments (multiple delimiters are collapsed).
3661
- *
3662
- * @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
3663
- * @returns {string} The camelCase formatted string.
3664
- *
3665
- * @example
3666
- * toCamelCase("hello world"); // "helloWorld"
3667
- * toCamelCase("convert_to-camel case"); // "convertToCamelCase"
3668
- * toCamelCase("___hello--world__ again!!"); // "helloWorldAgain"
3669
- * toCamelCase("🔥fire_and-ice❄️"); // "fireAndIce"
3670
- * toCamelCase(null); // ""
3671
- */
3672
- declare const toCamelCase:(value?:string | null)=>string;
3673
- /** ----------------------------------------------------------
3674
- * * ***Converts a string to `PascalCase`.***
3675
- * ----------------------------------------------------------
3676
- *
3677
- * @description
3678
- * - Splits the string by any sequence of non-alphanumeric characters
3679
- * (including spaces, punctuation, symbols, hyphens, underscores, emojis, etc).
3680
- * - Each resulting word starts with an uppercase letter, followed by lowercase.
3681
- * - Joins all words without separators (PascalCase).
3682
- * - If input is `null` or `undefined`, returns an empty string.
3683
- * - Ignores empty segments (multiple delimiters are collapsed).
3684
- *
3685
- * @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
3686
- * @returns {string} The PascalCase formatted string.
3687
- *
3688
- * @example
3689
- * toPascalCase("hello world"); // "HelloWorld"
3690
- * toPascalCase("convert_to-pascal case"); // "ConvertToPascalCase"
3691
- * toPascalCase("___hello--world__ again!!"); // "HelloWorldAgain"
3692
- * toPascalCase("🔥fire_and-ice❄️"); // "FireAndIce"
3693
- * toPascalCase(null); // ""
3694
- */
3695
- declare const toPascalCase:(value?:string | null)=>string;
3696
- /** ----------------------------------------------------------
3697
- * * ***Converts a string to `kebab-case`.***
3698
- * ----------------------------------------------------------
3699
- *
3700
- * @description
3701
- * - Splits the string by any sequence of non-alphanumeric characters
3702
- * (spaces, hyphens, underscores, symbols, emojis, etc).
3703
- * - Joins all words with hyphens (-).
3704
- * - Converts entire string to lowercase.
3705
- * - If input is `null` or `undefined`, returns an empty string.
3706
- * - Ignores empty segments (multiple delimiters are collapsed).
3707
- *
3708
- * @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
3709
- * @returns {string} The kebab-case formatted string.
3710
- *
3711
- * @example
3712
- * toKebabCase("Hello World"); // "hello-world"
3713
- * toKebabCase("convert_to-kebab case"); // "convert-to-kebab-case"
3714
- * toKebabCase("🔥fire___and--ice❄️"); // "fire-and-ice"
3715
- * toKebabCase(null); // ""
3716
- */
3717
- declare const toKebabCase:(value?:string | null)=>string;
3718
- /** ----------------------------------------------------------
3719
- * * ***Converts a string to `snake_case`.***
3720
- * ----------------------------------------------------------
3721
- *
3722
- * @description
3723
- * - Lowercases all letters.
3724
- * - Joins words with `_`.
3725
- * - Removes special characters, treating them as word separators.
3726
- * - If input is `null` or `undefined`, returns "".
3727
- *
3728
- * @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
3729
- * @returns {string} snake_case string
3730
- *
3731
- * @example
3732
- * toSnakeCase("Hello World") => "hello_world"
3733
- * toSnakeCase("convert-to_snake case") => "convert_to_snake_case"
3734
- */
3735
- declare const toSnakeCase:(value?:string | null)=>string;
3736
- /** ----------------------------------------------------------
3737
- * * ***Converts a string to `dot.case`.***
3738
- * ----------------------------------------------------------
3739
- *
3740
- * @description
3741
- * - Lowercases all letters.
3742
- * - Joins words with `.`.
3743
- * - Removes special characters, treating them as word separators.
3744
- * - If input is `null` or `undefined`, returns "".
3745
- *
3746
- * @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
3747
- * @returns {string} dot.case string
3748
- *
3749
- * @example
3750
- * toDotCase("Hello World") => "hello.world"
3751
- * toDotCase("convert-to_dot case") => "convert.to.dot.case"
3752
- */
3753
- declare const toDotCase:(value?:string | null)=>string;
3754
- /** ----------------------------------------------------------
3755
- * * ***Slugifies a string for use in URLs.***
3756
- * ----------------------------------------------------------
3757
- *
3758
- * @description
3759
- * - Lowercases all letters.
3760
- * - Joins words with `-`.
3761
- * - Removes special characters and trims leading/trailing dashes.
3762
- * - If input is `null` or `undefined`, returns "".
3763
- *
3764
- * @param {string | null | undefined} value - The input string to be convert. If `null` or `undefined`, returns an empty string.
3765
- * @returns {string} slug string
3766
- *
3767
- * @example
3768
- * slugify("Hello World!") => "hello-world"
3769
- * slugify(" --- Convert to Slug? --- ") => "convert-to-slug"
3770
- */
3771
- declare const slugify:(value?:string | null)=>string;
3772
- /** ----------------------------------------------------------
3773
- * * ***Normalizes whitespace in a string by reducing multiple spaces
3774
- * to a single space, optionally trims, or only trims based on options.***
3775
- * ----------------------------------------------------------
3776
- *
3777
- * - ✅ Collapses all consecutive whitespace (spaces, tabs, newlines) into a single space.
3778
- * - ✅ Can trim leading/trailing spaces (default behavior), or preserve them with `withTrim: false`.
3779
- * - ✅ Can skip normalization entirely and only trim using `trimOnly: true`.
3780
- * - ✅ Returns an empty string if input is `null` or `undefined`.
3781
- *
3782
- * @param {string} [value] - The input string to be processed. If `null` or `undefined`, returns an empty string.
3783
- * @param {object} [options] - Configuration options.
3784
- * @param {boolean} [options.trimOnly=false] - If `true`, skips normalization and only trims the string.
3785
- * @param {boolean} [options.withTrim=true] - If `false`, preserves leading/trailing whitespace.
3786
- *
3787
- * @returns {string} The processed string.
3788
- *
3789
- * @example
3790
- * normalizeSpaces(" Hello World\tthis is\n\nok ");
3791
- * // "Hello World this is ok"
3792
- *
3793
- * normalizeSpaces(" Hello World\tthis is\n\nok ", { trimOnly: true });
3794
- * // "Hello World this is\n\nok"
3795
- *
3796
- * normalizeSpaces(" Hello World ", { withTrim: false });
3797
- * // " Hello World "
3798
- *
3799
- * normalizeSpaces(null);
3800
- * // ""
3801
- */
3802
- declare const normalizeSpaces:(value?:string | null,options?:{
3803
- /**
3804
- * If `true`, skips normalization and only trims whitespace from start & end.
3805
- * @default false */
3806
- trimOnly?:boolean;
3807
- /**
3808
- * If `false`, skips trimming value.
3809
- * @default true */
3810
- withTrim?:boolean;})=>string;
3811
- /** ----------------------------------------------------------
3812
- * * ***Normalizes a string by ensuring it is a valid string and trimming whitespace.***
3813
- * ----------------------------------------------------------
3814
- *
3815
- * @description
3816
- * If the input is `undefined`, `null`, or an `empty string` after trimming,
3817
- * it returns an empty string `("")`.
3818
- *
3819
- * @param {string | undefined | null} input - The input string to be normalize. If `null` or `undefined`, returns an empty string.
3820
- * @returns {string} A trimmed string or an empty string if the input is invalid.
3821
- *
3822
- * @example
3823
- * normalizeString(" Hello World ");
3824
- * // → "Hello World"
3825
- *
3826
- * normalizeString("");
3827
- * // → ""
3828
- *
3829
- * normalizeString(null);
3830
- * // → ""
3831
- *
3832
- * normalizeString(undefined);
3833
- * // → ""
3834
- */
3835
- declare const normalizeString:(input?:string | null)=>string;
3836
- /** ----------------------------------------------------------
3837
- * * ***Removes all spaces from a string or trims only, based on the options provided.***
3838
- * ----------------------------------------------------------
3839
- *
3840
- * @description
3841
- * - If `trimOnly` is `true`, the string is simply trimmed.
3842
- * - Otherwise, removes **all spaces**, tabs, newlines, etc.
3843
- * - If the input is `null` or `undefined`, returns an empty string `("")`.
3844
- *
3845
- * @param {string | null | undefined} value - The input string to be processed. If `null` or `undefined`, returns an empty string.
3846
- * @param {object} [options] - The options object.
3847
- * @param {boolean} [options.trimOnly=false] - If `true`, only trims the string without removing spaces inside.
3848
- * @returns {string} The processed string.
3849
- *
3850
- * @example
3851
- * removeSpaces(" Hello World ");
3852
- * // → "HelloWorld"
3853
- *
3854
- * removeSpaces(" Hello World ", { trimOnly: true });
3855
- * // → "Hello World"
3856
- *
3857
- * removeSpaces(null);
3858
- * // → ""
3859
- */
3860
- declare const removeSpaces:(value?:string | null,options?:{
3861
- /**
3862
- * @description If true, only trims the string.
3863
- *
3864
- * @default false */
3865
- trimOnly?:boolean;})=>string;
3866
- /** ----------------------------------------------------------
3867
- * * ***Removes all HTML tags from a given string.***
3868
- * ----------------------------------------------------------
3869
- *
3870
- * This function removes valid HTML tags (including nested and self-closing ones)
3871
- * by replacing them with spaces, then collapses multiple whitespaces into a single space.
3872
- *
3873
- * It handles the following cases:
3874
- * - If the input is not a string (`null`, `undefined`, or any non-string), it is returned as undefined.
3875
- * - If the input is an empty or whitespace-only string, it returns an empty string (`""`).
3876
- * - Otherwise, it returns the cleaned string with tags removed and normalized whitespace.
3877
- *
3878
- * @template T - Input string type (string | null | undefined).
3879
- * @param {T} [input] - A string potentially containing HTML tags.
3880
- * @returns {T extends string ? string : T} - Cleaned string if input is string, or original input otherwise.
3881
- *
3882
- * @example
3883
- * stripHtmlTags("<p>Hello</p>"); // "Hello"
3884
- * stripHtmlTags("<div><b>Bold</b> text</div>"); // "Bold text"
3885
- * stripHtmlTags("Line<br/>Break"); // "Line Break"
3886
- * stripHtmlTags("2 < 5 and 5 > 2"); // "2 < 5 and 5 > 2"
3887
- * stripHtmlTags(""); // ""
3888
- * stripHtmlTags(" "); // ""
3889
- * stripHtmlTags(null); // undefined
3890
- * stripHtmlTags(undefined); // undefined
3891
- */
3892
- declare const stripHtmlTags:<T extends string | null | undefined=undefined>(input?:T)=>T extends string ? string:undefined;
3893
- /** ----------------------------------------------------------
3894
- * * ***Replaces a substring at a specified index within a string.***
3895
- * ----------------------------------------------------------
3896
- *
3897
- * @description
3898
- * Replaces exactly one character at the specified index in the original string
3899
- * with the provided `replaceTo` string. If `replaceTo` has more than one character,
3900
- * the result will expand accordingly.
3901
- *
3902
- * @param {number} index - The starting index where the replacement should occur.
3903
- * @param {string} originalString - The original string to modify.
3904
- * @param {string} replaceTo - The string to insert at the specified index.
3905
- * @returns {string} - The modified string with the replacement applied.
3906
- *
3907
- * @example
3908
- * replaceAt(3, "hello", "X");
3909
- * // → "helXo"
3910
- *
3911
- * replaceAt(1, "world", "AB");
3912
- * // → "wABrld"
3913
- *
3914
- * replaceAt(0, "cat", "br");
3915
- * // → "brat"
3916
- *
3917
- * replaceAt(2, "12345", "-");
3918
- * // → "12-45"
3919
- *
3920
- * replaceAt(4, "ABCDE", "Z");
3921
- * // → "ABCDZ"
3922
- *
3923
- * // ❌ Examples that throw:
3924
- * replaceAt(10, "short", "X");
3925
- * // → ❌ RangeError: Index parameter is out of range at function `replaceAt`
3926
- *
3927
- * replaceAt(-1, "test", "X");
3928
- * // → ❌ RangeError: Index parameter is out of range at function `replaceAt`
3929
- *
3930
- * replaceAt("1", "test", "X");
3931
- * // → ❌ TypeError: Expected 'index' to be a number, and 'replaceTo' and 'originalString' to be strings
3932
- *
3933
- * replaceAt(2, null, "X");
3934
- * // → ❌ TypeError: Expected 'index' to be a number, and 'replaceTo' and 'originalString' to be strings
3935
- */
3936
- declare const replaceAt:(index:number,originalString:string,replaceTo:string)=>string;
3937
- /** ----------------------------------------------------------
3938
- * * ***Extracts initials from a given name.***
3939
- * ----------------------------------------------------------
3940
- *
3941
- * @description
3942
- * Extracts initials from the given name string.
3943
- * - For names with two or more words, returns the first letter of the first and second words.
3944
- * - For a single word with 2+ characters, returns the first two letters.
3945
- * - For a single character, returns that character.
3946
- * - For empty, null, or whitespace-only input, returns an empty string.
3947
- *
3948
- * @param {string} [name=""] - The name to extract initials from.
3949
- * @returns {string} The extracted initials (e.g., "JD" for "John Doe").
3950
- *
3951
- * @example
3952
- * getInitialsName("John Doe"); // "JD"
3953
- * getInitialsName("Alice"); // "AL"
3954
- * getInitialsName(" Bob Marley "); // "BM"
3955
- * getInitialsName("John Ronald Donal"); // "JR"
3956
- * getInitialsName("Lord John Doe Moe"); // "LJ"
3957
- * getInitialsName("X"); // "X"
3958
- * getInitialsName(" "); // "" (empty string)
3959
- * getInitialsName(""); // "" (empty string)
3960
- * getInitialsName(null); // "" (null input)
3961
- * getInitialsName(undefined); // "" (undefined input)
3962
- */
3963
- 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]:[];
3964
- /** ----------------------------------------------------------
3965
- * * ***Creates a helper for styled-components `shouldForwardProp`.***
3966
- * ----------------------------------------------------------
3967
- *
3968
- * @description
3969
- * This utility returns a predicate function that determines
3970
- * whether a given prop should be forwarded to the DOM.
3971
- * Useful for filtering out internal props (e.g., `$size`, `$active`)
3972
- * so they don't end up as invalid HTML attributes.
3973
- *
3974
- * - Accepts a tuple (strict) of prop keys to exclude from forwarding.
3975
- * - Automatically coerces prop names to string for consistent checking.
3976
- * - Supports string, number, or symbol keys (via PropertyKey).
3977
- * - Will throw an error if the provided `props` argument is not an array.
3978
- *
3979
- * @template CustomProps - The type of the component's props.
3980
- * @param {UnionToTupleStrict<keyof CustomProps>} props
3981
- * The list of prop names (keys of `CustomProps`) to exclude from forwarding.
3982
- *
3983
- * @returns {(propName: PropertyKey) => boolean}
3984
- * A function that takes a prop name and returns `true` if it should be forwarded, `false` if it should be blocked.
3985
- *
3986
- * @throws {Error} If `props` is not an array.
3987
- *
3988
- * @example
3989
- * type Props = { $size: string; color: string; visible: boolean };
3990
- * const filter = shouldForwardProp<Props>(["$size"]);
3991
- * filter("$size"); // false (blocked)
3992
- * filter("color"); // true (forwarded)
3993
- *
3994
- * @example
3995
- * // Using with styled-components:
3996
- * styled.div.withConfig({
3997
- * shouldForwardProp: shouldForwardProp<CustomProps>(["$internal"])
3998
- * })
3999
- */
4000
- declare const shouldForwardProp:<CustomProps>(props:UnionToTupleStrict<keyof CustomProps>)=>(propName:PropertyKey)=>boolean;
4001
- /** ---------------------------------
4002
- * * ***Constructs a valid URL with optional query parameters and allows selective removal of duplicate parameters.***
4003
- * ---------------------------------
4004
- *
4005
- *
4006
- * @param {string | URL} baseUrl
4007
- * The base URL to build upon. Must include protocol (e.g., "https://"),
4008
- * domain, and may include port and existing query parameters.
4009
- *
4010
- * @param {Iterable<[string, string]>|URLSearchParamsIterator<[string, string]>} [queryParams]
4011
- * Additional query parameters to append or overwrite on the URL.
4012
- * Accepts any iterable of key-value pairs (like `new URLSearchParams().entries()`).
4013
- *
4014
- * @param {string[]} [removeParams]
4015
- * A list of query parameter keys to remove from the final URL,
4016
- * whether they were in the base URL or provided queryParams.
4017
- *
4018
- * @returns {URL}
4019
- * A new URL object representing the constructed URL with merged
4020
- * and cleaned query parameters.
4021
- *
4022
- * @throws {TypeError}
4023
- * Throws if `baseUrl` is not a valid non-empty string or URL object,
4024
- * or if `queryParams` is not iterable, or if `removeParams` is not an array of strings.
4025
- *
4026
- * @example
4027
- * // Basic usage
4028
- * constructURL("https://example.com/path", new URLSearchParams({ a: "1", b: "2" }).entries());
4029
- * // => URL { href: "https://example.com/path?a=1&b=2", ... }
4030
- *
4031
- * @example
4032
- * // Remove parameters from base and added
4033
- * constructURL("https://example.com/path?foo=1&bar=2", new URLSearchParams({ bar: "ignored", baz: "3" }).entries(), ["bar"]);
4034
- * // => URL { href: "https://example.com/path?foo=1&baz=3", ... }
4035
- */
4036
- declare const constructURL:(baseUrl:string | URL,queryParams?:URLSearchParamsIterator<[string,string]>,removeParams?:string[])=>URL;
4037
- /** --------------------------------------------------------
4038
- * * ***Get Prefix from URL with Optional Base or Auto-detection (Supports String or Array of URLs).***
4039
- * --------------------------------------------------------
4040
- *
4041
- * @description
4042
- * This function extracts the prefix from one or more URLs. It can either:
4043
- * - Use a provided `base` string or an array of strings to check and return the matching prefix.
4044
- * - Automatically detect the prefix if no `base` is provided by analyzing the first part of the URL.
4045
- *
4046
- * The function is flexible and can handle both scenarios:
4047
- * 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.
4048
- * 2. **When the base is not provided**: The function will automatically detect the prefix by splitting the URL or using a regex.
4049
- *
4050
- * **Important Notes**:
4051
- * - If a base (or an array of bases) is provided, the URL must start with one of the given base(s).
4052
- * - If no base is provided, the function will attempt to detect the prefix automatically.
4053
- * - The `url` parameter can be either a string or an array of strings.
4054
- * - Supports deduplication of results (enabled by default).
4055
- * - Automatically returns a single string if only one unique result exists after processing.
4056
- *
4057
- * ---
4058
- *
4059
- * @param {string|string[]} url The full URL(s) from which the prefix should be extracted. Can be a string or an array of strings.
4060
- * @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.
4061
- * @param {{ levels?: number; removeDuplicates?: boolean }} [options] Additional options object:
4062
- * - `levels` (default `1`): The number of segments to include when auto-detecting the prefix (e.g. `/foo/bar` for `levels: 2`).
4063
- * - `removeDuplicates` (default `true`): Whether to remove duplicate prefixes from the final array result.
4064
- *
4065
- * @returns {string|string[]|null}
4066
- * Returns one of:
4067
- * - A single string if only one unique prefix/base is found.
4068
- * - An array of strings if multiple different prefixes/bases are found.
4069
- * - `null` if no matching base is found when using `base`.
4070
- *
4071
- * ---
4072
- *
4073
- * @throws {TypeError}
4074
- * Throws if:
4075
- * - `url` is not a string or an array of strings.
4076
- * - `base` is not a string, array of strings, or `null`.
4077
- * - `options` is not an object.
4078
- * - `levels` is not a number.
4079
- * - `removeDuplicates` is not a boolean.
4080
- *
4081
- * ---
4082
- *
4083
- * ### **🔹 Usage Examples**
4084
- *
4085
- * #### ✅ **Correct Usage (With an Array of URLs and Base)**
4086
- * ```ts
4087
- * const routes = [
4088
- * "/settings/profile",
4089
- * "/settings/password",
4090
- * "/settings/other-path",
4091
- * "/other-path/xyz",
4092
- * ];
4093
- *
4094
- * // With base provided as a string
4095
- * routes.forEach(route => {
4096
- * console.log(getPrefixPathname(route, '/settings')); // Output: "/settings"
4097
- * });
4098
- *
4099
- * // With base provided as an array
4100
- * routes.forEach(route => {
4101
- * console.log(getPrefixPathname(route, ['/settings', '/admin'])); // Output: "/settings" or "/admin" depending on the URL
4102
- * });
4103
- * ```
4104
- *
4105
- * #### ✅ **Correct Usage (With Single URL and Single Base)**
4106
- * ```ts
4107
- * const result = getPrefixPathname("/settings/profile", "/settings");
4108
- * console.log(result); // Output: "/settings"
4109
- * ```
4110
- *
4111
- * #### ✅ **Correct Usage (With Multiple URLs and Single Base)**
4112
- * ```ts
4113
- * const result = getPrefixPathname(["/settings/profile", "/settings/password"], "/settings");
4114
- * console.log(result); // Output: "/settings"
4115
- * ```
4116
- *
4117
- * #### ✅ **Correct Usage (With Multiple URLs and Multiple Bases)**
4118
- * ```ts
4119
- * const result = getPrefixPathname(["/settings/profile", "/admin/password"], ["/settings", "/admin"]);
4120
- * console.log(result); // Output: ["/settings", "/admin"]
4121
- * ```
4122
- *
4123
- * #### ✅ **Auto-detection of Prefix**
4124
- * ```ts
4125
- * const result = getPrefixPathname("/settings/profile");
4126
- * console.log(result); // Output: "/settings"
4127
- *
4128
- * const result2 = getPrefixPathname("/settings/profile/info", null, { levels: 2 });
4129
- * console.log(result2); // Output: "/settings/profile"
4130
- * ```
4131
- *
4132
- * #### ✅ **Multiple URLs with Auto-detection**
4133
- * ```ts
4134
- * const result = getPrefixPathname(["/admin/profile", "/settings/password"]);
4135
- * console.log(result); // Output: ["/admin", "/settings"]
4136
- * ```
4137
- *
4138
- * #### ✅ **Handling Duplicates**
4139
- * ```ts
4140
- * const result = getPrefixPathname(["/settings/profile", "/settings/password"], "/settings");
4141
- * console.log(result); // Output: "/settings" (deduped to single string)
4142
- *
4143
- * const result2 = getPrefixPathname(["/settings/profile", "/settings/profile"], "/settings", { removeDuplicates: false });
4144
- * console.log(result2); // Output: ["/settings", "/settings"]
4145
- * ```
4146
- *
4147
- * #### ❌ **Incorrect Usage (URL Does Not Match Base)**
4148
- * ```ts
4149
- * const result = getPrefixPathname("/other-path/profile", "/settings");
4150
- * console.log(result); // Output: null
4151
- * ```
4152
- *
4153
- * ---
4154
- */
4155
- declare const getPrefixPathname:(url:string | string[],base?:string | string[] | null,options?:{
4156
- /** 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. */
4157
- levels?:number;
4158
- /** Whether to remove duplicates from the result if multiple URLs are passed (default is `true`). */
4159
- removeDuplicates?:boolean;})=>string | string[] | null;
4160
- /** --------------------------------------------------------
4161
- * * ***Extract First Valid Prefix from Path Array or String.***
4162
- * --------------------------------------------------------
4163
- *
4164
- * ### 🚀 **Main Purpose:**
4165
- * This function helps extract the first valid URL prefix from various possible inputs.
4166
- * It is especially useful in routing systems, middleware, or frontend apps that
4167
- * need to decide layout, active navigation, or permissions based on the first
4168
- * segment (or prefix) of a pathname.
4169
- *
4170
- * Typical uses include:
4171
- * - Determining which layout to render (e.g., `/admin` vs `/dashboard` vs `/`).
4172
- * - Highlighting the active menu item in a sidebar based on the current URL.
4173
- * - Enforcing route guards or access controls depending on the URL prefix.
4174
- * - Parsing multi-level route prefixes and selecting the most relevant one.
4175
- *
4176
- * ---
4177
- *
4178
- * ### 🔍 Behavior:
4179
- * It works as follows:
4180
- * - If `result` is an array of strings, it normalizes each element and returns
4181
- * the first non-root path (i.e., not just `"/"`). If all items normalize to `"/"`,
4182
- * it returns the `defaultValue` (normalized).
4183
- * - If `result` is a single string, it normalizes it and returns it if valid,
4184
- * otherwise falls back to the normalized `defaultValue`.
4185
- * - If `result` is `null` or `undefined`, it returns the normalized `defaultValue`.
4186
- *
4187
- * ---
4188
- *
4189
- * ### 🔍 Validation & Errors:
4190
- *
4191
- * - Throws a `TypeError` if:
4192
- * - `defaultValue` is not a non-empty string.
4193
- * - `result` is an array that contains non-string elements.
4194
- * - `result` is a value that is neither `string`, `string[]`, nor `null`.
4195
- *
4196
- * ---
4197
- *
4198
- * ### 🛠 Usage Examples:
4199
- *
4200
- * 1. #### For React: *Determining layout*
4201
- * ```ts
4202
- * const prefix = getFirstPrefixPathname(getPrefixPathname("/admin/settings", ["/admin", "/dashboard"]));
4203
- * if (prefix === "/admin") {
4204
- * renderAdminLayout();
4205
- * }
4206
- * ```
4207
- *
4208
- * 2. #### Setting active menu state
4209
- * ```ts
4210
- * const activeSection = getFirstPrefixPathname(["", "/dashboard", "/profile"]);
4211
- * // => "/dashboard"
4212
- * ```
4213
- *
4214
- * 3. #### Providing graceful fallback
4215
- * ```ts
4216
- * const section = getFirstPrefixPathname([], "/home");
4217
- * // => "/home"
4218
- * ```
4219
- * 4. #### ✅ Using with an Array of Pathnames
4220
- * ```ts
4221
- * const result = getPrefixPathname([" ", "/dashboard", "/settings"]);
4222
- * console.log(getFirstPrefixPathname(result)); // => "/dashboard"
4223
- * ```
4224
- *
4225
- * 5. #### ✅ Using with Single String:
4226
- * ```ts
4227
- * console.log(getFirstPrefixPathname("/profile/settings")); // => "/profile/settings"
4228
- * console.log(getFirstPrefixPathname(" ")); // => "/"
4229
- * ```
4230
- *
4231
- * 6. #### ✅ Fallback to Custom Default:
4232
- * ```ts
4233
- * console.log(getFirstPrefixPathname([" ", ""], "/home")); // => "/home"
4234
- * console.log(getFirstPrefixPathname(null, "/dashboard")); // => "/dashboard"
4235
- * ```
4236
- *
4237
- * 7. #### ✅ Throws on Invalid Input:
4238
- * ```ts
4239
- * getFirstPrefixPathname([1, 2] as any); // ❌ throws TypeError
4240
- * getFirstPrefixPathname({} as any); // ❌ throws TypeError
4241
- * getFirstPrefixPathname(null, " "); // ❌ throws TypeError
4242
- * ```
4243
- *
4244
- * ---
4245
- *
4246
- * @param {string | string[] | null} result
4247
- * The pathname(s) to process. Can be:
4248
- * - A string path (e.g. `"/profile"`),
4249
- * - An array of string paths (e.g. `[" ", "/dashboard"]`),
4250
- * - Or `null`.
4251
- *
4252
- * @param {string} [defaultValue="/"]
4253
- * A custom default path to use if `result` is null or no valid prefix is found.
4254
- * Must be a non-empty string. Defaults to `"/"`.
4255
- *
4256
- * @returns {string}
4257
- * The first valid normalized pathname, or the normalized default.
4258
- *
4259
- * @throws {TypeError}
4260
- * If `result` is not a valid type, or `defaultValue` is not a non-empty string.
4261
- */
4262
- declare const getFirstPrefixPathname:(result?:string | string[] | null,defaultValue?:string)=>string;
4263
- /** --------------------------------------------------------
4264
- * * ***Normalizes a given pathname by ensuring consistent formatting.***
4265
- * --------------------------------------------------------
4266
- *
4267
- * @description
4268
- * This function processes and normalizes a given pathname:
4269
- *
4270
- * - If `pathname` is `null`, `undefined`, empty, or only whitespace,
4271
- * the `defaultPath` will be returned instead.
4272
- *
4273
- * - If `pathname` is a full URL (starting with `http://` or `https://`),
4274
- * it extracts and returns the pathname along with any search parameters and hash.
4275
- * Example: `"https://site.com/foo/bar?x=1#sec"` becomes `"/foo/bar?x=1#sec"`.
4276
- *
4277
- * - All spaces inside the pathname are removed.
4278
- *
4279
- * - Multiple consecutive slashes (like `"//"` or `"///"`) are collapsed into a single slash `"/"`.
4280
- *
4281
- * - Ensures the returned string always starts with exactly one `/`.
4282
- *
4283
- * @param {string | null | undefined} pathname - The pathname to normalize.
4284
- * @param {string} [defaultPath="/"] - A fallback value returned if `pathname` is empty or invalid. Must be a non-empty string, default `"/"`.
4285
- *
4286
- * @returns {string} A properly normalized pathname starting with a single `/`,
4287
- * or the `defaultPath` if the input is invalid or empty.
4288
- *
4289
- * @throws {TypeError} If `defaultPath` is not a non-empty string.
4290
- * @throws {NormalizePathnameError} If an unexpected error occurs during normalization (e.g., URL parsing failure).
4291
- *
4292
- * @example
4293
- * normalizePathname(" /foo//bar "); // => "/foo/bar"
4294
- *
4295
- * normalizePathname("https://example.com//path///to/resource?x=1#hash");
4296
- * // => "/path/to/resource?x=1#hash"
4297
- *
4298
- * normalizePathname(" "); // => "/"
4299
- * normalizePathname(null, "/home"); // => "/home"
4300
- * normalizePathname("/double//slashes"); // => "/double/slashes"
4301
- *
4302
- * normalizePathname(" nested / path / 🚀 "); // => "/nested/path/🚀"
4303
- */
4304
- declare const normalizePathname:(pathname?:string | null,defaultPath?:string)=>string;
4305
- /** -----------------------------------------------
4306
- * * ***Retrieves and formats an environment port variable.***
4307
- * -----------------------------------------------
4308
- *
4309
- * - Extracts only digits from the input.
4310
- * - If no digits found, returns an empty string.
4311
- * - By default does NOT prefix with a colon.
4312
- * Use `{ prefixColon: true }` to prefix with a colon.
4313
- *
4314
- * @param envVar The environment variable string.
4315
- * @param options Optional object: `{ prefixColon?: boolean }`.
4316
- * @returns A string like ":8080" or "8080", or "" if no digits.
4317
- *
4318
- * @throws TypeError if `options` is not an object or `prefixColon` is not boolean.
4319
- *
4320
- * @example
4321
- * formatEnvPort("port:8080"); // "8080"
4322
- * formatEnvPort("port:8080", { prefixColon: true }); // ":8080"
4323
- */
4324
- declare const formatEnvPort:(envVar?:string | null,options?:{
4325
- /** Add prefix with a colon.
4326
- *
4327
- * @default false
4328
- */
4329
- prefixColon?:boolean;})=>string;
4330
- /** ---------------------------------
4331
- * * ***Custom Error for Pathname Normalization Failures***
4332
- * ---------------------------------
4333
- */
4334
- 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,getPreciseType,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';