@lntvow/utils 4.2.13 → 4.2.15

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.
@@ -4,8 +4,6 @@
4
4
  type Arrayable<T> = T | T[];
5
5
  /**
6
6
  * Extracts the type of an item from an array.
7
- * @template T The array type.
8
- * @returns The type of the array's items.
9
7
  */
10
8
  type ArrayItem<T> = T extends (infer U)[] ? U : never;
11
9
  /**
@@ -22,67 +20,86 @@ type AnyObject = Record<PropertyKey, any>;
22
20
  type StringNumber = string | number;
23
21
 
24
22
  /**
25
- * Converts a non-array value to an array. If the target is already an array, it is returned as-is.
23
+ * Converts a non-array value to an array or returns the array as-is.
24
+ *
25
+ * This utility function takes any value and ensures it becomes an array. If the input
26
+ * is already an array, it returns the original array unchanged. If the input is not
27
+ * an array, it wraps the value in a new array.
28
+ *
26
29
  * @example
30
+ * castArray(1) // => [1]
31
+ * castArray('hello') // => ['hello']
32
+ * castArray(null) // => [null]
27
33
  *
28
- * castArray(1) => [1]
34
+ * @example
35
+ * castArray([1, 2, 3]) // => [1, 2, 3]
36
+ * castArray(['a', 'b']) // => ['a', 'b']
29
37
  *
30
- * castArray([1, 2, 3]) => [1, 2, 3]
38
+ * @returns Returns an array containing the input value, or the original array if already an array
31
39
  */
32
40
  declare function castArray<T>(target: Arrayable<T>): T[];
33
41
 
34
42
  /**
35
- * Determines whether `value` is of the `Object` type in JavaScript, including objects, arrays, and functions.
36
- * @returns Returns `true` if `value` is an object, otherwise `false`.
37
- * @example
43
+ * Checks if a value is of the Object type in JavaScript.
38
44
  *
39
- * isObject({}) => true
45
+ * This utility determines whether a value is an object type, which includes
46
+ * objects, arrays, and functions. It excludes null (which technically has
47
+ * typeof 'object' in JavaScript) and primitive values.
40
48
  *
41
- * isObject([1, 2, 3]) => true
49
+ * @example
50
+ * isObject({}) // => true
51
+ * isObject([1, 2, 3]) // => true
52
+ * isObject(function() {}) // => true
42
53
  *
43
- * isObject(function() {}) => true
54
+ * @example
55
+ * isObject(null) // => false
56
+ * isObject(undefined) // => false
57
+ * isObject('string') // => false
44
58
  *
45
- * isObject(null) => false
59
+ * @returns Returns `true` if the value is an object, otherwise `false`
46
60
  */
47
61
  declare function isObject(value: unknown): value is AnyObject;
48
62
 
49
63
  /**
50
- * Determines whether `value` is a general object. A value is considered a general object if it is not `null`
51
- * and the result of `typeof` is "object".
64
+ * Checks if a value is object-like (non-null object type).
52
65
  *
53
- * The difference between `isObject` and `isObjectLike` is that `isObjectLike` does not treat functions as objects.
66
+ * This utility determines whether a value is object-like, meaning it's not null
67
+ * and has a typeof result of "object". Unlike `isObject`, this function excludes
68
+ * functions, treating only pure objects and arrays as object-like.
54
69
  *
55
- * @returns Returns `true` if `value` is a general object, otherwise `false`.
56
70
  * @example
71
+ * isObjectLike({}) // => true
72
+ * isObjectLike([1, 2, 3]) // => true
73
+ * isObjectLike(new Date()) // => true
57
74
  *
58
- * isObjectLike({}) => true
59
- *
60
- * isObjectLike([1, 2, 3]) => true
61
- *
62
- * isObjectLike(function() {}) => false
75
+ * @example
76
+ * isObjectLike(function() {}) // => false
77
+ * isObjectLike(null) // => false
78
+ * isObjectLike('string') // => false
63
79
  *
64
- * isObjectLike(null) => false
80
+ * @returns Returns `true` if the value is object-like, otherwise `false`
65
81
  */
66
82
  declare function isObjectLike(value: unknown): value is AnyObject;
67
83
 
68
84
  /**
69
- * Checks if a value is a plain object. A plain object is defined as an object created by the `{}` syntax
70
- * or constructed using `Object.create(null)`. It includes objects created by `class` or constructors,
71
- * as long as their internal type is `[object Object]`. It excludes arrays, functions, and other built-in objects.
85
+ * Checks if a value is a plain object.
72
86
  *
73
- * @returns Returns `true` if `value` is a plain object, otherwise `false`.
74
- * @example
75
- *
76
- * isPlainObject({ x: 0, y: 0 }) => true
87
+ * This utility determines whether a value is a plain object, defined as an object
88
+ * created by the `{}` syntax, `Object.create(null)`, or class constructors that
89
+ * maintain the `[object Object]` internal type. It excludes arrays, functions,
90
+ * and other built-in objects like Date, RegExp, etc.
77
91
  *
78
- * isPlainObject([1, 2, 3]) => false
79
- *
80
- * isPlainObject(Object.create(null)) => true
92
+ * @example
93
+ * isPlainObject({ x: 0, y: 0 }) // => true
94
+ * isPlainObject(Object.create(null)) // => true
95
+ * isPlainObject(new class Foo {}()) // => true
81
96
  *
82
- * isPlainObject(null) => false
97
+ * @example
98
+ * isPlainObject([1, 2, 3]) // => false
99
+ * isPlainObject(null) // => false
100
+ * isPlainObject(new Date()) // => false
83
101
  *
84
- * class Foo {}
85
- * isPlainObject(new Foo()) => true
102
+ * @returns Returns `true` if the value is a plain object, otherwise `false`
86
103
  */
87
104
  declare function isPlainObject(value: unknown): value is AnyObject;
88
105
 
@@ -92,110 +109,109 @@ declare function isPlainObject(value: unknown): value is AnyObject;
92
109
  declare const objectToString: () => string;
93
110
  /**
94
111
  * Converts a value to its type string representation
95
- * @param value The value to convert
112
+ *
96
113
  * @returns The type string of the value (e.g., "[object Object]")
97
114
  */
98
115
  declare const toTypeString: (value: unknown) => string;
99
116
  /**
100
117
  * Extracts the type name from the type string
101
- * @param value The value to extract the type from
118
+ *
102
119
  * @returns The type name (e.g., "Object", "Array")
103
120
  */
104
121
  declare const toTypeValue: (value: unknown) => string;
105
122
  /**
106
123
  * Checks if a value is a string
107
- * @param val The value to check
124
+ *
108
125
  * @returns `true` if the value is a string, otherwise `false`
109
126
  */
110
127
  declare const isString: (val: unknown) => val is string;
111
128
  /**
112
129
  * Checks if a value is a valid number (excluding NaN and Infinity).
113
- * @param val The value to check
130
+ *
114
131
  * @returns `true` if the value is a finite number, otherwise `false`
115
132
  */
116
133
  declare const isNumber: (val: unknown) => val is number;
117
134
  /**
118
135
  * Checks if a value is a boolean
119
- * @param val The value to check
136
+ *
120
137
  * @returns `true` if the value is a boolean, otherwise `false`
121
138
  */
122
139
  declare const isBoolean: (val: unknown) => val is boolean;
123
140
  /**
124
141
  * Checks if a value is null
125
- * @param val The value to check
142
+ *
126
143
  * @returns `true` if the value is null, otherwise `false`
127
144
  */
128
145
  declare const isNull: (val: unknown) => val is null;
129
146
  /**
130
147
  * Checks if a value is undefined
131
- * @param val The value to check
148
+ *
132
149
  * @returns `true` if the value is undefined, otherwise `false`
133
150
  */
134
151
  declare const isUndef: (val: unknown) => val is undefined;
135
152
  /**
136
153
  * Checks if a value is a symbol
137
- * @param val The value to check
154
+ *
138
155
  * @returns `true` if the value is a symbol, otherwise `false`
139
156
  */
