mazey 3.5.4 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -51
- package/README_CN.md +4 -2
- package/lib/index.cjs.js +3607 -2753
- package/lib/index.d.ts +274 -42
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +3602 -2754
- package/lib/mazey.min.js +2 -2
- package/package.json +1 -1
- package/scripts/env.sh +2 -0
- package/src/index.ts +328 -45
- package/src/preview.js +0 -44
package/lib/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* @param {string} aStr String
|
|
22
22
|
* @param {string} bStr String
|
|
23
23
|
* @returns {number} Length
|
|
24
|
+
* @category Calculate and Formula
|
|
24
25
|
*/
|
|
25
26
|
export declare function calLongestCommonSubstring(aStr: string, bStr: string): number;
|
|
26
27
|
/**
|
|
@@ -43,6 +44,7 @@ export declare function calLongestCommonSubstring(aStr: string, bStr: string): n
|
|
|
43
44
|
* @param {string} aStr 字符串
|
|
44
45
|
* @param {string} bStr 字符串
|
|
45
46
|
* @returns {number} 长度
|
|
47
|
+
* @category Calculate and Formula
|
|
46
48
|
*/
|
|
47
49
|
export declare function calLongestCommonSubsequence(aStr: string, bStr: string): number;
|
|
48
50
|
/**
|
|
@@ -154,6 +156,7 @@ export declare function getDomain(url: string, rules?: string[]): string;
|
|
|
154
156
|
*
|
|
155
157
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
156
158
|
* @returns {string} 'a-b-c'
|
|
159
|
+
* @category Util
|
|
157
160
|
*/
|
|
158
161
|
export declare function camelCaseToKebabCase(camelCase: string): string;
|
|
159
162
|
/**
|
|
@@ -166,6 +169,7 @@ export declare function camelCaseToKebabCase(camelCase: string): string;
|
|
|
166
169
|
*
|
|
167
170
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
168
171
|
* @returns {string} 'a_b_c'
|
|
172
|
+
* @category Util
|
|
169
173
|
*/
|
|
170
174
|
export declare function camelCase2Underscore(camelCase: string): string;
|
|
171
175
|
/**
|
|
@@ -178,13 +182,20 @@ export declare function camelCase2Underscore(camelCase: string): string;
|
|
|
178
182
|
*
|
|
179
183
|
* @param {string} str The string to trim.
|
|
180
184
|
* @returns {string} Trimmed string.
|
|
185
|
+
* @category Util
|
|
181
186
|
*/
|
|
182
187
|
export declare function mTrim(str: string): string;
|
|
183
188
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
189
|
+
* Make a newline of HTML.
|
|
190
|
+
*
|
|
191
|
+
* ```
|
|
192
|
+
* newLine('a\nb\nc'); // 'a<br />b<br />c'
|
|
193
|
+
* newLine('a\n\nbc'); // 'a<br /><br />bc'
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
186
196
|
* @param {string} str The string to make a newline.
|
|
187
197
|
* @returns {string} A newline with `br`.
|
|
198
|
+
* @category DOM
|
|
188
199
|
*/
|
|
189
200
|
export declare function newLine(str: string): string;
|
|
190
201
|
/**
|
|
@@ -206,6 +217,7 @@ export declare function newLine(str: string): string;
|
|
|
206
217
|
*
|
|
207
218
|
* @param {object} obj The value to clone.
|
|
208
219
|
* @returns {object} Returns the deep cloned value.
|
|
220
|
+
* @category Util
|
|
209
221
|
*/
|
|
210
222
|
export declare function deepCopyObject(obj: any): any;
|
|
211
223
|
/**
|
|
@@ -224,13 +236,23 @@ export declare function deepCopyObject(obj: any): any;
|
|
|
224
236
|
* false
|
|
225
237
|
* true
|
|
226
238
|
* ```
|
|
239
|
+
*
|
|
240
|
+
* @param {string} str The string to check.
|
|
241
|
+
* @returns {boolean} Return the result of checking.
|
|
242
|
+
* @category Util
|
|
227
243
|
*/
|
|
228
244
|
export declare function isJsonString(str: string): boolean;
|
|
229
245
|
/**
|
|
230
|
-
*
|
|
231
|
-
*
|
|
246
|
+
* Produce a random string of number, `generateRndNum(7)` => '7658495'.
|
|
247
|
+
*
|
|
248
|
+
* ```
|
|
249
|
+
* generateRndNum(4); // '9730'
|
|
250
|
+
* generateRndNum(7); // '2262490'
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
232
253
|
* @param {number} n Length
|
|
233
254
|
* @returns {string} Return the random string.
|
|
255
|
+
* @category Util
|
|
234
256
|
*/
|
|
235
257
|
export declare function generateRndNum(n?: number): string;
|
|
236
258
|
/**
|
|
@@ -257,15 +279,54 @@ export declare function floatFixed(num: string, size?: number): string;
|
|
|
257
279
|
*/
|
|
258
280
|
export declare function cancelBubble(e: any): void;
|
|
259
281
|
/**
|
|
260
|
-
*
|
|
282
|
+
* Modify `class`.
|
|
283
|
+
*
|
|
284
|
+
* ```
|
|
285
|
+
* const dom = document.querySelector('#box');
|
|
286
|
+
*
|
|
287
|
+
* // Determine `class`
|
|
288
|
+
* hasClass(dom, 'test');
|
|
289
|
+
* // Add `class`
|
|
290
|
+
* addClass(dom, 'test');
|
|
291
|
+
* // Remove `class`
|
|
292
|
+
* removeClass(dom, 'test');
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* @category DOM
|
|
261
296
|
*/
|
|
262
297
|
export declare function hasClass(obj: any, cls: string): boolean;
|
|
263
298
|
/**
|
|
264
|
-
*
|
|
299
|
+
* Modify `class`.
|
|
300
|
+
*
|
|
301
|
+
* ```
|
|
302
|
+
* const dom = document.querySelector('#box');
|
|
303
|
+
*
|
|
304
|
+
* // Determine `class`
|
|
305
|
+
* hasClass(dom, 'test');
|
|
306
|
+
* // Add `class`
|
|
307
|
+
* addClass(dom, 'test');
|
|
308
|
+
* // Remove `class`
|
|
309
|
+
* removeClass(dom, 'test');
|
|
310
|
+
* ```
|
|
311
|
+
*
|
|
312
|
+
* @category DOM
|
|
265
313
|
*/
|
|
266
314
|
export declare function addClass(obj: any, cls: string): void;
|
|
267
315
|
/**
|
|
268
|
-
*
|
|
316
|
+
* Modify `class`.
|
|
317
|
+
*
|
|
318
|
+
* ```
|
|
319
|
+
* const dom = document.querySelector('#box');
|
|
320
|
+
*
|
|
321
|
+
* // Determine `class`
|
|
322
|
+
* hasClass(dom, 'test');
|
|
323
|
+
* // Add `class`
|
|
324
|
+
* addClass(dom, 'test');
|
|
325
|
+
* // Remove `class`
|
|
326
|
+
* removeClass(dom, 'test');
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* @category DOM
|
|
269
330
|
*/
|
|
270
331
|
export declare function removeClass(obj: any, cls: string): void;
|
|
271
332
|
/**
|
|
@@ -280,6 +341,8 @@ export declare function removeClass(obj: any, cls: string): void;
|
|
|
280
341
|
* ```
|
|
281
342
|
*
|
|
282
343
|
* Reference: [Lodash](https://lodash.com/docs/4.17.15#throttle)
|
|
344
|
+
*
|
|
345
|
+
* @category Util
|
|
283
346
|
*/
|
|
284
347
|
export declare function throttle(func: any, wait: number, options?: {
|
|
285
348
|
leading?: boolean;
|
|
@@ -295,6 +358,8 @@ export declare function throttle(func: any, wait: number, options?: {
|
|
|
295
358
|
* console.log('The debounced function will only be invoked in 1000 milliseconds, the other invoking will disappear during the wait time.');
|
|
296
359
|
* }, 1000, true);
|
|
297
360
|
* ```
|
|
361
|
+
*
|
|
362
|
+
* @category Util
|
|
298
363
|
*/
|
|
299
364
|
export declare function debounce(func: any, wait: number, immediate?: any): any;
|
|
300
365
|
/**
|
|
@@ -327,6 +392,7 @@ export declare function friendlyInterval(start?: number, end?: number, options?:
|
|
|
327
392
|
* @param {boolean} options.isNaNAsNumber 是否 NaN 算数字(默认不算)
|
|
328
393
|
* @param {boolean} options.isUnFiniteAsNumber 是否 无限 算数字(默认不算)
|
|
329
394
|
* @returns {boolean} true 是数字
|
|
395
|
+
* @category Util
|
|
330
396
|
*/
|
|
331
397
|
export declare function isNumber(num: any, options?: {
|
|
332
398
|
isNaNAsNumber?: boolean;
|
|
@@ -339,31 +405,111 @@ export declare function isNumber(num: any, options?: {
|
|
|
339
405
|
*/
|
|
340
406
|
export declare function doFn(fn: any, ...params: any[]): any;
|
|
341
407
|
/**
|
|
342
|
-
*
|
|
343
|
-
*
|
|
408
|
+
* EN: Handle Storage (Keep fit for JSON, it can tansfer format automatically).
|
|
409
|
+
*
|
|
410
|
+
* ZH: 存储/获取数据到 sessionStorage/localStorage
|
|
411
|
+
*
|
|
412
|
+
* ```
|
|
413
|
+
* setSessionStorage('test', '123');
|
|
414
|
+
* getSessionStorage('test'); // 123
|
|
415
|
+
* setLocalStorage('test', '123');
|
|
416
|
+
* getLocalStorage('test'); // 123
|
|
417
|
+
*
|
|
418
|
+
* // or package in usage
|
|
419
|
+
* const projectName = 'mazey';
|
|
420
|
+
* function mSetLocalStorage (key, value) {
|
|
421
|
+
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
422
|
+
* }
|
|
423
|
+
*
|
|
424
|
+
* function mGetLocalStorage (key) {
|
|
425
|
+
* return getLocalStorage(`${projectName}_${key}`);
|
|
426
|
+
* }
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
344
429
|
* @param {string} key 键
|
|
345
|
-
* @
|
|
430
|
+
* @returns {any} 返回值
|
|
431
|
+
* @category Cache Data
|
|
346
432
|
*/
|
|
347
433
|
export declare function setSessionStorage(key: string, value?: any): void;
|
|
348
434
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
435
|
+
* EN: Handle Storage (Keep fit for JSON, it can tansfer format automatically).
|
|
436
|
+
*
|
|
437
|
+
* ZH: 存储/获取数据到 sessionStorage/localStorage
|
|
438
|
+
*
|
|
439
|
+
* ```
|
|
440
|
+
* setSessionStorage('test', '123');
|
|
441
|
+
* getSessionStorage('test'); // 123
|
|
442
|
+
* setLocalStorage('test', '123');
|
|
443
|
+
* getLocalStorage('test'); // 123
|
|
444
|
+
*
|
|
445
|
+
* // or package in usage
|
|
446
|
+
* const projectName = 'mazey';
|
|
447
|
+
* function mSetLocalStorage (key, value) {
|
|
448
|
+
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
449
|
+
* }
|
|
450
|
+
*
|
|
451
|
+
* function mGetLocalStorage (key) {
|
|
452
|
+
* return getLocalStorage(`${projectName}_${key}`);
|
|
453
|
+
* }
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
351
456
|
* @param {string} key 键
|
|
352
|
-
* @returns {
|
|
457
|
+
* @returns {any} 返回值
|
|
458
|
+
* @category Cache Data
|
|
353
459
|
*/
|
|
354
460
|
export declare function getSessionStorage(key: string): any;
|
|
355
461
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
462
|
+
* EN: Handle Storage (Keep fit for JSON, it can tansfer format automatically).
|
|
463
|
+
*
|
|
464
|
+
* ZH: 存储/获取数据到 sessionStorage/localStorage
|
|
465
|
+
*
|
|
466
|
+
* ```
|
|
467
|
+
* setSessionStorage('test', '123');
|
|
468
|
+
* getSessionStorage('test'); // 123
|
|
469
|
+
* setLocalStorage('test', '123');
|
|
470
|
+
* getLocalStorage('test'); // 123
|
|
471
|
+
*
|
|
472
|
+
* // or package in usage
|
|
473
|
+
* const projectName = 'mazey';
|
|
474
|
+
* function mSetLocalStorage (key, value) {
|
|
475
|
+
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
476
|
+
* }
|
|
477
|
+
*
|
|
478
|
+
* function mGetLocalStorage (key) {
|
|
479
|
+
* return getLocalStorage(`${projectName}_${key}`);
|
|
480
|
+
* }
|
|
481
|
+
* ```
|
|
482
|
+
*
|
|
358
483
|
* @param {string} key 键
|
|
359
|
-
* @
|
|
484
|
+
* @returns {any} 返回值
|
|
485
|
+
* @category Cache Data
|
|
360
486
|
*/
|
|
361
487
|
export declare function setLocalStorage(key: string, value?: any): void;
|
|
362
488
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
489
|
+
* EN: Handle Storage (Keep fit for JSON, it can tansfer format automatically).
|
|
490
|
+
*
|
|
491
|
+
* ZH: 存储/获取数据到 sessionStorage/localStorage
|
|
492
|
+
*
|
|
493
|
+
* ```
|
|
494
|
+
* setSessionStorage('test', '123');
|
|
495
|
+
* getSessionStorage('test'); // 123
|
|
496
|
+
* setLocalStorage('test', '123');
|
|
497
|
+
* getLocalStorage('test'); // 123
|
|
498
|
+
*
|
|
499
|
+
* // or package in usage
|
|
500
|
+
* const projectName = 'mazey';
|
|
501
|
+
* function mSetLocalStorage (key, value) {
|
|
502
|
+
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
503
|
+
* }
|
|
504
|
+
*
|
|
505
|
+
* function mGetLocalStorage (key) {
|
|
506
|
+
* return getLocalStorage(`${projectName}_${key}`);
|
|
507
|
+
* }
|
|
508
|
+
* ```
|
|
509
|
+
*
|
|
365
510
|
* @param {string} key 键
|
|
366
|
-
* @returns {
|
|
511
|
+
* @returns {any} 返回值
|
|
512
|
+
* @category Cache Data
|
|
367
513
|
*/
|
|
368
514
|
export declare function getLocalStorage(key: string): any;
|
|
369
515
|
/**
|
|
@@ -444,13 +590,29 @@ export declare function loadScript(url: string, options?: {
|
|
|
444
590
|
*/
|
|
445
591
|
export declare function mNow(): number;
|
|
446
592
|
/**
|
|
447
|
-
*
|
|
448
|
-
*
|
|
593
|
+
* EN: Handle Cookie.
|
|
594
|
+
*
|
|
595
|
+
* ZH: 设置/获取 Cookie
|
|
596
|
+
*
|
|
597
|
+
* ```
|
|
598
|
+
* setCookie('test', '123', 30, 'example.com'); // key value day domain
|
|
599
|
+
* getCookie('test'); // 123
|
|
600
|
+
* ```
|
|
601
|
+
*
|
|
602
|
+
* @category Cache Data
|
|
449
603
|
*/
|
|
450
604
|
export declare function setCookie(name: string, value: string, days: number, domain: string): void;
|
|
451
605
|
/**
|
|
452
|
-
*
|
|
453
|
-
*
|
|
606
|
+
* EN: Handle Cookie.
|
|
607
|
+
*
|
|
608
|
+
* ZH: 设置/获取 Cookie
|
|
609
|
+
*
|
|
610
|
+
* ```
|
|
611
|
+
* setCookie('test', '123', 30, 'example.com'); // key value day domain
|
|
612
|
+
* getCookie('test'); // 123
|
|
613
|
+
* ```
|
|
614
|
+
*
|
|
615
|
+
* @category Cache Data
|
|
454
616
|
*/
|
|
455
617
|
export declare function getCookie(name: string): string;
|
|
456
618
|
/**
|
|
@@ -500,6 +662,7 @@ interface WebPerformance {
|
|
|
500
662
|
*
|
|
501
663
|
* @param {boolean} camelCase -- false(默认) 以下划线形式返回数据 true 以驼峰形式返回数据
|
|
502
664
|
* @returns {Promise<object>} 加载数据
|
|
665
|
+
* @category Web Performance
|
|
503
666
|
*/
|
|
504
667
|
export declare function getPerformance(camelCase?: boolean): Promise<WebPerformance | Error>;
|
|
505
668
|
/**
|
|
@@ -537,10 +700,11 @@ export declare function getPerformance(camelCase?: boolean): Promise<WebPerforma
|
|
|
537
700
|
*
|
|
538
701
|
* @param {number} rate -- 0.1 ~ 1 => 1% ~ 100%
|
|
539
702
|
* @returns {boolean} true 命中
|
|
703
|
+
* @category Calculate and Formula
|
|
540
704
|
*/
|
|
541
705
|
export declare function inRate(rate: number): boolean;
|
|
542
706
|
/**
|
|
543
|
-
* EN: Determine if it is a secure PWA environment that it can run.
|
|
707
|
+
* EN: Detect the margin of Safety. Determine if it is a secure PWA environment that it can run.
|
|
544
708
|
*
|
|
545
709
|
* ZH: 判断是否是安全的 PWA 环境
|
|
546
710
|
*
|
|
@@ -557,6 +721,7 @@ export declare function inRate(rate: number): boolean;
|
|
|
557
721
|
* ```
|
|
558
722
|
*
|
|
559
723
|
* @returns {boolean} true 是
|
|
724
|
+
* @category Browser Information
|
|
560
725
|
*/
|
|
561
726
|
export declare function isSafePWAEnv(): boolean;
|
|
562
727
|
/**
|
|
@@ -578,18 +743,18 @@ export declare function isSafePWAEnv(): boolean;
|
|
|
578
743
|
*
|
|
579
744
|
* Results:
|
|
580
745
|
*
|
|
581
|
-
* |
|
|
582
|
-
* | --- | --- | --- |
|
|
583
|
-
* | System |
|
|
584
|
-
* | System version |
|
|
585
|
-
* | Platform |
|
|
586
|
-
* | Engine |
|
|
587
|
-
* | Engine version |
|
|
588
|
-
* | Supporter |
|
|
589
|
-
* | Supporter version |
|
|
590
|
-
* | Shell |
|
|
591
|
-
* | Shell version |
|
|
592
|
-
* | Apple device type |
|
|
746
|
+
* | Attribute | Description | Type | Values |
|
|
747
|
+
* | --- | --- | --- | --- |
|
|
748
|
+
* | **system** | System | string | android, ios, windows, macos, linux |
|
|
749
|
+
* | systemVs | System version | string | windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 <br />macos: ... |
|
|
750
|
+
* | platform | Platform | string | desktop, mobile |
|
|
751
|
+
* | engine | Engine | string | webkit, gecko, presto, trident |
|
|
752
|
+
* | engineVs | Engine version | string | - |
|
|
753
|
+
* | supporter | Supporter | string | edge, opera, chrome, safari, firefox, iexplore |
|
|
754
|
+
* | supporterVs | Supporter version | string | - |
|
|
755
|
+
* | shell | Shell | string | (Optional) wechat, qq_browser, qq_app, uc, 360, 2345, sougou, liebao, maxthon, bilibili |
|
|
756
|
+
* | shellVs | Shell version | string | (Optional) 20/... |
|
|
757
|
+
* | appleType | Apple device type | string | (Optional) ipad, iphone, ipod, iwatch |
|
|
593
758
|
*
|
|
594
759
|
* Example: Determine the environment of the mobile QQ.
|
|
595
760
|
*
|
|
@@ -652,7 +817,7 @@ export declare function windowLoaded(timeout?: number): Promise<string | Error>;
|
|
|
652
817
|
/**
|
|
653
818
|
* EN: Add `<style>` in `<head>`.
|
|
654
819
|
*
|
|
655
|
-
* ZH: 添加样式标签; style: 样式标签内的字符串; id: `<style>` 标签的 `id`; 返回:
|
|
820
|
+
* ZH: 添加样式标签; style: 样式标签内的字符串; id: `<style>` 标签的 `id`; 返回: 添加成功/失败
|
|
656
821
|
*
|
|
657
822
|
* Example 1: Add the `<style>` with `id`, and repeated invoking will update the content instead of adding a new one.
|
|
658
823
|
*
|
|
@@ -680,20 +845,18 @@ export declare function windowLoaded(timeout?: number): Promise<string | Error>;
|
|
|
680
845
|
* addStyle(
|
|
681
846
|
* `
|
|
682
847
|
* body {
|
|
683
|
-
* background-color: #
|
|
848
|
+
* background-color: #444;
|
|
684
849
|
* }
|
|
685
850
|
* `
|
|
686
851
|
* );
|
|
687
852
|
* // <style>
|
|
688
853
|
* // body {
|
|
689
|
-
* // background-color: #
|
|
854
|
+
* // background-color: #444;
|
|
690
855
|
* // }
|
|
691
856
|
* // </style>
|
|
692
857
|
* ```
|
|
693
858
|
*
|
|
694
|
-
* @
|
|
695
|
-
* @param options.id `id` in `<style>`
|
|
696
|
-
* @returns Success/Fail
|
|
859
|
+
* @category DOM
|
|
697
860
|
*/
|
|
698
861
|
export declare function addStyle(style: string, options?: {
|
|
699
862
|
id?: string;
|
|
@@ -727,6 +890,7 @@ export declare function addStyle(style: string, options?: {
|
|
|
727
890
|
* @param {function} logFn The function with Log.
|
|
728
891
|
* @param {function} errorFn The function with Error.
|
|
729
892
|
* @returns {object} 新实例
|
|
893
|
+
* @category Debug
|
|
730
894
|
*/
|
|
731
895
|
export declare function genCustomConsole(prefix?: string, options?: {
|
|
732
896
|
isClosed?: boolean;
|
|
@@ -784,6 +948,7 @@ export declare function isNonEmptyArray(arr: any[]): boolean;
|
|
|
784
948
|
* @param {string[]} attributes Data Attributes
|
|
785
949
|
* @param {any} validValue Given Value for verifying.
|
|
786
950
|
* @returns {boolean} Return TRUE if the data is valid.
|
|
951
|
+
* @category Util
|
|
787
952
|
*/
|
|
788
953
|
export declare function isValidData(data: any, attributes: string[], validValue: any): boolean;
|
|
789
954
|
/**
|
|
@@ -826,7 +991,74 @@ export declare function genHashCode(str: string): number;
|
|
|
826
991
|
* @param {Date|number|string} dateIns Original Date
|
|
827
992
|
* @param {string} format Format String
|
|
828
993
|
* @returns {string} Return the formatted date string.
|
|
994
|
+
* @category Util
|
|
829
995
|
*/
|
|
830
996
|
export declare function formatDate(dateIns?: Date | number | string, format?: string): string;
|
|
997
|
+
/**
|
|
998
|
+
* Get event container.
|
|
999
|
+
*
|
|
1000
|
+
* @category Event
|
|
1001
|
+
* @hidden
|
|
1002
|
+
*/
|
|
1003
|
+
export declare function getDefineListeners(): DefineListeners;
|
|
1004
|
+
/**
|
|
1005
|
+
* Add event.
|
|
1006
|
+
*
|
|
1007
|
+
* @param type
|
|
1008
|
+
* @param fn
|
|
1009
|
+
* @category Event
|
|
1010
|
+
*/
|
|
1011
|
+
export declare function addEvent(type: string, fn: any): void;
|
|
1012
|
+
/**
|
|
1013
|
+
* Invoke event.
|
|
1014
|
+
*
|
|
1015
|
+
* @param type
|
|
1016
|
+
* @category Event
|
|
1017
|
+
*/
|
|
1018
|
+
export declare function invokeEvent(type: string): void;
|
|
1019
|
+
/**
|
|
1020
|
+
* Remove event.
|
|
1021
|
+
*
|
|
1022
|
+
* @param type
|
|
1023
|
+
* @param fn
|
|
1024
|
+
* @category Event
|
|
1025
|
+
*/
|
|
1026
|
+
export declare function removeEvent(type: string, fn: any): void;
|
|
1027
|
+
/**
|
|
1028
|
+
* Check if the given string is a valid url.
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```js
|
|
1032
|
+
* console.log(isUrl('https://www.google.com')); // true
|
|
1033
|
+
* console.log(isUrl('https://www.google.com/')); // true
|
|
1034
|
+
* console.log(isUrl('https://www.google.com/?q=hello')); // true
|
|
1035
|
+
* console.log(isUrl('https://www.google.com/?q=hello#world')); // true
|
|
1036
|
+
* console.log(isUrl('https://www.google.com/#world')); // true
|
|
1037
|
+
* console.log(isUrl('https://www.google.com/#')); // true
|
|
1038
|
+
* console.log(isUrl('https://www.google.com/#?q=hello')); // true
|
|
1039
|
+
* console.log(isUrl('https://www.google.com/#?q=hello#world')); // true
|
|
1040
|
+
* ```
|
|
1041
|
+
*
|
|
1042
|
+
* @param url
|
|
1043
|
+
* @returns {boolean} Return true if the given url is a valid url.
|
|
1044
|
+
* @category URL
|
|
1045
|
+
*/
|
|
1046
|
+
export declare function isValidUrl(url: string): boolean;
|
|
1047
|
+
/**
|
|
1048
|
+
* Check if the given string is a mobile phone number.
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```js
|
|
1052
|
+
* console.log(isMobile('13800138000')); // true
|
|
1053
|
+
* console.log(isMobile('1380013800')); // false
|
|
1054
|
+
* console.log(isMobile('138001380000')); // false
|
|
1055
|
+
* console.log(isMobile('1380013800a')); // false
|
|
1056
|
+
* ```
|
|
1057
|
+
*
|
|
1058
|
+
* @param mobile
|
|
1059
|
+
* @returns {boolean} Return true if the given string is a mobile phone number.
|
|
1060
|
+
* @category Util
|
|
1061
|
+
*/
|
|
1062
|
+
export declare function isValidPhoneNumber(mobile: string): boolean;
|
|
831
1063
|
export {};
|
|
832
1064
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB5E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CA8BR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAmBzE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,MAAM,CAQR;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQvD;AAED;;;;;;;;;;;;;;;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