mazey 3.11.1 → 3.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -9,13 +9,14 @@ import { BrowserInfo, DefineListeners, ThrottleFunc, DebounceFunc, IsNumberOptio
9
9
  *
10
10
  * Usage:
11
11
  *
12
- * ```
13
- * longestComSubstring('fish', 'finish');
12
+ * ```javascript
13
+ * const ret = longestComSubstring('fish', 'finish');
14
+ * console.log(ret);
14
15
  * ```
15
16
  *
16
17
  * Output:
17
18
  *
18
- * ```
19
+ * ```text
19
20
  * 3
20
21
  * ```
21
22
  *
@@ -38,13 +39,14 @@ export declare function calLongestCommonSubstring(aStr: string, bStr: string): n
38
39
  *
39
40
  * Usage:
40
41
  *
41
- * ```
42
- * longestComSubsequence('fish', 'finish');
42
+ * ```javascript
43
+ * const ret = longestComSubsequence('fish', 'finish');
44
+ * console.log(ret);
43
45
  * ```
44
46
  *
45
47
  * Output:
46
48
  *
47
- * ```
49
+ * ```text
48
50
  * 4
49
51
  * ```
50
52
  *
@@ -63,11 +65,20 @@ export declare function calLongestCommonSubsequence(aStr: string, bStr: string):
63
65
  /**
64
66
  * Get the query param's value of the current Web URL(`location.search`).
65
67
  *
66
- * ```
68
+ * Usage:
69
+ *
70
+ * ```javascript
67
71
  * // http://example.com/?t1=1&t2=2&t3=3&t4=4#2333
68
72
  * // ?t1=1&t2=2&t3=3&t4=4
69
- * getQueryParam('t3'); // 3
70
- * getQueryParam('t4'); // 4
73
+ * const p1 = getQueryParam('t3');
74
+ * const p2 = getQueryParam('t4');
75
+ * console.log(p1, p2);
76
+ * ```
77
+ *
78
+ * Output:
79
+ *
80
+ * ```text
81
+ * 3 4
71
82
  * ```
72
83
  *
73
84
  * @param {string} param Query param.
@@ -78,10 +89,18 @@ export declare function getQueryParam(param: string): string;
78
89
  /**
79
90
  * Returns the value of the specified query parameter in the input URL.
80
91
  *
81
- * @example
92
+ * Usage:
93
+ *
94
+ * ```javascript
95
+ * const p1 = getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3');
96
+ * const p2 = getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4');
97
+ * console.log(p1, p2);
82
98
  * ```
83
- * getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3'); // Returns '3'
84
- * getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4'); // Returns '4'
99
+ *
100
+ * Output:
101
+ *
102
+ * ```text
103
+ * 3 4
85
104
  * ```
86
105
  *
87
106
  * @param {string} url The URL string.
@@ -95,14 +114,16 @@ export declare function getUrlParam(url: string, param: string): string | string
95
114
  *
96
115
  * Usage:
97
116
  *
98
- * ```
99
- * updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3', 'three');
100
- * updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4', 'four');
117
+ * ```javascript
118
+ * const ret1 = updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3', 'three');
119
+ * const ret2 = updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4', 'four');
120
+ * console.log(ret1);
121
+ * console.log(ret2);
101
122
  * ```
102
123
  *
103
124
  * Output:
104
125
  *
105
- * ```
126
+ * ```text
106
127
  * http://example.com/?t1=1&t2=2&t3=three&t4=4
107
128
  * http://example.com/?t1=1&t2=2&t3=3&t4=four
108
129
  * ```
@@ -119,18 +140,18 @@ export declare function updateQueryParam(url: string, param: string, value: stri
119
140
  *
120
141
  * Usage:
121
142
  *
122
- * ```
143
+ * ```javascript
123
144
  * // http://example.com/?#2333?t1=1&t2=2&t3=3&t4=4
124
145
  * // #2333?t1=1&t2=2&t3=3&t4=4
125
- * getHashQueryParam('t3');
126
- * getHashQueryParam('t4');
146
+ * const p1 = getHashQueryParam('t3');
147
+ * const p2 = getHashQueryParam('t4');
148
+ * console.log(p1, p2);
127
149
  * ```
128
150
  *
129
151
  * Output:
130
152
  *
131
- * ```
132
- * 3
133
- * 4
153
+ * ```text
154
+ * 3 4
134
155
  * ```
135
156
  *
136
157
  * @param {string} param Query param.
@@ -143,18 +164,24 @@ export declare function getHashQueryParam(param: string): string;
143
164
  *
144
165
  * Usage:
145
166
  *
146
- * ```
147
- * getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4');
148
- * getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']);
149
- * getDomain('http://example.com:7890/test/thanks', ['hostname']);
150
- * getDomain('http://example.com:7890/test/thanks', ['host']); // With Port
151
- * getDomain('http://example.com:7890/test/thanks', ['origin']);
152
- * getDomain('http://example.com:7890/test/thanks?id=1', ['origin', 'pathname', 'search']);
167
+ * ```javascript
168
+ * const ret1 = getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4');
169
+ * const ret2 = getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']);
170
+ * const ret3 = getDomain('http://example.com:7890/test/thanks', ['hostname']);
171
+ * const ret4 = getDomain('http://example.com:7890/test/thanks', ['host']); // With Port
172
+ * const ret5 = getDomain('http://example.com:7890/test/thanks', ['origin']);
173
+ * const ret6 = getDomain('http://example.com:7890/test/thanks?id=1', ['origin', 'pathname', 'search']);
174
+ * console.log(ret1);
175
+ * console.log(ret2);
176
+ * console.log(ret3);
177
+ * console.log(ret4);
178
+ * console.log(ret5);
179
+ * console.log(ret6);
153
180
  * ```
154
181
  *
155
182
  * Output:
156
183
  *
157
- * ```
184
+ * ```text
158
185
  * example.com
159
186
  * example.com/test/thanks
160
187
  * example.com
@@ -171,9 +198,20 @@ export declare function getDomain(url: string, rules?: string[]): string;
171
198
  /**
172
199
  * Transfer CamelCase to KebabCase.
173
200
  *
201
+ * Usage:
202
+ *
203
+ * ```javascript
204
+ * const ret1 = convertCamelToKebab('ABC');
205
+ * const ret2 = convertCamelToKebab('aBC');
206
+ * console.log(ret1);
207
+ * console.log(ret2);
174
208
  * ```
175
- * convertCamelToKebab('ABC'); // a-b-c
176
- * convertCamelToKebab('aBC'); // a-b-c
209
+ *
210
+ * Output:
211
+ *
212
+ * ```text
213
+ * a-b-c
214
+ * a-b-c
177
215
  * ```
178
216
  *
179
217
  * @param {string} camelCase 'aBC' or 'ABC'
@@ -190,9 +228,20 @@ export declare function camelCaseToKebabCase(camelCase: string): string;
190
228
  /**
191
229
  * Transfer CamelCase to Underscore.
192
230
  *
231
+ * Usage:
232
+ *
233
+ * ```javascript
234
+ * const ret1 = convertCamelToUnder('ABC');
235
+ * const ret2 = convertCamelToUnder('aBC');
236
+ * console.log(ret1);
237
+ * console.log(ret2);
193
238
  * ```
194
- * convertCamelToUnder('ABC'); // a_b_c
195
- * convertCamelToUnder('aBC'); // a_b_c
239
+ *
240
+ * Output:
241
+ *
242
+ * ```text
243
+ * a_b_c
244
+ * a_b_c
196
245
  * ```
197
246
  *
198
247
  * @param {string} camelCase 'aBC' or 'ABC'
@@ -211,9 +260,20 @@ export declare function camelCase2Underscore(camelCase: string): string;
211
260
  *
212
261
  * Note: This method is used to replace the native `String.prototype.trim()`. But it is not necessary to use it in modern browsers.
213
262
  *
263
+ * Usage:
264
+ *
265
+ * ```javascript
266
+ * const ret1 = mTrim(' 1 2 3 ');
267
+ * const ret2 = mTrim('abc ');
268
+ * console.log(ret1);
269
+ * console.log(ret2);
214
270
  * ```
215
- * mTrim(' 1 2 3 '); // '1 2 3'
216
- * mTrim('abc '); // 'abc'
271
+ *
272
+ * Output:
273
+ *
274
+ * ```text
275
+ * 1 2 3
276
+ * abc
217
277
  * ```
218
278
  *
219
279
  * @param {string} str The string to trim.
@@ -225,9 +285,20 @@ export declare function mTrim(str: string): string;
225
285
  /**
226
286
  * Make a new line of HTML.
227
287
  *
288
+ * Usage:
289
+ *
290
+ * ```javascript
291
+ * const ret1 = newLine('a\nb\nc');
292
+ * const ret2 = newLine('a\n\nbc');
293
+ * console.log(ret1);
294
+ * console.log(ret2);
228
295
  * ```
229
- * newLine('a\nb\nc'); // 'a<br />b<br />c'
230
- * newLine('a\n\nbc'); // 'a<br /><br />bc'
296
+ *
297
+ * Output:
298
+ *
299
+ * ```text
300
+ * a<br />b<br />c
301
+ * a<br /><br />bc
231
302
  * ```
232
303
  *
233
304
  * @param {string} str The string to make a new line.
@@ -240,16 +311,18 @@ export declare function newLine(str: string): string;
240
311
  *
241
312
  * Usage:
242
313
  *
243
- * ```
244
- * deepCopy(['a', 'b', 'c']);
245
- * deepCopy('abc');
314
+ * ```javascript
315
+ * const ret1 = deepCopy(['a', 'b', 'c']);
316
+ * const ret2 = deepCopy('abc');
317
+ * console.log(ret1);
318
+ * console.log(ret2);
246
319
  * ```
247
320
  *
248
321
  * Output:
249
322
  *
250
- * ```
323
+ * ```text
251
324
  * ['a', 'b', 'c']
252
- * 'abc'
325
+ * abc
253
326
  * ```
254
327
  *
255
328
  * @param {object} obj The value to clone.
@@ -268,14 +341,16 @@ export declare function deepCopyObject<T>(obj: T): T;
268
341
  *
269
342
  * Usage:
270
343
  *
271
- * ```
272
- * isJSONString(`['a', 'b', 'c']`);
273
- * isJSONString(`["a", "b", "c"]`);
344
+ * ```javascript
345
+ * const ret1 = isJSONString(`['a', 'b', 'c']`);
346
+ * const ret2 = isJSONString(`["a", "b", "c"]`);
347
+ * console.log(ret1);
348
+ * console.log(ret2);
274
349
  * ```
275
350
  *
276
351
  * Output:
277
352
  *
278
- * ```
353
+ * ```text
279
354
  * false
280
355
  * true
281
356
  * ```
@@ -294,9 +369,20 @@ export declare function isJsonString(str: string): boolean;
294
369
  /**
295
370
  * Produce a random string of number, `genRndNumString(7)` => '7658495'.
296
371
  *
372
+ * Usage:
373
+ *
374
+ * ```javascript
375
+ * const ret1 = genRndNumString(4);
376
+ * const ret2 = genRndNumString(7);
377
+ * console.log(ret1);
378
+ * console.log(ret2);
297
379
  * ```
298
- * genRndNumString(4); // '9730'
299
- * genRndNumString(7); // '2262490'
380
+ *
381
+ * Output:
382
+ *
383
+ * ```text
384
+ * 9730
385
+ * 2262490
300
386
  * ```
301
387
  *
302
388
  * @param {number} n Length
@@ -311,7 +397,23 @@ export declare function genRndNumString(n?: number): string;
311
397
  */
312
398
  export declare function generateRndNum(n?: number): string;
313
399
  /**
314
- * 根据时间生成唯一标志的数字 genUniqueNumString() => 1538324722364123
400
+ * 根据时间生成唯一标志的数字 `genUniqueNumString()` => `1538324722364123`
401
+ *
402
+ * Usage:
403
+ *
404
+ * ```javascript
405
+ * const ret1 = genUniqueNumString();
406
+ * const ret2 = genUniqueNumString(3);
407
+ * console.log(ret1);
408
+ * console.log(ret2);
409
+ * ```
410
+ *
411
+ * Output:
412
+ *
413
+ * ```text
414
+ * 1538324722364123
415
+ * 1538324722364123
416
+ * ```
315
417
  *
316
418
  * @param {number} n 随机数的长度
317
419
  * @category Util
@@ -326,6 +428,22 @@ export declare function generateUniqueNum(n?: number): string;
326
428
  /**
327
429
  * 浮点数转为百分比 0.2 => 20%
328
430
  *
431
+ * Usage:
432
+ *
433
+ * ```javascript
434
+ * const ret1 = floatToPercent(0.2);
435
+ * const ret2 = floatToPercent(0.2, 2);
436
+ * console.log(ret1);
437
+ * console.log(ret2);
438
+ * ```
439
+ *
440
+ * Output:
441
+ *
442
+ * ```text
443
+ * 20%
444
+ * 20.00%
445
+ * ```
446
+ *
329
447
  * @param {number} num 浮点数
330
448
  * @param {number} fixSize 保留几位浮点数
331
449
  * @category Util
@@ -334,19 +452,43 @@ export declare function floatToPercent(num: number, fixSize?: number): string;
334
452
  /**
335
453
  * 浮点数保留指定位
336
454
  *
455
+ * Usage:
456
+ *
457
+ * ```javascript
458
+ * const ret1 = floatFixed(0.2);
459
+ * const ret2 = floatFixed(0.2, 2);
460
+ * console.log(ret1);
461
+ * console.log(ret2);
462
+ * ```
463
+ *
464
+ * Output:
465
+ *
466
+ * ```text
467
+ * 0
468
+ * 0.20
469
+ * ```
470
+ *
337
471
  * @category Util
338
472
  */
339
473
  export declare function floatFixed(num: string, size?: number): string;
340
474
  /**
341
475
  * 阻止冒泡
342
476
  *
477
+ * Usage:
478
+ *
479
+ * ```javascript
480
+ * const ret1 = cancelBubble(e);
481
+ * ```
482
+ *
343
483
  * @category Event
344
484
  */
345
485
  export declare function cancelBubble(e: Event): void;
346
486
  /**
347
487
  * Modify `class`.
348
488
  *
349
- * ```
489
+ * Usage:
490
+ *
491
+ * ```javascript
350
492
  * const dom = document.querySelector('#box');
351
493
  *
352
494
  * // Determine `class`
@@ -363,7 +505,9 @@ export declare function hasClass(obj: HTMLElement, cls: string): boolean;
363
505
  /**
364
506
  * Modify `class`.
365
507
  *
366
- * ```
508
+ * Usage:
509
+ *
510
+ * ```javascript
367
511
  * const dom = document.querySelector('#box');
368
512
  *
369
513
  * // Determine `class`
@@ -380,7 +524,9 @@ export declare function addClass(obj: HTMLElement, cls: string): void;
380
524
  /**
381
525
  * Modify `class`.
382
526
  *
383
- * ```
527
+ * Usage:
528
+ *
529
+ * ```javascript
384
530
  * const dom = document.querySelector('#box');
385
531
  *
386
532
  * // Determine `class`
@@ -399,7 +545,9 @@ export declare function removeClass(obj: HTMLElement, cls: string): void;
399
545
  *
400
546
  * ZH: 节流
401
547
  *
402
- * ```
548
+ * Usage:
549
+ *
550
+ * ```javascript
403
551
  * const foo = throttle(() => {
404
552
  * console.log('The function will be invoked at most once per every wait 1000 milliseconds.');
405
553
  * }, 1000, { leading: true });
@@ -418,7 +566,9 @@ export declare function throttle<T extends (...args: UnknownFnParams) => Unknown
418
566
  *
419
567
  * ZH: 去抖
420
568
  *
421
- * ```
569
+ * Usage:
570
+ *
571
+ * ```javascript
422
572
  * const foo = debounce(() => {
423
573
  * console.log('The debounced function will only be invoked in 1000 milliseconds, the other invoking will disappear during the wait time.');
424
574
  * }, 1000, true);
@@ -430,11 +580,23 @@ export declare function debounce<T extends (...args: UnknownFnParams) => Unknown
430
580
  /**
431
581
  * 获取间隔时间
432
582
  *
433
- * @example
434
- * ```js
435
- * console.log('getFriendlyInterval:', getFriendlyInterval(new Date('2020-03-28 00:09:27'), new Date('2023-04-18 10:54:00'), { type: 'd' })); // 1116
436
- * console.log('getFriendlyInterval:', getFriendlyInterval(1585325367000, 1681786440000, { type: 'text' })); // 1116 天 10 时 44 分 33 秒
437
- * console.log('getFriendlyInterval:', getFriendlyInterval('2020-03-28 00:09:27', '2023-04-18 10:54:00', { type: 'text' })); // 1116 天 10 时 44 分 33 秒
583
+ * Usage:
584
+ *
585
+ * ```javascript
586
+ * const ret1 = getFriendlyInterval(new Date('2020-03-28 00:09:27'), new Date('2023-04-18 10:54:00'), { type: 'd' });
587
+ * const ret2 = getFriendlyInterval(1585325367000, 1681786440000, { type: 'text' });
588
+ * const ret3 = getFriendlyInterval('2020-03-28 00:09:27', '2023-04-18 10:54:00', { type: 'text' });
589
+ * console.log(ret1);
590
+ * console.log(ret2);
591
+ * console.log(ret3);
592
+ * ```
593
+ *
594
+ * Output:
595
+ *
596
+ * ```text
597
+ * 1116
598
+ * 1116 天 10 时 44 分 33 秒
599
+ * 1116 天 10 时 44 分 33 秒
438
600
  * ```
439
601
  *
440
602
  * @param {number/Date} start 开始时间戳 1585325367122
@@ -451,14 +613,23 @@ export declare function getFriendlyInterval(start?: number | string | Date, end?
451
613
  *
452
614
  * ZH: 判断是否有效数字
453
615
  *
454
- * ```
455
- * isNumber(123); // true
456
- * isNumber('123'); // false
616
+ * Usage:
617
+ *
618
+ * ```javascript
619
+ * const ret1 = isNumber(123);
620
+ * const ret2 = isNumber('123');
457
621
  * // Default: NaN, Infinity is not Number
458
- * isNumber(Infinity); // false
459
- * isNumber(Infinity, { isInfinityAsNumber: true }); // true
460
- * isNumber(NaN); // false
461
- * isNumber(NaN, { isNaNAsNumber: true, isInfinityAsNumber: true }); // true
622
+ * const ret3 = isNumber(Infinity);
623
+ * const ret4 = isNumber(Infinity, { isInfinityAsNumber: true });
624
+ * const ret5 = isNumber(NaN);
625
+ * const ret6 = isNumber(NaN, { isNaNAsNumber: true, isInfinityAsNumber: true });
626
+ * console.log(ret1, ret2, ret3, ret4, ret5, ret6);
627
+ * ```
628
+ *
629
+ * Output:
630
+ *
631
+ * ```text
632
+ * true false false true false true
462
633
  * ```
463
634
  *
464
635
  * @param {*} num 被判断的值
@@ -471,6 +642,14 @@ export declare function isNumber(num: unknown, options?: IsNumberOptions): boole
471
642
  /**
472
643
  * 执行有效函数
473
644
  *
645
+ * Usage:
646
+ *
647
+ * ```javascript
648
+ * const ret = doFn(() => {
649
+ * console.log('doFn');
650
+ * });
651
+ * ```
652
+ *
474
653
  * @param {function} fn 等待被执行的未知是否有效的函数
475
654
  * @category Util
476
655
  */
@@ -480,11 +659,14 @@ export declare function doFn(fn: AnyFunction, ...params: Parameters<AnyFunction>
480
659
  *
481
660
  * ZH: 存储/获取数据到 sessionStorage/localStorage
482
661
  *
483
- * ```
662
+ * Usage:
663
+ *
664
+ * ```javascript
484
665
  * setSessionStorage('test', '123');
485
- * getSessionStorage('test'); // 123
666
+ * const ret1 = getSessionStorage('test');
486
667
  * setLocalStorage('test', '123');
487
- * getLocalStorage('test'); // 123
668
+ * const ret2 = getLocalStorage('test');
669
+ * console.log(ret1, ret2);
488
670
  *
489
671
  * // or package in usage
490
672
  * const projectName = 'mazey';
@@ -497,6 +679,12 @@ export declare function doFn(fn: AnyFunction, ...params: Parameters<AnyFunction>
497
679
  * }
498
680
  * ```
499
681
  *
682
+ * Output:
683
+ *
684
+ * ```text
685
+ * 123 123
686
+ * ```
687
+ *
500
688
  * @param {string} key 键
501
689
  * @returns {void} 返回值
502
690
  * @category Cache Data
@@ -507,11 +695,14 @@ export declare function setSessionStorage<T>(key: string, value?: T | null): voi
507
695
  *
508
696
  * ZH: 存储/获取数据到 sessionStorage/localStorage
509
697
  *
510
- * ```
698
+ * Usage:
699
+ *
700
+ * ```javascript
511
701
  * setSessionStorage('test', '123');
512
- * getSessionStorage('test'); // 123
702
+ * const ret1 = getSessionStorage('test');
513
703
  * setLocalStorage('test', '123');
514
- * getLocalStorage('test'); // 123
704
+ * const ret2 = getLocalStorage('test');
705
+ * console.log(ret1, ret2);
515
706
  *
516
707
  * // or package in usage
517
708
  * const projectName = 'mazey';
@@ -524,6 +715,12 @@ export declare function setSessionStorage<T>(key: string, value?: T | null): voi
524
715
  * }
525
716
  * ```
526
717
  *
718
+ * Output:
719
+ *
720
+ * ```text
721
+ * 123 123
722
+ * ```
723
+ *
527
724
  * @param {string} key 键
528
725
  * @returns {any} 返回值
529
726
  * @category Cache Data
@@ -534,11 +731,14 @@ export declare function getSessionStorage<T>(key: string): T | null;
534
731
  *
535
732
  * ZH: 存储/获取数据到 sessionStorage/localStorage
536
733
  *
537
- * ```
734
+ * Usage:
735
+ *
736
+ * ```javascript
538
737
  * setSessionStorage('test', '123');
539
- * getSessionStorage('test'); // 123
738
+ * const ret1 = getSessionStorage('test');
540
739
  * setLocalStorage('test', '123');
541
- * getLocalStorage('test'); // 123
740
+ * const ret2 = getLocalStorage('test');
741
+ * console.log(ret1, ret2);
542
742
  *
543
743
  * // or package in usage
544
744
  * const projectName = 'mazey';
@@ -551,6 +751,12 @@ export declare function getSessionStorage<T>(key: string): T | null;
551
751
  * }
552
752
  * ```
553
753
  *
754
+ * Output:
755
+ *
756
+ * ```text
757
+ * 123 123
758
+ * ```
759
+ *
554
760
  * @param {string} key 键
555
761
  * @returns {void} 返回值
556
762
  * @category Cache Data
@@ -561,11 +767,14 @@ export declare function setLocalStorage<T>(key: string, value?: T | null): void;
561
767
  *
562
768
  * ZH: 存储/获取数据到 sessionStorage/localStorage
563
769
  *
564
- * ```
770
+ * Usage:
771
+ *
772
+ * ```javascript
565
773
  * setSessionStorage('test', '123');
566
- * getSessionStorage('test'); // 123
774
+ * const ret1 = getSessionStorage('test');
567
775
  * setLocalStorage('test', '123');
568
- * getLocalStorage('test'); // 123
776
+ * const ret2 = getLocalStorage('test');
777
+ * console.log(ret1, ret2);
569
778
  *
570
779
  * // or package in usage
571
780
  * const projectName = 'mazey';
@@ -578,8 +787,14 @@ export declare function setLocalStorage<T>(key: string, value?: T | null): void;
578
787
  * }
579
788
  * ```
580
789
  *
790
+ * Output:
791
+ *
792
+ * ```text
793
+ * 123 123
794
+ * ```
795
+ *
581
796
  * @param {string} key 键
582
- * @returns {any} 返回值
797
+ * @returns {void} 返回值
583
798
  * @category Cache Data
584
799
  */
585
800
  export declare function getLocalStorage<T>(key: string): T | null;
@@ -588,7 +803,9 @@ export declare function getLocalStorage<T>(key: string): T | null;
588
803
  *
589
804
  * ZH: 动态加载 CSS 文件
590
805
  *
591
- * ```
806
+ * Usage:
807
+ *
808
+ * ```javascript
592
809
  * loadCSS(
593
810
  * 'http://example.com/path/example.css',
594
811
  * {
@@ -607,6 +824,12 @@ export declare function getLocalStorage<T>(key: string): T | null;
607
824
  * );
608
825
  * ```
609
826
  *
827
+ * Output:
828
+ *
829
+ * ```text
830
+ * Load CSS Success: loaded
831
+ * ```
832
+ *
610
833
  * @param {string} url -- css资源路径
611
834
  * @param {string} options.id -- link标签id
612
835
  * @returns {Promise<string>} true -- 加载成功
@@ -620,7 +843,9 @@ export declare function loadCSS(url: string, options?: {
620
843
  *
621
844
  * ZH: 动态加载 JavaScript 文件
622
845
  *
623
- * ```
846
+ * Usage:
847
+ *
848
+ * ```javascript
624
849
  * loadScript(
625
850
  * 'http://example.com/static/js/plugin-2.1.1.min.js',
626
851
  * {
@@ -641,6 +866,12 @@ export declare function loadCSS(url: string, options?: {
641
866
  * );
642
867
  * ```
643
868
  *
869
+ * Output:
870
+ *
871
+ * ```text
872
+ * Load JavaScript script: loaded
873
+ * ```
874
+ *
644
875
  * @param {string} url -- JavaScript 资源路径
645
876
  * @param {string} options.id -- DOM ID
646
877
  * @param {function} options.callback -- 加载后回调函数
@@ -658,6 +889,19 @@ export declare function loadScript(url: string, options?: {
658
889
  /**
659
890
  * 获取时间戳
660
891
  *
892
+ * Usage:
893
+ *
894
+ * ```javascript
895
+ * const ret = mNow();
896
+ * console.log(ret);
897
+ * ```
898
+ *
899
+ * Output:
900
+ *
901
+ * ```text
902
+ * 1585325367122
903
+ * ```
904
+ *
661
905
  * @category Util
662
906
  */
663
907
  export declare function mNow(): number;
@@ -666,9 +910,18 @@ export declare function mNow(): number;
666
910
  *
667
911
  * ZH: 设置/获取 Cookie
668
912
  *
669
- * ```
913
+ * Usage:
914
+ *
915
+ * ```javascript
670
916
  * setCookie('test', '123', 30, 'example.com'); // key value day domain
671
- * getCookie('test'); // 123
917
+ * const ret = getCookie('test');
918
+ * console.log(ret);
919
+ * ```
920
+ *
921
+ * Output:
922
+ *
923
+ * ```text
924
+ * 123
672
925
  * ```
673
926
  *
674
927
  * @category Cache Data
@@ -679,9 +932,18 @@ export declare function setCookie(name: string, value: string, days?: number, do
679
932
  *
680
933
  * ZH: 设置/获取 Cookie
681
934
  *
682
- * ```
935
+ * Usage:
936
+ *
937
+ * ```javascript
683
938
  * setCookie('test', '123', 30, 'example.com'); // key value day domain
684
- * getCookie('test'); // 123
939
+ * const ret = getCookie('test');
940
+ * console.log(ret);
941
+ * ```
942
+ *
943
+ * Output:
944
+ *
945
+ * ```text
946
+ * 123
685
947
  * ```
686
948
  *
687
949
  * @category Cache Data
@@ -690,6 +952,19 @@ export declare function getCookie(name: string): string;
690
952
  /**
691
953
  * Delete a cookie by name.
692
954
  *
955
+ * Usage:
956
+ *
957
+ * ```javascript
958
+ * const ret = delCookie('test');
959
+ * console.log(ret);
960
+ * ```
961
+ *
962
+ * Output:
963
+ *
964
+ * ```text
965
+ * true
966
+ * ```
967
+ *
693
968
  * @param name - The name of the cookie to delete.
694
969
  * @returns `true` if the cookie was deleted successfully, `false` otherwise.
695
970
  * @category Cache Data
@@ -705,6 +980,22 @@ interface WebPerformance {
705
980
  * Gets the first contentful paint (FCP) time of a web page using the Performance API.
706
981
  * The FCP time is the time it takes for the first piece of content to be painted on the screen.
707
982
  *
983
+ * Usage:
984
+ *
985
+ * ```javascript
986
+ * getFCP().then(
987
+ * res => {
988
+ * console.log(`FCP: ${res}`);
989
+ * }
990
+ * );
991
+ * ```
992
+ *
993
+ * Output:
994
+ *
995
+ * ```text
996
+ * FCP: 123
997
+ * ```
998
+ *
708
999
  * @returns A promise that resolves with the FCP time in milliseconds, or 0 if the 'paint' entry type is not supported.
709
1000
  * @category Web Performance
710
1001
  */
@@ -713,6 +1004,22 @@ export declare function getFCP(): Promise<number>;
713
1004
  * Gets the first paint (FP) time of a web page using the Performance API.
714
1005
  * The FP time is the time it takes for the first pixel to be painted on the screen.
715
1006
  *
1007
+ * Usage:
1008
+ *
1009
+ * ```javascript
1010
+ * getFP().then(
1011
+ * res => {
1012
+ * console.log(`FP: ${res}`);
1013
+ * }
1014
+ * );
1015
+ * ```
1016
+ *
1017
+ * Output:
1018
+ *
1019
+ * ```text
1020
+ * FP: 123
1021
+ * ```
1022
+ *
716
1023
  * @returns A promise that resolves with the FP time in milliseconds, or 0 if the 'paint' entry type is not supported.
717
1024
  * @category Web Performance
718
1025
  */
@@ -721,6 +1028,22 @@ export declare function getFP(): Promise<number>;
721
1028
  * Gets the largest contentful paint (LCP) time of a web page using the Performance API.
722
1029
  * The LCP time is the time it takes for the largest piece of content to be painted on the screen.
723
1030
  *
1031
+ * Usage:
1032
+ *
1033
+ * ```javascript
1034
+ * getLCP().then(
1035
+ * res => {
1036
+ * console.log(`LCP: ${res}`);
1037
+ * }
1038
+ * );
1039
+ * ```
1040
+ *
1041
+ * Output:
1042
+ *
1043
+ * ```text
1044
+ * LCP: 123
1045
+ * ```
1046
+ *
724
1047
  * @returns A promise that resolves with the LCP time in milliseconds, or 0 if the 'largest-contentful-paint' entry type is not supported.
725
1048
  * @category Web Performance
726
1049
  */
@@ -729,6 +1052,22 @@ export declare function getLCP(): Promise<number>;
729
1052
  * Gets the first input delay (FID) of a web page using the Performance API.
730
1053
  * The FID is the time it takes for the first user input to be processed by the browser.
731
1054
  *
1055
+ * Usage:
1056
+ *
1057
+ * ```javascript
1058
+ * getFID().then(
1059
+ * res => {
1060
+ * console.log(`FID: ${res}`);
1061
+ * }
1062
+ * );
1063
+ * ```
1064
+ *
1065
+ * Output:
1066
+ *
1067
+ * ```text
1068
+ * FID: 123
1069
+ * ```
1070
+ *
732
1071
  * @returns A promise that resolves with the FID in milliseconds, or 0 if the 'first-input' entry type is not supported.
733
1072
  * @category Web Performance
734
1073
  */
@@ -737,6 +1076,22 @@ export declare function getFID(): Promise<number>;
737
1076
  * Gets the Cumulative Layout Shift (CLS) score of a web page using the Performance API.
738
1077
  * The CLS score is a measure of how much the page layout shifts during loading.
739
1078
  *
1079
+ * Usage:
1080
+ *
1081
+ * ```javascript
1082
+ * getCLS().then(
1083
+ * res => {
1084
+ * console.log(`CLS: ${res}`);
1085
+ * }
1086
+ * );
1087
+ * ```
1088
+ *
1089
+ * Output:
1090
+ *
1091
+ * ```text
1092
+ * CLS: 123
1093
+ * ```
1094
+ *
740
1095
  * @returns A promise that resolves with the CLS score, or 0 if the 'layout-shift' entry type is not supported.
741
1096
  * @category Web Performance
742
1097
  */
@@ -745,6 +1100,22 @@ export declare function getCLS(): Promise<number>;
745
1100
  * Gets the time to first byte (TTFB) of a web page using the Performance API.
746
1101
  * The TTFB is the time it takes for the first byte of the response to be received by the browser.
747
1102
  *
1103
+ * Usage:
1104
+ *
1105
+ * ```javascript
1106
+ * getTTFB().then(
1107
+ * res => {
1108
+ * console.log(`TTFB: ${res}`);
1109
+ * }
1110
+ * );
1111
+ * ```
1112
+ *
1113
+ * Output:
1114
+ *
1115
+ * ```text
1116
+ * TTFB: 123
1117
+ * ```
1118
+ *
748
1119
  * @returns The TTFB in milliseconds, or 0 if the navigation timing information is not available.
749
1120
  * @category Web Performance
750
1121
  */
@@ -761,7 +1132,7 @@ export declare function getTTFB(): Promise<number>;
761
1132
  *
762
1133
  * Usage:
763
1134
  *
764
- * ```
1135
+ * ```javascript
765
1136
  * // `camelCase:false` (Default) Return underline(`a_b`) data.
766
1137
  * // `camelCase:true` Return hump(`aB`) data.
767
1138
  * getPerformance()
@@ -773,7 +1144,7 @@ export declare function getTTFB(): Promise<number>;
773
1144
  *
774
1145
  * Output:
775
1146
  *
776
- * ```
1147
+ * ```text
777
1148
  * {"source":"PerformanceNavigationTiming","os":"others","os_version":"","device_type":"pc","network":"4g","screen_direction":"","unload_time":0,"redirect_time":0,"dns_time":0,"tcp_time":0,"ssl_time":0,"response_time":2,"download_time":2,"first_paint_time":288,"first_contentful_paint_time":288,"dom_ready_time":0,"onload_time":0,"white_time":0,"render_time":0,"decoded_body_size":718,"encoded_body_size":718}
778
1149
  * ```
779
1150
  *
@@ -805,19 +1176,20 @@ export declare function getPerformance(camelCase?: boolean): Promise<WebPerforma
805
1176
  *
806
1177
  * Usage:
807
1178
  *
808
- * ```
809
- * inRate(0.5); // 0.01 ~ 1 true/false
1179
+ * ```javascript
1180
+ * const ret = inRate(0.5); // 0.01 ~ 1 true/false
1181
+ * console.log(ret);
810
1182
  * ```
811
1183
  *
812
1184
  * Output:
813
1185
  *
814
- * ```
1186
+ * ```text
815
1187
  * true
816
1188
  * ```
817
1189
  *
818
1190
  * Example: Test the precision.
819
1191
  *
820
- * ```
1192
+ * ```javascript
821
1193
  * // Test
822
1194
  * let trueCount = 0;
823
1195
  * let falseCount = 0;
@@ -843,13 +1215,14 @@ export declare function inRate(rate: number): boolean;
843
1215
  *
844
1216
  * Usage:
845
1217
  *
846
- * ```
847
- * isSafePWAEnv();
1218
+ * ```javascript
1219
+ * const ret = isSafePWAEnv();
1220
+ * console.log(ret);
848
1221
  * ```
849
1222
  *
850
1223
  * Output:
851
1224
  *
852
- * ```
1225
+ * ```text
853
1226
  * true
854
1227
  * ```
855
1228
  *
@@ -864,13 +1237,14 @@ export declare function isSafePWAEnv(): boolean;
864
1237
  *
865
1238
  * Usage:
866
1239
  *
867
- * ```
868
- * getBrowserInfo();
1240
+ * ```javascript
1241
+ * const ret = getBrowserInfo();
1242
+ * console.log(ret);
869
1243
  * ```
870
1244
  *
871
1245
  * Output:
872
1246
  *
873
- * ```
1247
+ * ```text
874
1248
  * {"engine":"webkit","engineVs":"537.36","platform":"desktop","supporter":"chrome","supporterVs":"85.0.4183.121","system":"windows","systemVs":"10"}
875
1249
  * ```
876
1250
  *
@@ -879,7 +1253,7 @@ export declare function isSafePWAEnv(): boolean;
879
1253
  * | Attribute | Description | Type | Values |
880
1254
  * | :------------ | :------------ | :------------ | :------------ |
881
1255
  * | **system** | System | string | android, ios, windows, macos, linux |
882
- * | systemVs | System version | string | windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 <br />macos: ... |
1256
+ * | systemVs | System version | string | Windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 macOS: ... |
883
1257
  * | platform | Platform | string | desktop, mobile |
884
1258
  * | engine | Engine | string | webkit, gecko, presto, trident |
885
1259
  * | engineVs | Engine version | string | - |
@@ -891,7 +1265,7 @@ export declare function isSafePWAEnv(): boolean;
891
1265
  *
892
1266
  * Example: Determine the environment of the mobile QQ.
893
1267
  *
894
- * ```
1268
+ * ```javascript
895
1269
  * const { system, shell } = getBrowserInfo();
896
1270
  * const isMobileQQ = ['android', 'ios'].includes(system) && ['qq_browser', 'qq_app'].includes(shell);
897
1271
  * ```
@@ -903,6 +1277,19 @@ export declare function getBrowserInfo(): BrowserInfo;
903
1277
  /**
904
1278
  * 去除 HTML 标签
905
1279
  *
1280
+ * Usage:
1281
+ *
1282
+ * ```javascript
1283
+ * const ret = clearHtml('<div>hello world</div>');
1284
+ * console.log(ret);
1285
+ * ```
1286
+ *
1287
+ * Output:
1288
+ *
1289
+ * ```text
1290
+ * hello world
1291
+ * ```
1292
+ *
906
1293
  * @param {string} str 带html标签的字符串
907
1294
  * @returns {string} 字符串
908
1295
  * @category Util
@@ -911,7 +1298,20 @@ export declare function clearHtml(str: string, options?: {
911
1298
  removeNewLine?: boolean;
912
1299
  }): string;
913
1300
  /**
914
- * Sanitizes user input to prevent XSS attacks
1301
+ * Sanitizes user input to prevent XSS attacks.
1302
+ *
1303
+ * Usage:
1304
+ *
1305
+ * ```javascript
1306
+ * const ret = sanitizeInput('<div>hello world</div>');
1307
+ * console.log(ret);
1308
+ * ```
1309
+ *
1310
+ * Output:
1311
+ *
1312
+ * ```text
1313
+ * &lt;div&gt;hello world&lt;/div&gt;
1314
+ * ```
915
1315
  *
916
1316
  * @param input - The input string to sanitize
917
1317
  * @returns The sanitized input string
@@ -921,6 +1321,19 @@ export declare function sanitizeInput(input: string): string;
921
1321
  /**
922
1322
  * Reverses the sanitization done by the `sanitizeInput` function.
923
1323
  *
1324
+ * Usage:
1325
+ *
1326
+ * ```javascript
1327
+ * const ret = unsanitize('&lt;div&gt;hello world&lt;/div&gt;');
1328
+ * console.log(ret);
1329
+ * ```
1330
+ *
1331
+ * Output:
1332
+ *
1333
+ * ```text
1334
+ * <div>hello world</div>
1335
+ * ```
1336
+ *
924
1337
  * @param input - The input string to unsanitize
925
1338
  * @returns The unsanitized input string
926
1339
  * @category Util
@@ -929,6 +1342,19 @@ export declare function unsanitize(input: string): string;
929
1342
  /**
930
1343
  * 截取字符串,中文算 2 个字节
931
1344
  *
1345
+ * Usage:
1346
+ *
1347
+ * ```javascript
1348
+ * const ret = truncateZHString('hello world', 5);
1349
+ * console.log(ret);
1350
+ * ```
1351
+ *
1352
+ * Output:
1353
+ *
1354
+ * ```text
1355
+ * hello
1356
+ * ```
1357
+ *
932
1358
  * @param {string} str 要截取的字符串
933
1359
  * @param {number} len
934
1360
  * @param {boolean} hasDot
@@ -947,16 +1373,24 @@ export declare function cutCHSString(str: string, len: number, hasDot?: boolean)
947
1373
  *
948
1374
  * ZH: 页面加载完成
949
1375
  *
950
- * ```
1376
+ * Usage:
1377
+ *
1378
+ * ```javascript
951
1379
  * windowLoaded(30) // second
952
1380
  * .then(res => {
953
- * console.log(`Load Success: ${res}`); // Load Success: load
1381
+ * console.log(`Load Success: ${res}`);
954
1382
  * })
955
1383
  * .catch(err => {
956
1384
  * console.log(`Load Timeout or Fail: ${err.message}`);
957
1385
  * });
958
1386
  * ```
959
1387
  *
1388
+ * Output:
1389
+ *
1390
+ * ```text
1391
+ * Load Success: load
1392
+ * ```
1393
+ *
960
1394
  * @param {number} timeout 超时时间 / 单位:秒
961
1395
  * @returns {Promise<string>} document is loaded? 'complete' 'load' / 'timeout'
962
1396
  * @category Load Resource
@@ -969,7 +1403,7 @@ export declare function windowLoaded(timeout?: number): Promise<string | Error>;
969
1403
  *
970
1404
  * Example 1: Add the `<style>` with `id`, and repeated invoking will update the content instead of adding a new one.
971
1405
  *
972
- * ```
1406
+ * ```javascript
973
1407
  * addStyle(
974
1408
  * `
975
1409
  * body {
@@ -989,7 +1423,7 @@ export declare function windowLoaded(timeout?: number): Promise<string | Error>;
989
1423
  *
990
1424
  * Example 2: Add the `<style>` without `id`, and repeated invoking will add a new one.
991
1425
  *
992
- * ```
1426
+ * ```javascript
993
1427
  * addStyle(
994
1428
  * `
995
1429
  * body {
@@ -1016,7 +1450,7 @@ export declare function addStyle(style: string, options?: {
1016
1450
  *
1017
1451
  * Usage:
1018
1452
  *
1019
- * ```
1453
+ * ```javascript
1020
1454
  * const myConsole = genCustomConsole('MazeyLog:');
1021
1455
  * myConsole.log('I am string.');
1022
1456
  * myConsole.info('I am boolean.', true);
@@ -1026,7 +1460,7 @@ export declare function addStyle(style: string, options?: {
1026
1460
  *
1027
1461
  * Output:
1028
1462
  *
1029
- * ```
1463
+ * ```text
1030
1464
  * MazeyLog: I am string.
1031
1465
  * MazeyLog: I am boolean. true
1032
1466
  * MazeyLog: I am number. 123 456
@@ -1060,6 +1494,19 @@ export declare function zAxiosIsValidRes(res: ZResResponse | undefined, options?
1060
1494
  /**
1061
1495
  * Verify the validity of a non-empty array.
1062
1496
  *
1497
+ * Usage:
1498
+ *
1499
+ * ```javascript
1500
+ * const ret = isNonEmptyArray([1, 2, 3]);
1501
+ * console.log(ret);
1502
+ * ```
1503
+ *
1504
+ * Output:
1505
+ *
1506
+ * ```text
1507
+ * true
1508
+ * ```
1509
+ *
1063
1510
  * @category Util
1064
1511
  */
1065
1512
  export declare function isNonEmptyArray<T>(arr: Array<T>): boolean;
@@ -1068,7 +1515,7 @@ export declare function isNonEmptyArray<T>(arr: Array<T>): boolean;
1068
1515
  *
1069
1516
  * Usage:
1070
1517
  *
1071
- * ```
1518
+ * ```javascript
1072
1519
  * const validData = {
1073
1520
  * a: {
1074
1521
  * b: {
@@ -1088,7 +1535,7 @@ export declare function isNonEmptyArray<T>(arr: Array<T>): boolean;
1088
1535
  *
1089
1536
  * Output:
1090
1537
  *
1091
- * ```
1538
+ * ```text
1092
1539
  * isValidDataResA: false
1093
1540
  * isValidDataResB: true
1094
1541
  * isValidDataResC: false
@@ -1102,7 +1549,20 @@ export declare function isNonEmptyArray<T>(arr: Array<T>): boolean;
1102
1549
  */
1103
1550
  export declare function isValidData(data: UnknownObject, attributes: string[], validValue: SimpleType): boolean;
1104
1551
  /**
1105
- * 语义化文件大小, 把字节转换成正常文件大小.
1552
+ * 语义化文件大小,把字节转换成正常文件大小。
1553
+ *
1554
+ * Usage:
1555
+ *
1556
+ * ```javascript
1557
+ * const ret = getFileSize(1024);
1558
+ * console.log(ret);
1559
+ * ```
1560
+ *
1561
+ * Output:
1562
+ *
1563
+ * ```text
1564
+ * 1 KB
1565
+ * ```
1106
1566
  *
1107
1567
  * @category Util
1108
1568
  */
@@ -1110,6 +1570,20 @@ export declare function getFileSize(size: number): string;
1110
1570
  /**
1111
1571
  * Detect webp support.
1112
1572
  *
1573
+ * Usage:
1574
+ *
1575
+ * ```javascript
1576
+ * isSupportWebp().then(res => {
1577
+ * console.log('isSupportWebp:', res);
1578
+ * });
1579
+ * ```
1580
+ *
1581
+ * Output:
1582
+ *
1583
+ * ```text
1584
+ * isSupportWebp: true
1585
+ * ```
1586
+ *
1113
1587
  * Reference: [Detect WEBP Support with JavaScript](https://davidwalsh.name/detect-webp)
1114
1588
  *
1115
1589
  * @category Browser Information
@@ -1118,6 +1592,19 @@ export declare function isSupportWebp(): Promise<boolean>;
1118
1592
  /**
1119
1593
  * Generate a Hash Code from a string.
1120
1594
  *
1595
+ * Usage:
1596
+ *
1597
+ * ```javascript
1598
+ * const ret = genHashCode('hello world');
1599
+ * console.log(ret);
1600
+ * ```
1601
+ *
1602
+ * Output:
1603
+ *
1604
+ * ```text
1605
+ * 1794106052
1606
+ * ```
1607
+ *
1121
1608
  * Reference: [Generate a Hash from string in Javascript](https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery)
1122
1609
  *
1123
1610
  * @category Util
@@ -1128,16 +1615,20 @@ export declare function genHashCode(str: string): number;
1128
1615
  *
1129
1616
  * Usage:
1130
1617
  *
1131
- * ```
1132
- * console.log('Default formatDate value:', formatDate());
1133
- * console.log('String formatDate value:', formatDate('Tue Jan 11 2022 14:12:26 GMT+0800 (China Standard Time)', 'yyyy-MM-dd hh:mm:ss'));
1134
- * console.log('Number formatDate value:', formatDate(1641881235000, 'yyyy-MM-dd hh:mm:ss'));
1135
- * console.log('Date formatDate value:', formatDate(new Date(2014, 1, 11), 'MM/dd/yyyy'));
1618
+ * ```javascript
1619
+ * const ret1 = formatDate();
1620
+ * const ret2 = formatDate('Tue Jan 11 2022 14:12:26 GMT+0800 (China Standard Time)', 'yyyy-MM-dd hh:mm:ss');
1621
+ * const ret3 = formatDate(1641881235000, 'yyyy-MM-dd hh:mm:ss');
1622
+ * const ret4 = formatDate(new Date(2014, 1, 11), 'MM/dd/yyyy');
1623
+ * console.log('Default formatDate value:', ret1);
1624
+ * console.log('String formatDate value:', ret2);
1625
+ * console.log('Number formatDate value:', ret3);
1626
+ * console.log('Date formatDate value:', ret4);
1136
1627
  * ```
1137
1628
  *
1138
1629
  * Output:
1139
1630
  *
1140
- * ```
1631
+ * ```text
1141
1632
  * Default formatDate value: 2023-01-11
1142
1633
  * String formatDate value: 2022-01-11 14:12:26
1143
1634
  * Number formatDate value: 2022-01-11 14:07:15
@@ -1153,6 +1644,12 @@ export declare function formatDate(dateIns?: Date | number | string, format?: st
1153
1644
  /**
1154
1645
  * Get event container.
1155
1646
  *
1647
+ * Usage:
1648
+ *
1649
+ * ```javascript
1650
+ * const ret = getEventContainer();
1651
+ * ```
1652
+ *
1156
1653
  * @category Event
1157
1654
  * @hidden
1158
1655
  */
@@ -1160,6 +1657,14 @@ export declare function getDefineListeners(): DefineListeners;
1160
1657
  /**
1161
1658
  * Add event.
1162
1659
  *
1660
+ * Usage:
1661
+ *
1662
+ * ```javascript
1663
+ * addEvent('test', (e) => {
1664
+ * console.log('test event:', e);
1665
+ * });
1666
+ * ```
1667
+ *
1163
1668
  * @param type
1164
1669
  * @param fn
1165
1670
  * @category Event
@@ -1168,6 +1673,12 @@ export declare function addEvent(type: string, fn: UnknownFn): void;
1168
1673
  /**
1169
1674
  * Invoke event.
1170
1675
  *
1676
+ * Usage:
1677
+ *
1678
+ * ```javascript
1679
+ * invokeEvent('test');
1680
+ * ```
1681
+ *
1171
1682
  * @param type
1172
1683
  * @category Event
1173
1684
  */
@@ -1175,6 +1686,12 @@ export declare function invokeEvent(type: string): void;
1175
1686
  /**
1176
1687
  * Remove event.
1177
1688
  *
1689
+ * Usage:
1690
+ *
1691
+ * ```javascript
1692
+ * removeEvent('test');
1693
+ * ```
1694
+ *
1178
1695
  * @param type
1179
1696
  * @param fn
1180
1697
  * @category Event
@@ -1183,13 +1700,21 @@ export declare function removeEvent(type: string, fn: UnknownFn): void;
1183
1700
  /**
1184
1701
  * Checks if the given string is a valid URL, including **scheme URLs**.
1185
1702
  *
1186
- * @example
1187
- * ```js
1188
- * isValidUrl('https://www.example.com'); // true
1189
- * isValidUrl('http://example.com/path/exx/ss'); // true
1190
- * isValidUrl('https://www.example.com/?q=hello&age=24#world'); // true
1191
- * isValidUrl('http://www.example.com/#world?id=9'); // true
1192
- * isValidUrl('ftp://example.com'); // true
1703
+ * Usage:
1704
+ *
1705
+ * ```javascript
1706
+ * const ret1 = isValidUrl('https://www.example.com');
1707
+ * const ret2 = isValidUrl('http://example.com/path/exx/ss');
1708
+ * const ret3 = isValidUrl('https://www.example.com/?q=hello&age=24#world');
1709
+ * const ret4 = isValidUrl('http://www.example.com/#world?id=9');
1710
+ * const ret5 = isValidUrl('ftp://example.com');
1711
+ * console.log(ret1, ret2, ret3, ret4, ret5);
1712
+ * ```
1713
+ *
1714
+ * Output:
1715
+ *
1716
+ * ```text
1717
+ * true true true true true
1193
1718
  * ```
1194
1719
  *
1195
1720
  * @remarks
@@ -1204,13 +1729,21 @@ export declare function isValidUrl(url: string): boolean;
1204
1729
  /**
1205
1730
  * Check if the given string is a valid HTTP/HTTPS URL.
1206
1731
  *
1207
- * @example
1208
- * ```js
1209
- * isValidHttpUrl('https://www.example.com'); // true
1210
- * isValidHttpUrl('http://example.com/path/exx/ss'); // true
1211
- * isValidHttpUrl('https://www.example.com/?q=hello&age=24#world'); // true
1212
- * isValidHttpUrl('http://www.example.com/#world?id=9'); // true
1213
- * isValidHttpUrl('ftp://example.com'); // false
1732
+ * Usage:
1733
+ *
1734
+ * ```javascript
1735
+ * const ret1 = isValidHttpUrl('https://www.example.com');
1736
+ * const ret2 = isValidHttpUrl('http://example.com/path/exx/ss');
1737
+ * const ret3 = isValidHttpUrl('https://www.example.com/?q=hello&age=24#world');
1738
+ * const ret4 = isValidHttpUrl('http://www.example.com/#world?id=9');
1739
+ * const ret5 = isValidHttpUrl('ftp://example.com');
1740
+ * console.log(ret1, ret2, ret3, ret4, ret5);
1741
+ * ```
1742
+ *
1743
+ * Output:
1744
+ *
1745
+ * ```text
1746
+ * true true true true false
1214
1747
  * ```
1215
1748
  *
1216
1749
  * @param url
@@ -1221,12 +1754,20 @@ export declare function isValidHttpUrl(url: string): boolean;
1221
1754
  /**
1222
1755
  * Check if the given string is a mobile phone number.
1223
1756
  *
1224
- * @example
1225
- * ```js
1226
- * console.log(isMobile('13800138000')); // true
1227
- * console.log(isMobile('1380013800')); // false
1228
- * console.log(isMobile('138001380000')); // false
1229
- * console.log(isMobile('1380013800a')); // false
1757
+ * Usage:
1758
+ *
1759
+ * ```javascript
1760
+ * const ret1 = isMobile('13800138000');
1761
+ * const ret2 = isMobile('1380013800');
1762
+ * const ret3 = isMobile('138001380000');
1763
+ * const ret4 = isMobile('1380013800a');
1764
+ * console.log(ret1, ret2, ret3, ret4);
1765
+ * ```
1766
+ *
1767
+ * Output:
1768
+ *
1769
+ * ```text
1770
+ * true false false false
1230
1771
  * ```
1231
1772
  *
1232
1773
  * @param mobile
@@ -1237,9 +1778,17 @@ export declare function isValidPhoneNumber(mobile: string): boolean;
1237
1778
  /**
1238
1779
  * Check if the given string is a valid email.
1239
1780
  *
1240
- * @example
1241
- * ```js
1242
- * console.log(isValidEmail('mazeyqian@gmail.com')); // true
1781
+ * Usage:
1782
+ *
1783
+ * ```javascript
1784
+ * const ret = isValidEmail('mazeyqian@gmail.com');
1785
+ * console.log(ret);
1786
+ * ```
1787
+ *
1788
+ * Output:
1789
+ *
1790
+ * ```text
1791
+ * true
1243
1792
  * ```
1244
1793
  *
1245
1794
  * @param email
@@ -1250,13 +1799,21 @@ export declare function isValidEmail(email: string): boolean;
1250
1799
  /**
1251
1800
  * Convert a given 10-hex number to a lowercase 26-hex string.
1252
1801
  *
1253
- * @example
1254
- * ```js
1255
- * console.log(convert10To26(1)); // a
1256
- * console.log(convert10To26(26)); // z
1257
- * console.log(convert10To26(27)); // aa
1258
- * console.log(convert10To26(52)); // az
1259
- * console.log(convert10To26(53)); // ba
1802
+ * Usage:
1803
+ *
1804
+ * ```javascript
1805
+ * const ret1 = convert10To26(1);
1806
+ * const ret2 = convert10To26(26);
1807
+ * const ret3 = convert10To26(27);
1808
+ * const ret4 = convert10To26(52);
1809
+ * const ret5 = convert10To26(53);
1810
+ * console.log(ret1, ret2, ret3, ret4, ret5);
1811
+ * ```
1812
+ *
1813
+ * Output:
1814
+ *
1815
+ * ```text
1816
+ * a z aa az ba
1260
1817
  * ```
1261
1818
  *
1262
1819
  * @param {number} num
@@ -1269,13 +1826,21 @@ export declare function convert10To26(num: number): string;
1269
1826
  *
1270
1827
  * ZH: 获取文件后缀名
1271
1828
  *
1272
- * @example
1273
- * ```js
1274
- * console.log(getUrlFileType('https://example.com/a/b/c.png')); // png
1275
- * console.log(getUrlFileType('https://example.com/a/b/c.jpg')); // jpg
1276
- * console.log(getUrlFileType('https://example.com/a/b/c.jpeg')); // jpeg
1277
- * console.log(getUrlFileType('/a/b/c.jpeg')); // jpeg
1278
- * console.log(getUrlFileType('https://example.com/a/b/c.v/a')); // ''
1829
+ * Usage:
1830
+ *
1831
+ * ```javascript
1832
+ * const ret1 = getUrlFileType('https://example.com/a/b/c.png');
1833
+ * const ret2 = getUrlFileType('https://example.com/a/b/c.jpg');
1834
+ * const ret3 = getUrlFileType('https://example.com/a/b/c.jpeg');
1835
+ * const ret4 = getUrlFileType('/a/b/c.jpeg');
1836
+ * const ret5 = getUrlFileType('https://example.com/a/b/c.v/a');
1837
+ * console.log(ret1, ret2, ret3, ret4, ret5);
1838
+ * ```
1839
+ *
1840
+ * Output:
1841
+ *
1842
+ * ```text
1843
+ * png jpg jpeg jpeg ''
1279
1844
  * ```
1280
1845
  *
1281
1846
  * @param url
@@ -1288,8 +1853,9 @@ export declare function getUrlFileType(url: string): boolean | string;
1288
1853
  * The `src` attribute should contain `width` and/or `height` values in the format "width=100" or "height=100".
1289
1854
  * If jQuery is available, this function uses jQuery to select the images. Otherwise, it uses pure JavaScript.
1290
1855
  *
1291
- * @example
1292
- * ```
1856
+ * Usage:
1857
+ *
1858
+ * ```javascript
1293
1859
  * // Example images with `src` attributes containing `width` and/or `height` values
1294
1860
  * const img1 = document.createElement('img');
1295
1861
  * img1.setAttribute('src', 'https://example.com/example.png?width=2233&height=111');
@@ -1307,10 +1873,20 @@ export declare function setImgWidHeiBySrc(): boolean;
1307
1873
  /**
1308
1874
  * Generate the inline style string from the given parameters. The first parameter is the query selector, and the second parameter is the style array.
1309
1875
  *
1310
- * @example
1311
- * ```js
1312
- * console.log(genStyleString('.a', [ 'color:red' ])); // '.a{color:red;}'
1313
- * console.log(genStyleString('#b', [ 'color:red', 'font-size:12px' ])); // '#b{color:red;font-size:12px;}'
1876
+ * Usage:
1877
+ *
1878
+ * ```javascript
1879
+ * const ret1 = genStyleString('.a', [ 'color:red' ]);
1880
+ * const ret2 = genStyleString('#b', [ 'color:red', 'font-size:12px' ]);
1881
+ * console.log(ret1);
1882
+ * console.log(ret2);
1883
+ * ```
1884
+ *
1885
+ * Output:
1886
+ *
1887
+ * ```text
1888
+ * .a{color:red;}
1889
+ * #b{color:red;font-size:12px;}
1314
1890
  * ```
1315
1891
  *
1316
1892
  * @param {string} selector
@@ -1326,8 +1902,9 @@ export declare function genStyleString(selector: string, styleArray: Array<strin
1326
1902
  *
1327
1903
  * Note that this method will not add the image to the DOM.
1328
1904
  *
1329
- * @example
1330
- * ```js
1905
+ * Usage:
1906
+ *
1907
+ * ```javascript
1331
1908
  * loadImage('https://example.com/example.png')
1332
1909
  * .then((img) => {
1333
1910
  * console.log(img);
@@ -1351,6 +1928,24 @@ export declare function getCurrentVersion(): string;
1351
1928
  /**
1352
1929
  * Repeatedly fires a callback function with a certain interval until a specified condition is met.
1353
1930
  *
1931
+ * Usage:
1932
+ *
1933
+ * ```javascript
1934
+ * repeatUntilConditionMet(
1935
+ * () => {
1936
+ * console.log('repeatUntilConditionMet');
1937
+ * return true;
1938
+ * }, {
1939
+ * interval: 1000,
1940
+ * times: 10,
1941
+ * context: null,
1942
+ * args: [],
1943
+ * }, (result) => {
1944
+ * return result === true;
1945
+ * }
1946
+ * );
1947
+ * ```
1948
+ *
1354
1949
  * @param callback The callback function to fire.
1355
1950
  * @param options An object containing the options for the function.
1356
1951
  * @param options.interval The interval between each firing of the callback function, in milliseconds. Defaults to 1000.
@@ -1364,17 +1959,24 @@ export declare function repeatUntilConditionMet<T extends (...args: UnknownFnPar
1364
1959
  /**
1365
1960
  * Load a script from the given URL if it (`window['attribute']`) has not already been loaded.
1366
1961
  *
1367
- * @example
1368
- * ```js
1369
- * loadScriptIfUndefined('jQuery', 'https://example.com/lib/jquery.min.js')
1962
+ * Usage:
1963
+ *
1964
+ * ```javascript
1965
+ * loadScriptIfUndefined('xyz', 'https://example.com/lib/jquery.min.js')
1370
1966
  * .then(() => {
1371
- * console.log('jQuery is loaded.');
1967
+ * console.log('xyz is loaded.');
1372
1968
  * })
1373
1969
  * .catch(err => {
1374
- * console.log('Failed to load jQuery.', err);
1970
+ * console.log('Failed to load xyz.', err);
1375
1971
  * });
1376
1972
  * ```
1377
1973
  *
1974
+ * Output:
1975
+ *
1976
+ * ```text
1977
+ * xyz is loaded.
1978
+ * ```
1979
+ *
1378
1980
  * @param {string} windowAttribute - The name of the window attribute to check (e.g. `jQuery`, `axios`, etc.).
1379
1981
  * @param {string} url - The URL of the script to load.
1380
1982
  * @returns {Promise} A Promise that resolves when the script has been loaded.
@@ -1384,6 +1986,19 @@ export declare function loadScriptIfUndefined(windowAttribute: string, url: stri
1384
1986
  /**
1385
1987
  * Retrieve a query parameter from a script URL in the browser.
1386
1988
  *
1989
+ * Usage:
1990
+ *
1991
+ * ```javascript
1992
+ * const ret = getScriptQueryParam('test', 'https://example.com/example.js');
1993
+ * console.log(ret);
1994
+ * ```
1995
+ *
1996
+ * Output:
1997
+ *
1998
+ * ```text
1999
+ * hello
2000
+ * ```
2001
+ *
1387
2002
  * @param param - The name of the query parameter to retrieve.
1388
2003
  * @param matchString - An optional substring to match in the script URL.
1389
2004
  * If not provided, defaults to matching the ".js" substring.
@@ -1394,6 +2009,20 @@ export declare function getScriptQueryParam(param: string, matchString?: string)
1394
2009
  /**
1395
2010
  * Wait for a specified amount of time.
1396
2011
  *
2012
+ * Usage:
2013
+ *
2014
+ * ```javascript
2015
+ * waitTime(1000).then((time) => {
2016
+ * console.log('waitTime:', time);
2017
+ * });
2018
+ * ```
2019
+ *
2020
+ * Output:
2021
+ *
2022
+ * ```text
2023
+ * waitTime: 1000
2024
+ * ```
2025
+ *
1397
2026
  * @param time The amount of time to wait, in milliseconds.
1398
2027
  * @returns A Promise that resolves after the specified time has elapsed.
1399
2028
  * @category Util