140
157
  declare const isSymbol: (val: unknown) => val is symbol;
141
158
  /**
142
159
  * Checks if a value is an array
143
- * @param val The value to check
160
+ *
144
161
  * @returns `true` if the value is an array, otherwise `false`
145
162
  */
146
163
  declare const isArray: (arg: any) => arg is any[];
147
164
  /**
148
165
  * Checks if a value is a function
149
- * @param val The value to check
166
+ *
150
167
  * @returns `true` if the value is a function, otherwise `false`
151
168
  */
152
169
  declare const isFunction: (val: unknown) => val is Function;
153
170
  /**
154
171
  * Checks if a value is a Map
155
- * @param val The value to check
172
+ *
156
173
  * @returns `true` if the value is a Map, otherwise `false`
157
174
  */
158
175
  declare const isMap: (val: unknown) => val is Map<any, any>;
159
176
  /**
160
177
  * Checks if a value is a Set
161
- * @param val The value to check
178
+ *
162
179
  * @returns `true` if the value is a Set, otherwise `false`
163
180
  */
164
181
  declare const isSet: (val: unknown) => val is Set<any>;
165
182
  /**
166
183
  * Checks if a value is a Date
167
- * @param val The value to check
184
+ *
168
185
  * @returns `true` if the value is a Date, otherwise `false`
169
186
  */
170
187
  declare const isDate: (val: unknown) => val is Date;
171
188
  /**
172
189
  * Checks if a value is a RegExp
173
- * @param val The value to check
190
+ *
174
191
  * @returns `true` if the value is a RegExp, otherwise `false`
175
192
  */
176
193
  declare const isRegExp: (val: unknown) => val is RegExp;
177
194
  /**
178
195
  * Checks if a value is a Promise
179
- * @param val The value to check
196
+ *
180
197
  * @returns `true` if the value is a Promise, otherwise `false`
181
198
  */
182
199
  declare const isPromise: <T = any>(val: unknown) => val is Promise<T>;
183
200
  /**
184
201
  * Checks if a value is undefined or null
185
- * @param val The value to check
202
+ *
186
203
  * @returns `true` if the value is undefined or null, otherwise `false`
187
204
  */
188
205
  declare const isNil: (val: unknown) => val is undefined | null;
189
206
  /**
190
207
  * Checks if a value is defined (not undefined or null)
191
- * @param val The value to check
208
+ *
192
209
  * @returns `true` if the value is defined, otherwise `false`
193
210
  */
194
211
  declare const isDef: <T>(val: T) => val is NonNullable<T>;
195
212
  /**
196
213
  * Checks if two values are different
197
- * @param oldValue The old value
198
- * @param newValue The new value
214
+ *
199
215
  * @returns `true` if the values are different, otherwise `false`
200
216
  */
201
217
  declare const hasChanged: (oldValue: unknown, newValue: unknown) => boolean;
@@ -221,35 +237,36 @@ declare const hasChanged: (oldValue: unknown, newValue: unknown) => boolean;
221
237
  * @returns True if the object contains circular references, false otherwise
222
238
  *
223
239
  * @throws {Error} When `obj` is not an object
224
- *
225
- * @remarks
226
- * - Supports both plain objects, function objects, and arrays
227
- * - Handles nested objects and mixed object/array structures
228
240
  */
229
241
  declare function hasCircularReference(obj: AnyObject): boolean;
230
242
 
231
243
  /**
232
- * Exclude certain properties from an object
233
- * @param target The target object
234
- * @param properties The properties to exclude
235
- * @module
236
- * @example
244
+ * Creates a new object with specified properties excluded from the original object.
245
+ *
246
+ * This utility removes specific properties from an object and returns a new object
247
+ * containing all other properties. It supports both single property names and arrays
248
+ * of property names, creating a deep clone to prevent reference sharing.
237
249
  *
238
- * omit({ a: 1, b: 2, c: 3 }, 'a') => { b: 2, c: 3 }
250
+ * @example
251
+ * omit({ a: 1, b: 2, c: 3 }, 'a') // => { b: 2, c: 3 }
252
+ * omit({ a: 1, b: 2, c: 3 }, ['a', 'b']) // => { c: 3 }
239
253
  *
240
- * omit({ a: 1, b: 2, c: 3 }, ['a', 'b']) => { c: 3 }
254
+ * @returns Returns a new object without the specified properties
241
255
  */
242
256
  declare function omit<T extends object, K extends keyof T>(target: T, properties: Arrayable<K>): Omit<T, K>;
243
257
 
244
258
  /**
245
- * Extract specific properties from an object
246
- * @param target The target object
247
- * @param properties The properties to extract
248
- * @example
259
+ * Creates a new object with only the specified properties from the original object.
249
260
  *
250
- * pick({ a: 1, b: 2, c: 3 }, 'a') => { a: 1 }
261
+ * This utility extracts specific properties from an object and returns a new object
262
+ * containing only those properties. It supports both single property names and arrays
263
+ * of property names, with optional deep cloning to prevent reference sharing.
251
264
  *
252
- * pick({ a: 1, b: 2, c: 3 }, ['a', 'b']) => { a: 1, b: 2 }
265
+ * @example
266
+ * pick({ a: 1, b: 2, c: 3 }, 'a') // => { a: 1 }
267
+ * pick({ a: 1, b: 2, c: 3 }, ['a', 'b']) // => { a: 1, b: 2 }
268
+ *
269
+ * @returns Returns a new object with only the specified properties
253
270
  */
254
271
  declare function pick<T extends object, K extends keyof T>(target: T, properties: Arrayable<K>, options?: PickOptions): Pick<T, K>;
255
272
  interface PickOptions {
@@ -271,21 +288,53 @@ interface PickOptions {
271
288
  }
272
289
 
273
290
  /**
274
- * Generate random array
275
- * @example generateRandomArray(4, () => 1) => [1, 1, 1, 1]
276
- * */
277
- declare function generateRandomArray<T>(num: number, cb: (item?: unknown, index?: number) => T): T[];
291
+ * Generates an array of specified length with elements created by a callback function.
292
+ *
293
+ * This utility creates an array by calling the provided callback function the specified number of times.
294
+ * Each element in the array is the result of invoking the callback function. The callback is called
295
+ * independently for each element, allowing for dynamic generation of array contents.
296
+ *
297
+ * @example
298
+ * generateRandomArray(4, () => 1) // => [1, 1, 1, 1]
299
+ * generateRandomArray(3, () => Math.random()) // => [0.123, 0.456, 0.789]
300
+ * generateRandomArray(2, () => new Date()) // => [Date, Date]
301
+ *
302
+ * @returns Returns an array of length `num` with elements created by calling `cb`
303
+ *
304
+ * @throws {Error} When `num` is not a non-negative integer
305
+ * @throws {Error} When `cb` is not a function
306
+ */
307
+ declare function generateRandomArray<T>(num: number, cb: () => T): T[];
278
308
 
279
309
  /**
280
- * Generate random color
281
- * @example generateRandomColor() => '#f36a38'
282
- * */
310
+ * Generates a random hex color string in the format '#RRGGBB'.
311
+ *
312
+ * This utility creates a random color by generating a random integer between 0 and 0xFFFFFF,
313
+ * then converting it to a 6-digit hexadecimal string. The result is always a valid CSS color value.
314
+ *
315
+ * @example
316
+ * generateRandomColor() // => '#f36a38'
317
+ * generateRandomColor() // => '#00ffcc'
318
+ * generateRandomColor() // => '#123456'
319
+ *
320
+ * @returns Returns a string representing a random color in hex format, always starting with '#'.
321
+ */
283
322
  declare function generateRandomColor(): string;
284
323
 
285
324
  /**
286
- * Generate random date
287
- * @example generateRandomDate() => '2021-07-01 08:51:34'
288
- * */
325
+ * Generates a random date within a specified time range.
326
+ *
327
+ * This utility creates random dates between start and end boundaries with customizable
328
+ * date formatting. It intelligently handles date validation and ensures the generated
329
+ * date falls within the specified range while respecting calendar constraints.
330
+ *
331
+ * @example
332
+ * generateRandomDate() // => '2021-07-01 08:51:34'
333
+ * generateRandomDate({ start: '2020-01-01' }) // => '2022-03-15 14:23:45'
334
+ * generateRandomDate({ format: 'YYYY-MM-DD' }) // => '2021-11-28'
335
+ *
336
+ * @returns Returns a randomly generated date string in the specified format
337
+ */
289
338
  declare function generateRandomDate(options?: GenerateRandomDate): string;
290
339
  interface GenerateRandomDate {
291
340
  /**
@@ -306,15 +355,35 @@ interface GenerateRandomDate {
306
355
  }
307
356
 
308
357
  /**
309
- * Generate random email
310
- * @example generateRandomEmail() => lZtJqMl0dyTO3WDGzFDO@gmail.com
358
+ * Generates a random email address with realistic formatting.
359
+ *
360
+ * This utility creates random email addresses using common email providers
361
+ * and ensures proper email format validation. The generated emails have
362
+ * random usernames and are selected from a pool of realistic domains.
363
+ *
364
+ * @example
365
+ * generateRandomEmail() // => 'lZtJqMl0dyTO3WDGzFDO@gmail.com'
366
+ * generateRandomEmail() // => 'Kj9mP2xQ@outlook.com.cn'
367
+ * generateRandomEmail() // => 'abc123@qq.com'
368
+ *
369
+ * @returns Returns a randomly generated email address string
311
370
  */
312
371
  declare function generateRandomEmail(): string;
313
372
 
314
373
  /**
315
- * Generate random float number within range
316
- * @example generateRandomFloat() => 0.35
317
- * */
374
+ * Generates a random floating-point number within a specified range.
375
+ *
376
+ * This utility creates random float values between minimum and maximum boundaries
377
+ * with support for precision control. It accepts either a simple maximum value
378
+ * or a configuration object with detailed range and precision settings.
379
+ *
380
+ * @example
381
+ * generateRandomFloat() // => 0.35
382
+ * generateRandomFloat(10) // => 7.23 (between 0 and 10)
383
+ * generateRandomFloat({ min: 1, max: 5 }) // => 3.47 (between 1 and 5)
384
+ *
385
+ * @returns Returns a random floating-point number within the specified range
386
+ */
318
387
  declare function generateRandomFloat(options?: GenerateRandomFloat): number;
319
388
  type GenerateRandomFloat = number | {
320
389
  /**
@@ -335,34 +404,68 @@ type GenerateRandomFloat = number | {
335
404
  };
336
405
 
337
406
  /**
338
- * Generate random Chinese ID card number
339
- * @example generateRandomIdCard() => '410304200210165258'
407
+ * Generates a random Chinese ID card number with valid format.
408
+ *
409
+ * This utility creates random Chinese identity card numbers following the
410
+ * standard 18-digit format. The generated numbers include area codes, birth dates,
411
+ * sequence numbers, and check digits, maintaining the structural validity of real ID numbers.
412
+ *
413
+ * @example
414
+ * generateRandomIdCard() // => '410304200210165258'
415
+ * generateRandomIdCard() // => '11010519901215002X'
416
+ * generateRandomIdCard() // => '330106198512234567'
417
+ *
418
+ * @returns Returns a randomly generated Chinese ID card number string
340
419
  */
341
420
  declare function generateRandomIdCard(): string;
342
421
 
343
422
  /**
344
- * Generate random mobile phone number
345
- * @example generateRandomMobilePhone() => 13012345678
423
+ * Generates a random Chinese mobile phone number with valid prefix.
424
+ *
425
+ * This utility creates random Chinese mobile phone numbers using authentic
426
+ * carrier prefixes (13x, 14x, 15x, 16x, 17x, 18x, 19x) followed by random
427
+ * digits to form complete 11-digit phone numbers.
428
+ *
429
+ * @example
430
+ * generateRandomMobilePhone() // => '13012345678'
431
+ * generateRandomMobilePhone() // => '18598765432'
432
+ * generateRandomMobilePhone() // => '15611223344'
433
+ *
434
+ * @returns Returns a randomly generated Chinese mobile phone number string
346
435
  */
347
436
  declare function generateRandomMobilePhone(): string;
348
437
 
349
438
  /**
350
- * Generate random string from source
351
- * @param num Number of times to randomly get items from source
352
- * @example generateRandomStringFromSource(4, ['1', 'b', 'c', 'd', 'e']) => 'dea1'
353
- * */
439
+ * Generates a random string by selecting characters from a provided source array.
440
+ *
441
+ * This utility creates a string of specified length by randomly selecting items from
442
+ * the source array. Each character in the result is independently chosen, allowing
443
+ * for repetition of characters from the source.
444
+ *
445
+ * @example
446
+ * generateRandomStringFromSource(4, ['1', 'b', 'c', 'd', 'e']) // => 'dea1'
447
+ * generateRandomStringFromSource(6, ['a', 'b', 'c']) // => 'abcabc'
448
+ *
449
+ * @returns Returns a string composed of randomly selected characters from the source
450
+ *
451
+ * @throws {Error} When `num` is not greater than 0
452
+ * @throws {Error} When `source` is not a non-empty array
453
+ */
354
454
  declare function generateRandomStringFromSource(num: number, source: (number | string)[]): string;
355
455
 
356
456
  /**
357
- * Returns a random integer within a specified range.
358
- *
359
- * @example
457
+ * Generates a random integer within a specified range.
360
458
  *
361
- * getRandomInt() => 217342
459
+ * This utility generates random integers with flexible range specification. It accepts
460
+ * either a simple maximum value or an options object with min/max boundaries.
461
+ * The function ensures the generated number is inclusive of both boundaries.
362
462
  *
363
- * getRandomInt(100) => 35
463
+ * @example
464
+ * getRandomInt() // => 217342 (random large integer)
465
+ * getRandomInt(100) // => 35 (between 1 and 100)
466
+ * getRandomInt({ min: 1, max: 100 }) // => 42 (between 1 and 100)
364
467
  *
365
- * getRandomInt({ min: 1, max: 100 }) => 42
468
+ * @returns Returns a random integer within the specified range (inclusive)
366
469
  */
367
470
  declare function getRandomInt(options?: Options$1): number;
368
471
  type Options$1 = {
@@ -384,15 +487,33 @@ type Options$1 = {
384
487
  | number;
385
488
 
386
489
  /**
387
- * Get random item from array
388
- * @example getRandomItem([0, 1, 2, 3, 4]) => 2
490
+ * Selects a random item from an array.
491
+ *
492
+ * This utility randomly picks one element from the provided array using
493
+ * a uniform distribution. Each element has an equal probability of being selected.
494
+ *
495
+ * @example
496
+ * getRandomItem([0, 1, 2, 3, 4]) // => 2
497
+ * getRandomItem(['a', 'b', 'c']) // => 'b'
498
+ * getRandomItem([{ id: 1 }, { id: 2 }]) // => { id: 1 }
499
+ *
500
+ * @returns Returns a randomly selected item from the array
389
501
  */
390
502
  declare function getRandomItem<T>(list: T[]): T;
391
503
 
392
504
  /**
393
- * Returns a random string containing uppercase letters, lowercase letters, numbers, and optionally extra characters.
505
+ * Generates a random string with customizable character sets and length.
506
+ *
507
+ * This utility creates random strings using a combination of uppercase letters,
508
+ * lowercase letters, numbers, and optional extra characters. It supports flexible
509
+ * configuration including length ranges, prefixes, suffixes, and character set customization.
510
+ *
511
+ * @example
512
+ * getRandomString() // => 'lZtJqMl0dyTO3WDG'
513
+ * getRandomString({ length: 8 }) // => 'Kj9mP2xQ'
514
+ * getRandomString({ prefix: 'user_', length: 6 }) // => 'user_Abc123'
394
515
  *
395
- * @example getRandomString() => 'lZtJqMl0dyTO3WDG'
516
+ * @returns Returns a randomly generated string based on the specified options
396
517
  */
397
518
  declare function getRandomString(options?: Options): string;
398
519
  type Options = {
@@ -447,44 +568,109 @@ type Options = {
447
568
  | number;
448
569
 
449
570
  /**
450
- * Returns a random URL string.
571
+ * Generates a random URL string with realistic structure.
572
+ *
573
+ * This utility creates random URLs with authentic components including protocols,
574
+ * domain names, top-level domains, and query parameters. The generated URLs
575
+ * follow standard web address conventions with various parameter combinations.
576
+ *
577
+ * @example
578
+ * getRandomUrl() // => 'https://06hcfsdjubH.cn?name=aB3x'
579
+ * getRandomUrl() // => 'http://mywebsite.com?id=12345'
580
+ * getRandomUrl() // => 'https://example.org?token=a1b2c3d4e5f6g7h8'
451
581
  *
452
- * @example getRandomUrl() => 'https://06hcfsdjubH.cn'
582
+ * @returns Returns a randomly generated URL string
453
583
  */
454
584
  declare function getRandomUrl(): string;
455
585
 
456
586
  /**
457
- * Convert decimal to binary
458
- * @example decimalToBinary(233) => '11101001'
587
+ * Converts a decimal number to its binary representation.
588
+ *
589
+ * This utility transforms a decimal number into a binary string using the standard
590
+ * division-by-2 algorithm. The function uses a stack-based approach to ensure
591
+ * the correct order of binary digits in the result.
592
+ *
593
+ * @example
594
+ * decimalToBinary(233) // => '11101001'
595
+ * decimalToBinary(10) // => '1010'
596
+ * decimalToBinary(0) // => ''
597
+ *
598
+ * @returns Returns the binary representation as a string
459
599
  */
460
600
  declare function decimalToBinary(decNumber: number): string;
461
601
  /**
462
- * Base64 encode
463
- * @example base64Encode('hello') => 'aGVsbG8='
602
+ * Encodes a string to Base64 format.
603
+ *
604
+ * This utility converts a string into its Base64 encoded representation using
605
+ * the standard Base64 character set. The function handles UTF-8 characters
606
+ * and applies proper padding as required by the Base64 specification.
607
+ *
608
+ * @example
609
+ * base64Encode('hello') // => 'aGVsbG8='
610
+ * base64Encode('Hi there!') // => 'SGkgdGhlcmUh'
611
+ * base64Encode('') // => ''
612
+ *
613
+ * @returns Returns the Base64 encoded string
464
614
  */
465
615
  declare function base64Encode(str: string): string;
466
616
  /**
467
- * Base64 decode
468
- * @example base64Decode('aGVsbG8=') => 'hello'
617
+ * Decodes a Base64 encoded string back to its original format.
618
+ *
619
+ * This utility converts a Base64 encoded string back to its original text representation.
620
+ * The function handles standard Base64 padding and properly reconstructs the original
621
+ * characters from the encoded binary data.
622
+ *
623
+ * @example
624
+ * base64Decode('aGVsbG8=') // => 'hello'
625
+ * base64Decode('SGkgdGhlcmUh') // => 'Hi there!'
626
+ * base64Decode('') // => ''
627
+ *
628
+ * @returns Returns the decoded original string
469
629
  */
470
630
  declare function base64Decode(str: string): string;
471
631
 
472
632
  /**
473
- * compose
474
- * @param fns Any functions
633
+ * Composes multiple functions into a single function, executing them from left to right.
634
+ *
635
+ * This utility creates a new function that represents the composition of the provided functions.
636
+ * The output of each function is passed as input to the next function in the sequence.
637
+ *
638
+ * @example
639
+ * const add = (x: number) => x + 1
640
+ * const multiply = (x: number) => x * 2
641
+ * const composed = compose(add, multiply)
642
+ * composed(5) // => 12 (5 + 1 = 6, then 6 * 2 = 12)
643
+ *
644
+ * @returns Returns the composed function
475
645
  */
476
646
  declare function compose(...fns: ((...args: any[]) => any)[]): (...args: any[]) => any;
477
647
  /**
478
- * Compose from right to left
479
- * @param fns Any functions
648
+ * Composes multiple functions into a single function, executing them from right to left.
649
+ *
650
+ * This utility creates a new function that represents the composition of the provided functions
651
+ * in reverse order. The output of each function is passed as input to the previous function.
652
+ *
653
+ * @example
654
+ * const add = (x: number) => x + 1
655
+ * const multiply = (x: number) => x * 2
656
+ * const composed = composeRight(add, multiply)
657
+ * composed(5) // => 11 (5 * 2 = 10, then 10 + 1 = 11)
658
+ *
659
+ * @returns Returns the composed function
480
660
  */
481
661
  declare function composeRight(...fns: ((...args: any[]) => any)[]): (...args: any[]) => any;
482
662
 
483
663
  /**
484
- * Debounce function
485
- * @param target Target function
486
- * @param wait Wait time, default 500ms
487
- * @example debounce(() => console.log('debounce'), 500)
664
+ * Creates a debounced function that delays invoking the provided function until after the specified time period has elapsed since the last time it was called.
665
+ *
666
+ * This utility prevents a function from being called too frequently by delaying its execution.
667
+ * Each new call resets the delay timer, ensuring the function only executes after the specified
668
+ * wait period of inactivity.
669
+ *
670
+ * @example
671
+ * debounce(() => console.log('debounce'), 500)
672
+ *
673
+ * @returns Returns the debounced function
488
674
  */
489
675
  declare function debounce(target: Function, wait?: number): (...args: any[]) => void;
490
676
 
@@ -493,7 +679,7 @@ declare function debounce(target: Function, wait?: number): (...args: any[]) =>
493
679
  *
494
680
  * This utility performs a complete deep copy of the input value, handling complex nested structures,
495
681
  * circular references, and various JavaScript types. It preserves prototype chains, property descriptors,
496
- * and handles special objects like Date, RegExp, Map, Set, and more.
682
+ * Symbol properties, and handles special objects like Date, RegExp, Map, Set, and more.
497
683
  *
498
684
  * @example
499
685
  * deepClone({ name: 'test' }) => { name: 'test' }
@@ -502,19 +688,6 @@ declare function debounce(target: Function, wait?: number): (...args: any[]) =>
502
688
  * deepClone({ user: { name: 'John', data: [1, 2] } }) => { user: { name: 'John', data: [1, 2] } }
503
689
  *
504
690
  * @returns A deep clone of the input value with all nested references copied
505
- *
506
- * @remarks
507
- * - Handles circular references to prevent infinite loops
508
- * - Preserves prototype chains for objects and arrays
509
- * - Maintains property descriptors including getters and setters
510
- * - Supports Symbol properties and Symbol keys
511
- * - Clones Date objects to new Date instances with same time
512
- * - Clones RegExp objects maintaining their behavior
513
- * - Returns Promise objects as-is (promises are not cloned)
514
- * - Recursively clones Map and Set collections including their keys/values
515
- * - Handles non-object-like values (primitives) by returning them directly
516
- * - Preserves array subclass prototypes and custom array-like objects
517
- * - Maintains all property metadata and descriptors
518
691
  */
519
692
  declare function deepClone<T>(target: T): T;
520
693
 
@@ -533,16 +706,6 @@ declare function deepClone<T>(target: T): T;
533
706
  * deepMerge({ data: { x: 1 } }, { data: { y: 2 } }) => { data: { x: 1, y: 2 } }
534
707
  *
535
708
  * @returns A new merged object combining properties from both template and source
536
- *
537
- * @remarks
538
- * - Template object provides default values and structure
539
- * - Source object values override template values for matching keys
540
- * - Nested objects are recursively merged rather than replaced
541
- * - Arrays can be merged or replaced based on mergeStrategy option
542
- * - Property descriptors (getters, setters, etc.) are preserved
543
- * - Deep cloning is enabled by default to prevent original object mutation
544
- * - Non-plain objects in source will replace corresponding template values
545
- * - Supports Symbol properties and maintains prototype relationships
546
709
  */
547
710
  declare function deepMerge(template: AnyObject, source: AnyObject, options?: DeepMergeOptions): any;
548
711
  interface DeepMergeOptions {
@@ -570,21 +733,57 @@ interface DeepMergeOptions {
570
733
  mergeStrategy?: 'merge' | 'replace';
571
734
  }
572
735
 
736
+ /**
737
+ * Custom error class for utility functions.
738
+ *
739
+ * This error class extends the native Error class and provides a consistent
740
+ * way to throw errors with a specific scope or context name.
741
+ */
573
742
  declare class UtilsError extends Error {
574
743
  constructor(m: string, name?: string);
575
744
  }
745
+ /**
746
+ * Throws a formatted error with scope information.
747
+ *
748
+ * This utility creates and throws a UtilsError with a formatted message
749
+ * that includes the scope context for better debugging and error tracking.
750
+ *
751
+ * @example
752
+ * throwError('validation', 'Invalid input') // throws Error: [validation] Invalid input
753
+ *
754
+ * @throws {UtilsError} Always throws an error with the formatted message
755
+ */
576
756
  declare function throwError(scope: string, message: string): void;
757
+ /**
758
+ * Logs a warning message to the console.
759
+ *
760
+ * This utility function provides a flexible way to log warnings, accepting either
761
+ * an Error object directly or scope and message parameters to create a warning.
762
+ * It outputs the warning to the console for debugging purposes.
763
+ *
764
+ * @example
765
+ * debugWarn('validation', 'Deprecated API usage')
766
+ * debugWarn(new Error('Something went wrong'))
767
+ *
768
+ * @returns No return value - outputs warning to console
769
+ */
577
770
  declare function debugWarn(err: Error): void;
578
771
  declare function debugWarn(scope: string, message: string): void;
579
- declare const deprecated: ({ from, replacement, version, type, }: {
580
- from: string;
581
- replacement: string;
582
- version: string;
583
- type?: "API";
584
- }) => void;
585
- declare function throwErrorInvalidTypeMessage(scope: string, key: string, type: string, value: unknown): void;
586
- declare function debugWarnInvalidTypeMessage(scope: string, key: string, type: string, value: unknown): void;
587
772
 
773
+ /**
774
+ * Logs informational messages with consistent formatting.
775
+ *
776
+ * This utility provides a standardized logging interface that formats messages
777
+ * with a '[Log]' prefix and the provided name. Supports multiple arguments
778
+ * that will be displayed as context information.
779
+ *
780
+ * @example
781
+ * log('API', 'Request completed')
782
+ * log('User', { id: 1, name: 'John' })
783
+ * log('Debug', 'value1', 'value2', { extra: 'data' })
784
+ *
785
+ * @returns No return value - outputs directly to console
786
+ */
588
787
  declare const log: {
589
788
  (name: unknown, ...arg: unknown[]): void;
590
789
  info(name: unknown, ...arg: unknown[]): void;
@@ -643,16 +842,6 @@ declare global {
643
842
  * @throws {Error} When `encodeDotInKeys` is not a boolean
644
843
  * @throws {Error} When `commaRoundTrip` is not a boolean
645
844
  * @throws {Error} When `allowEmptyArrays` is not a boolean
646
- *
647
- * @remarks
648
- * - Supports nested objects and arrays with configurable formatting
649
- * - Handles null, undefined, and empty values according to specified options
650
- * - Provides multiple array serialization formats (indices, brackets, comma)
651
- * - Supports both bracket notation and dot notation for nested objects
652
- * - Uses standard URL encoding with configurable key/value encoding options
653
- * - Returns empty string for non-object inputs
654
- * - Preserves key order from the original object
655
- * - Supports custom delimiters and query prefixes
656
845
  */
657
846
  declare function qsStringify(obj: AnyObject, options?: StringifyOptions): string;
658
847
  interface StringifyOptions {
@@ -784,10 +973,6 @@ declare const qs: {
784
973
  * @returns A URL-encoded query string
785
974
  *
786
975
  * @throws {Error} When `obj` is not an object
787
- *
788
- * @remarks
789
- * - Uses native URLSearchParams for encoding
790
- * - Only supports flat objects (no nested structures)
791
976
  */
792
977
  stringify: (obj: AnyObject) => string;
793
978
  /**
@@ -811,12 +996,6 @@ declare const qs: {
811
996
  * @returns A plain object containing the parsed key-value pairs as strings
812
997
  *
813
998
  * @throws {Error} When `str` is not a string
814
- *
815
- * @remarks
816
- * - Uses native URLSearchParams for parsing and decoding
817
- * - All values are returned as strings (no automatic type conversion)
818
- * - Handles standard URL encoding/decoding automatically
819
- * - Does not support nested objects or arrays
820
999
  */
821
1000
  parse: (str: string) => {
822
1001
  [k: string]: string;
@@ -845,41 +1024,24 @@ declare const qs: {
845
1024
  *
846
1025
  * @throws {Error} When `url` is not a string
847
1026
  * @throws {Error} When `obj` is not an object
848
- *
849
- * @remarks
850
- * - Automatically detects existing query strings and uses appropriate separators
851
- * - Handles edge cases like trailing '?' or '&' characters
852
- * - Preserves existing query parameters in the URL
853
- * - Uses the same encoding rules as the stringify method
854
1027
  */
855
1028
  appendQueryString: (url: string, obj: AnyObject) => string;
856
1029
  };
857
1030
 
858
1031
  /**
859
- * Throttle function
860
- * @param target Target function
861
- * @param wait Wait time, default 500ms
862
- * @example throttle(() => console.log('hello world'), 500)
1032
+ * Creates a throttled function that only invokes the provided function at most once per specified time period.
1033
+ *
1034
+ * This utility limits the rate at which a function can fire. When the throttled function is called,
1035
+ * it will invoke the original function immediately if it hasn't been called within the wait period.
1036
+ * Subsequent calls within the wait period are ignored until the period expires.
1037
+ *
1038
+ * @example
1039
+ * throttle(() => console.log('hello world'), 500)
1040
+ *
1041
+ * @returns Returns the throttled function
863
1042
  */
864
1043
  declare function throttle(target: Function, wait?: number): (...args: any[]) => any;
865
1044
 
866
- /**
867
- * Validates Chinese characters, letters, and digits
868
- */
869
- declare function validatorChineseOrEnglishOrNumber(value: string): boolean;
870
- /**
871
- * Validates Chinese characters and English letters
872
- */
873
- declare function validatorChineseOrEnglish(value: string): boolean;
874
- /**
875
- * Validates uppercase letters, digits, and special characters including !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
876
- */
877
- declare function validatorUppercaseOrNumbersOrSpecial(value: string): boolean;
878
- /**
879
- * Validates uppercase letters, digits, and underscore
880
- */
881
- declare function validatorUppercaseOrNumbersOrUnderline(value: string): boolean;
882
-
883
1045
  /**
884
1046
  * Executes an asynchronous function with retry logic.
885
1047
  *
@@ -921,15 +1083,6 @@ declare function validatorUppercaseOrNumbersOrUnderline(value: string): boolean;
921
1083
  * @throws {Error} When `signal` is not an AbortSignal object
922
1084
  * @throws {Promise rejection Error} "Operation Cancelled" when the operation is aborted via AbortSignal
923
1085
  * @throws {Promise rejection any} The original error from `fn` when all retry attempts are exhausted
924
- *
925
- * @remarks
926
- * - Uses exponential backoff when enabled: delay × 2^(attempt-1)
927
- * - Supports cancellation via AbortSignal at any point during execution
928
- * - Logs retry attempts for debugging purposes
929
- * - Validates all input parameters and throws descriptive errors
930
- * - Cleans up event listeners to prevent memory leaks
931
- * - Returns immediately on first successful execution
932
- * - Preserves the original error when all retries fail
933
1086
  */
934
1087
  declare function withRetry<T>(options: WithRetryOptions<T>): Promise<T>;
935
1088
  interface WithRetryOptions<T> {
@@ -977,49 +1130,6 @@ interface WithRetryOptions<T> {
977
1130
  signal?: AbortSignal;
978
1131
  }
979
1132
 
980
- /**
981
- * Validates if the value contains only digits
982
- */
983
- declare function isNumberOrNumberString(val: string): boolean;
984
- /**
985
- * Validates if the value contains only English letters
986
- */
987
- declare function isEnglishAphabet(val: string): boolean;
988
- /**
989
- * Validates if the value contains only uppercase letters
990
- */
991
- declare function isUpperCase(val: string): boolean;
992
- /**
993
- * Validates if the value contains only uppercase letters and digits
994
- */
995
- declare function isUpperCaseAndNumber(val: string): boolean;
996
- /**
997
- * Validates if the value contains only uppercase letters, digits and Chinese characters
998
- */
999
- declare function isUpperCaseAndNumberAndChinese(val: string): boolean;
1000
- /**
1001
- * Validates if the value contains only lowercase letters
1002
- */
1003
- declare function isLowerCase(val: string): boolean;
1004
- /**
1005
- * Validates if the value contains only lowercase letters and digits
1006
- */
1007
- declare function isLowerCaseAndNumber(val: string): boolean;
1008
- /**
1009
- * Validates if the value contains only lowercase letters, digits and Chinese characters
1010
- */
1011
- declare function isLowerCaseAndNumberAndChinese(val: string): boolean;
1012
- /**
1013
- * Validates whether the value is a Chinese string.
1014
- *
1015
- * @example
1016
- *
1017
- * isChineseString('你好') => true
1018
- *
1019
- * isChineseString('hello') => false
1020
- */
1021
- declare function isChineseString(val: string): boolean;
1022
-
1023
1133
  /**
1024
1134
  * Validates whether a string represents a valid float number.
1025
1135
  *
@@ -1038,14 +1148,6 @@ declare function isChineseString(val: string): boolean;
1038
1148
  * isFloat('abc') => false (non-numeric)
1039
1149
  *
1040
1150
  * @returns Returns `true` if the string is a valid float, `false` otherwise
1041
- *
1042
- * @remarks
1043
- * - Accepts positive floats (e.g., "1.23", "999.5")
1044
- * - Accepts negative floats (e.g., "-1.23", "-999.5")
1045
- * - Accepts zero with decimal point (e.g., "0.0", "-0.0")
1046
- * - Rejects integers without decimal point (e.g., "7", "-7")
1047
- * - Rejects numbers with no digits after decimal (e.g., "1.", "-2.")
1048
- * - Rejects non-numeric strings (e.g., "abc", "1.2a")
1049
1151
  */
1050
1152
  declare function isFloat(val: string): boolean;
1051
1153
  /**
@@ -1065,13 +1167,6 @@ declare function isFloat(val: string): boolean;
1065
1167
  * isPositiveFloat('7') => false (integer)
1066
1168
  *
1067
1169
  * @returns Returns `true` if the string is a positive float, `false` otherwise
1068
- *
1069
- * @remarks
1070
- * - Accepts only positive floats greater than zero (e.g., "1.23", "0.5")
1071
- * - Rejects zero with decimal point (e.g., "0.0", "0.00")
1072
- * - Rejects negative floats (e.g., "-1.23", "-0.5")
1073
- * - Rejects integers (e.g., "7", "-7")
1074
- * - Rejects non-numeric strings (e.g., "abc", "1.2a")
1075
1170
  */
1076
1171
  declare function isPositiveFloat(val: string): boolean;
1077
1172
  /**
@@ -1091,13 +1186,6 @@ declare function isPositiveFloat(val: string): boolean;
1091
1186
  * isNonNegativeFloat('abc') => false (non-numeric)
1092
1187
  *
1093
1188
  * @returns Returns `true` if the string is a non-negative float, `false` otherwise
1094
- *
1095
- * @remarks
1096
- * - Accepts zero with decimal point (e.g., "0.0", "0.00")
1097
- * - Accepts positive floats (e.g., "1.23", "999.5")
1098
- * - Rejects negative floats (e.g., "-1.23", "-0.5")
1099
- * - Rejects integers without decimal point (e.g., "7", "0")
1100
- * - Rejects non-numeric strings (e.g., "abc", "1.2a")
1101
1189
  */
1102
1190
  declare function isNonNegativeFloat(val: string): boolean;
1103
1191
  /**
@@ -1117,13 +1205,6 @@ declare function isNonNegativeFloat(val: string): boolean;
1117
1205
  * isNegativeFloat('-7') => false (integer)
1118
1206
  *
1119
1207
  * @returns Returns `true` if the string is a negative float, `false` otherwise
1120
- *
1121
- * @remarks
1122
- * - Accepts only negative floats less than zero (e.g., "-1.23", "-0.5")
1123
- * - Rejects zero with decimal point (e.g., "0.0", "-0.0")
1124
- * - Rejects positive floats (e.g., "1.23", "0.5")
1125
- * - Rejects integers (e.g., "-7", "7")
1126
- * - Rejects non-numeric strings (e.g., "abc", "-1.2a")
1127
1208
  */
1128
1209
  declare function isNegativeFloat(val: string): boolean;
1129
1210
  /**
@@ -1143,13 +1224,6 @@ declare function isNegativeFloat(val: string): boolean;
1143
1224
  * isNonPositiveFloat('abc') => false (non-numeric)
1144
1225
  *
1145
1226
  * @returns Returns `true` if the string is a non-positive float, `false` otherwise
1146
- *
1147
- * @remarks
1148
- * - Accepts zero with decimal point (e.g., "0.0", "-0.0")
1149
- * - Accepts negative floats (e.g., "-1.23", "-999.5")
1150
- * - Rejects positive floats (e.g., "1.23", "0.5")
1151
- * - Rejects integers without decimal point (e.g., "-7", "0")
1152
- * - Rejects non-numeric strings (e.g., "abc", "-1.2a")
1153
1227
  */
1154
1228
  declare function isNonPositiveFloat(val: string): boolean;
1155
1229
 
@@ -1171,14 +1245,6 @@ declare function isNonPositiveFloat(val: string): boolean;
1171
1245
  * isInteger('abc') => false (non-numeric)
1172
1246
  *
1173
1247
  * @returns Returns `true` if the string is a valid integer, `false` otherwise
1174
- *
1175
- * @remarks
1176
- * - Accepts positive integers (e.g., "1", "123", "999")
1177
- * - Accepts negative integers (e.g., "-1", "-123", "-999")
1178
- * - Accepts zero as "0"
1179
- * - Rejects decimal numbers (e.g., "1.5", "-2.3")
1180
- * - Rejects numbers with leading zeros (e.g., "01", "-02")
1181
- * - Rejects non-numeric strings (e.g., "abc", "12a")
1182
1248
  */
1183
1249
  declare function isInteger(val: string): boolean;
1184
1250
  /**
@@ -1198,14 +1264,6 @@ declare function isInteger(val: string): boolean;
1198
1264
  * isPositiveInteger('1.5') => false (decimal)
1199
1265
  *
1200
1266
  * @returns Returns `true` if the string is a positive integer, `false` otherwise
1201
- *
1202
- * @remarks
1203
- * - Accepts only positive integers greater than zero (e.g., "1", "123", "999")
1204
- * - Rejects zero ("0")
1205
- * - Rejects negative integers (e.g., "-1", "-123")
1206
- * - Rejects decimal numbers (e.g., "1.5", "2.0")
1207
- * - Rejects numbers with leading zeros (e.g., "01", "02")
1208
- * - Rejects non-numeric strings (e.g., "abc", "12a")
1209
1267
  */
1210
1268
  declare function isPositiveInteger(val: string): boolean;
1211
1269
  /**
@@ -1225,15 +1283,6 @@ declare function isPositiveInteger(val: string): boolean;
1225
1283
  * isNonNegativeInteger('01') => false (leading zero)
1226
1284
  *
1227
1285
  * @returns Returns `true` if the string is a non-negative integer, `false` otherwise
1228
- *
1229
- * @remarks
1230
- * - Accepts zero ("0")
1231
- * - Accepts positive integers (e.g., "1", "123", "999")
1232
- * - Rejects negative integers (e.g., "-1", "-123")
1233
- * - Rejects decimal numbers (e.g., "1.5", "-2.3")
1234
- * - Rejects numbers with leading zeros (e.g., "01", "02")
1235
- * - Handles negative zero (-0) correctly by rejecting it
1236
- * - Rejects non-numeric strings (e.g., "abc", "12a")
1237
1286
  */
1238
1287
  declare function isNonNegativeInteger(val: string): boolean;
1239
1288
  /**
@@ -1253,14 +1302,6 @@ declare function isNonNegativeInteger(val: string): boolean;
1253
1302
  * isNegativeInteger('-1.5') => false (decimal)
1254
1303
  *
1255
1304
  * @returns Returns `true` if the string is a negative integer, `false` otherwise
1256
- *
1257
- * @remarks
1258
- * - Accepts only negative integers less than zero (e.g., "-1", "-123", "-999")
1259
- * - Rejects zero ("0")
1260
- * - Rejects positive integers (e.g., "1", "123")
1261
- * - Rejects decimal numbers (e.g., "-1.5", "2.3")
1262
- * - Rejects numbers with leading zeros (e.g., "-01", "-02")
1263
- * - Rejects non-numeric strings (e.g., "abc", "-12a")
1264
1305
  */
1265
1306
  declare function isNegativeInteger(val: string): boolean;
1266
1307
  /**
@@ -1280,96 +1321,160 @@ declare function isNegativeInteger(val: string): boolean;
1280
1321
  * isNonPositiveInteger('-01') => false (leading zero)
1281
1322
  *
1282
1323
  * @returns Returns `true` if the string is a non-positive integer, `false` otherwise
1283
- *
1284
- * @remarks
1285
- * - Accepts zero ("0")
1286
- * - Accepts negative integers (e.g., "-1", "-123", "-999")
1287
- * - Rejects positive integers (e.g., "1", "123")
1288
- * - Rejects decimal numbers (e.g., "-1.5", "2.3")
1289
- * - Rejects numbers with leading zeros (e.g., "-01", "-02")
1290
- * - Handles negative zero (-0) correctly by accepting it
1291
- * - Rejects non-numeric strings (e.g., "abc", "-12a")
1292
1324
  */
1293
1325
  declare function isNonPositiveInteger(val: string): boolean;
1294
1326
 
1295
1327
  /**
1296
- * Checks if a string represents a valid standard decimal number.
1328
+ * Validates whether a string represents a valid date in the specified format.
1297
1329
  *
1298
- * This utility validates whether the input string matches standard decimal number format.
1299
- * It uses strict regex pattern matching to ensure only valid decimal numbers are accepted.
1300
- * The function also ensures the number is within JavaScript's safe integer range.
1330
+ * This utility uses Day.js library with strict parsing mode to validate date strings
1331
+ * against a given format. It ensures the date string exactly matches the format
1332
+ * and represents a valid calendar date.
1301
1333
  *
1302
1334
  * @example
1303
- * isStringNumber('123') // true
1304
- * isStringNumber('-45.67') // true
1305
- * isStringNumber('0') // true
1335
+ * isDateString('2023-01-01 12:30:45') // => true
1336
+ * isDateString('2024-02-29 00:00:00') // => true (leap year)
1337
+ * isDateString('2023-06-15', 'YYYY-MM-DD') // => true
1306
1338
  *
1307
1339
  * @example
1308
- * isStringNumber('.5') // false (must start with digit)
1309
- * isStringNumber('123.') // false (must not end with dot)
1310
- * isStringNumber(' 42 ') // false (contains spaces)
1311
- * isStringNumber('1e5') // false (scientific notation)
1312
- * isStringNumber('0xFF') // false (hexadecimal)
1313
- * isStringNumber('abc') // false (non-numeric)
1314
- * isStringNumber('') // false (empty)
1340
+ * isDateString('2023-13-01 00:00:00') // => false (invalid month)
1341
+ * isDateString('2023-02-30 00:00:00') // => false (invalid date)
1342
+ * isDateString('2023/01/01 12:30:45') // => false (wrong format)
1315
1343
  *
1316
- * @returns Returns `true` if the string is a valid standard decimal number, `false` otherwise
1344
+ * @returns Returns `true` if the string is a valid date in the specified format, `false` otherwise
1317
1345
  *
1318
- * @remarks
1319
- * - Only accepts standard decimal format: digits with optional decimal point
1320
- * - Must start with a digit (optionally preceded by minus sign)
1321
- * - If decimal point is present, must be followed by at least one digit
1322
- * - Does not accept strings with leading or trailing whitespace
1323
- * - Returns `false` for empty strings
1324
- * - Ensures the number is within JavaScript's safe integer range
1325
- * - Returns `false` for non-string inputs
1346
+ * @see https://day.js.org/docs/en/parse/string-format
1326
1347
  */
1327
- declare const isStringNumber: (val: string) => boolean;
1348
+ declare function isDateString(val: string, format?: string): boolean;
1328
1349
 
1329
1350
  /**
1330
- * Validates whether the value is a mobile phone number.
1351
+ * Validates whether a string represents a valid email address.
1352
+ *
1353
+ * This utility checks if the input string matches a valid email address format
1354
+ * using a comprehensive regex pattern. It validates both the local part (before @)
1355
+ * and the domain part (after @) according to standard email formatting rules.
1331
1356
  *
1332
1357
  * @example
1358
+ * isEmail('test@example.com') // => true
1359
+ * isEmail('user+tag@domain.org') // => true
1360
+ * isEmail('name.surname@company.co.uk') // => true
1333
1361
  *
1334
- * isMobilePhone('13912345678') => true
1362
+ * @example
1363
+ * isEmail('invalid@') // => false (missing domain)
1364
+ * isEmail('@example.com') // => false (missing local part)
1365
+ * isEmail('test@.com') // => false (invalid domain format)
1335
1366
  *
1336
- * isMobilePhone('1381234567') => false
1367
+ * @returns Returns `true` if the string is a valid email address, `false` otherwise
1337
1368
  */
1338
- declare function isMobilePhone(val: string): boolean;
1369
+ declare function isEmail(val: string): boolean;
1370
+
1339
1371
  /**
1340
- * Validates whether the value is a URL.
1372
+ * Validates whether a value is an empty string.
1373
+ *
1374
+ * This utility performs a strict equality check to determine if the input value
1375
+ * is exactly an empty string (''), excluding other falsy values like null, undefined,
1376
+ * or whitespace-only strings.
1341
1377
  *
1342
1378
  * @example
1379
+ * isEmptyString('') // => true
1343
1380
  *
1344
- * isURL('https://example.com') => true
1381
+ * @example
1382
+ * isEmptyString(' ') // => false (whitespace)
1383
+ * isEmptyString(null) // => false (null value)
1384
+ * isEmptyString(undefined) // => false (undefined value)
1385
+ * isEmptyString(0) // => false (number zero)
1345
1386
  *
1346
- * isURL('htt://321') => false
1387
+ * @returns Returns `true` if the value is exactly an empty string, `false` otherwise
1347
1388
  */
1348
- declare function isURL(val: string): boolean;
1389
+ declare function isEmptyString(val: unknown): val is "";
1390
+
1349
1391
  /**
1350
- * Validates whether the value is an email address.
1392
+ * Validates whether a string represents a valid Chinese ID card number.
1393
+ *
1394
+ * This utility validates Chinese national identification numbers (18 digits) by checking
1395
+ * both the format pattern and the embedded date validity. It verifies the administrative
1396
+ * division code, birth date format, and ensures the birth date is in the past.
1351
1397
  *
1352
1398
  * @example
1399
+ * isIdCard('11010519491231002X') // => true
1400
+ * isIdCard('110105194912310021') // => true
1401
+ * isIdCard('320102198001010011') // => true
1353
1402
  *
1354
- * isEmail('test@example.com') => true
1403
+ * @example
1404
+ * isIdCard('01010519491231002X') // => false (invalid admin code)
1405
+ * isIdCard('11010519491231002') // => false (incorrect length)
1406
+ * isIdCard('110105199202300021') // => false (invalid date - Feb 30th)
1355
1407
  *
1356
- * isEmail('invalid@') => false
1408
+ * @returns Returns `true` if the string is a valid Chinese ID card number, `false` otherwise
1357
1409
  */
1358
- declare function isEmail(val: string): boolean;
1410
+ declare function isIdCard(val: string): boolean;
1411
+
1359
1412
  /**
1360
- * Validates whether the value is a empty string.
1413
+ * Validates whether a string represents a valid Chinese mobile phone number.
1414
+ *
1415
+ * This utility checks if the input string matches the Chinese mobile phone number format,
1416
+ * which must start with 1 followed by a digit from 3-9, and contain exactly 11 digits total.
1417
+ * It supports all major Chinese carriers including China Mobile, China Unicom, and China Telecom.
1418
+ *
1419
+ * @example
1420
+ * isMobilePhone('13912345678') // => true
1421
+ * isMobilePhone('16600001111') // => true
1422
+ * isMobilePhone('19955556666') // => true
1423
+ *
1424
+ * @example
1425
+ * isMobilePhone('1381234567') // => false (too short)
1426
+ * isMobilePhone('22345678901') // => false (invalid prefix)
1427
+ * isMobilePhone('138-1234-5678') // => false (contains separators)
1428
+ *
1429
+ * @returns Returns `true` if the string is a valid Chinese mobile phone number, `false` otherwise
1430
+ *
1361
1431
  */
1362
- declare function isEmptyString(val: unknown): val is "";
1432
+ declare function isMobilePhone(val: string): boolean;
1433
+
1363
1434
  /**
1364
- * Validates if the value is a valid date string
1365
- * @param format Date format
1366
- * @default 'YYYY-MM-DD HH:mm:ss'
1367
- * @see https://day.js.org/docs/zh-CN/parse/string-format
1435
+ * Checks if a string represents a valid standard decimal number.
1436
+ *
1437
+ * This utility validates whether the input string matches standard decimal number format.
1438
+ * It uses strict regex pattern matching to ensure only valid decimal numbers are accepted.
1439
+ * The function also ensures the number is within JavaScript's safe integer range.
1440
+ *
1441
+ * @example
1442
+ * isStringNumber('123') // true
1443
+ * isStringNumber('-13.67') // true
1444
+ * isStringNumber('0') // true
1445
+ *
1446
+ * @example
1447
+ * isStringNumber('.5') // false (must start with digit)
1448
+ * isStringNumber('123.') // false (must not end with dot)
1449
+ * isStringNumber(' 42 ') // false (contains spaces)
1450
+ * isStringNumber('1e5') // false (scientific notation)
1451
+ * isStringNumber('0xFF') // false (hexadecimal)
1452
+ * isStringNumber('abc') // false (non-numeric)
1453
+ * isStringNumber('') // false (empty)
1454
+ *
1455
+ * @returns Returns `true` if the string is a valid standard decimal number, `false` otherwise
1368
1456
  */
1369
- declare function isDateString(val: string, format?: string): boolean;
1457
+ declare const isStringNumber: (val: string) => boolean;
1458
+
1370
1459
  /**
1371
- * Validates if the value is a valid Chinese ID card number
1460
+ * Validates whether a string represents a valid URL.
1461
+ *
1462
+ * This utility checks if the input string matches a valid HTTP or HTTPS URL format.
1463
+ * It uses a strict validation pattern that requires a proper protocol and domain structure.
1464
+ * The validation is case-insensitive and supports various URL components like paths, queries, and ports.
1465
+ *
1466
+ * @example
1467
+ * isURL('https://example.com') // => true
1468
+ * isURL('https://t-example.com:10086') // => true
1469
+ * isURL('https://www.example.com/path?query=param') // => true
1470
+ *
1471
+ * @example
1472
+ * isURL('ftp://example.com') // => false (unsupported protocol)
1473
+ * isURL('example.com') // => false (missing protocol)
1474
+ * isURL('https://') // => false (missing domain)
1475
+ *
1476
+ * @returns Returns `true` if the string is a valid HTTP/HTTPS URL, `false` otherwise
1372
1477
  */
1373
- declare function isIdCard(val: string): boolean;
1478
+ declare function isURL(val: string): boolean;
1374
1479
 
1375
- export { type AnyObject, type ArrayItem, type Arrayable, type DeepMergeOptions, type PlainObject, type StringNumber, type StringifyOptions, UtilsError, type WithRetryOptions, base64Decode, base64Encode, castArray, compose, composeRight, debounce, debugWarn, debugWarnInvalidTypeMessage, decimalToBinary, deepClone, deepMerge, deprecated, generateRandomArray, generateRandomColor, generateRandomDate, generateRandomEmail, generateRandomFloat, generateRandomIdCard, generateRandomMobilePhone, generateRandomStringFromSource, getRandomInt, getRandomItem, getRandomString, getRandomUrl, hasChanged, hasCircularReference, isArray, isBoolean, isChineseString, isDate, isDateString, isDef, isEmail, isEmptyString, isEnglishAphabet, isFloat, isFunction, isIdCard, isInteger, isLowerCase, isLowerCaseAndNumber, isLowerCaseAndNumberAndChinese, isMap, isMobilePhone, isNegativeFloat, isNegativeInteger, isNil, isNonNegativeFloat, isNonNegativeInteger, isNonPositiveFloat, isNonPositiveInteger, isNull, isNumber, isNumberOrNumberString, isObject, isObjectLike, isPlainObject, isPositiveFloat, isPositiveInteger, isPromise, isRegExp, isSet, isString, isStringNumber, isSymbol, isURL, isUndef, isUpperCase, isUpperCaseAndNumber, isUpperCaseAndNumberAndChinese, objectToString, omit, pick, qs, qsStringify, throttle, throwError, throwErrorInvalidTypeMessage, toTypeString, toTypeValue, validatorChineseOrEnglish, validatorChineseOrEnglishOrNumber, validatorUppercaseOrNumbersOrSpecial, validatorUppercaseOrNumbersOrUnderline, withRetry };
1480
+ export { type AnyObject, type ArrayItem, type Arrayable, type DeepMergeOptions, type PlainObject, type StringNumber, type StringifyOptions, UtilsError, type WithRetryOptions, base64Decode, base64Encode, castArray, compose, composeRight, debounce, debugWarn, decimalToBinary, deepClone, deepMerge, generateRandomArray, generateRandomColor, generateRandomDate, generateRandomEmail, generateRandomFloat, generateRandomIdCard, generateRandomMobilePhone, generateRandomStringFromSource, getRandomInt, getRandomItem, getRandomString, getRandomUrl, hasChanged, hasCircularReference, isArray, isBoolean, isDate, isDateString, isDef, isEmail, isEmptyString, isFloat, isFunction, isIdCard, isInteger, isMap, isMobilePhone, isNegativeFloat, isNegativeInteger, isNil, isNonNegativeFloat, isNonNegativeInteger, isNonPositiveFloat, isNonPositiveInteger, isNull, isNumber, isObject, isObjectLike, isPlainObject, isPositiveFloat, isPositiveInteger, isPromise, isRegExp, isSet, isString, isStringNumber, isSymbol, isURL, isUndef, objectToString, omit, pick, qs, qsStringify, throttle, throwError, toTypeString, toTypeValue, withRetry };