mazey 3.5.3 → 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 +226 -178
- package/README_CN.md +4 -2
- package/lib/index.cjs.js +3619 -2756
- package/lib/index.d.ts +286 -42
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +3614 -2757
- package/lib/mazey.min.js +2 -2
- package/package.json +4 -3
- package/scripts/env.sh +2 -0
- package/src/index.ts +343 -48
- 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
|
/**
|
|
@@ -57,6 +59,7 @@ export declare function calLongestCommonSubsequence(aStr: string, bStr: string):
|
|
|
57
59
|
*
|
|
58
60
|
* @param {string} param Query param.
|
|
59
61
|
* @returns {string} value
|
|
62
|
+
* @category URL
|
|
60
63
|
*/
|
|
61
64
|
export declare function getQueryParam(param: string): string;
|
|
62
65
|
/**
|
|
@@ -70,6 +73,7 @@ export declare function getQueryParam(param: string): string;
|
|
|
70
73
|
* @param {string} url URL string.
|
|
71
74
|
* @param {string} param Query param.
|
|
72
75
|
* @returns {string} value
|
|
76
|
+
* @category URL
|
|
73
77
|
*/
|
|
74
78
|
export declare function getUrlParam(url: string, param: string): string | string[];
|
|
75
79
|
/**
|
|
@@ -93,6 +97,7 @@ export declare function getUrlParam(url: string, param: string): string | string
|
|
|
93
97
|
* @param {string} param Query param.
|
|
94
98
|
* @param {string} value Param's value.
|
|
95
99
|
* @returns {string} URL.
|
|
100
|
+
* @category URL
|
|
96
101
|
*/
|
|
97
102
|
export declare function updateQueryParam(url: string, param: string, value: string): string;
|
|
98
103
|
/**
|
|
@@ -116,6 +121,7 @@ export declare function updateQueryParam(url: string, param: string, value: stri
|
|
|
116
121
|
*
|
|
117
122
|
* @param {string} param Query param.
|
|
118
123
|
* @returns {string} value
|
|
124
|
+
* @category URL
|
|
119
125
|
*/
|
|
120
126
|
export declare function getHashQueryParam(param: string): string;
|
|
121
127
|
/**
|
|
@@ -137,6 +143,7 @@ export declare function getHashQueryParam(param: string): string;
|
|
|
137
143
|
*
|
|
138
144
|
* @param {string} url
|
|
139
145
|
* @param {array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
|
|
146
|
+
* @category URL
|
|
140
147
|
*/
|
|
141
148
|
export declare function getDomain(url: string, rules?: string[]): string;
|
|
142
149
|
/**
|
|
@@ -149,6 +156,7 @@ export declare function getDomain(url: string, rules?: string[]): string;
|
|
|
149
156
|
*
|
|
150
157
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
151
158
|
* @returns {string} 'a-b-c'
|
|
159
|
+
* @category Util
|
|
152
160
|
*/
|
|
153
161
|
export declare function camelCaseToKebabCase(camelCase: string): string;
|
|
154
162
|
/**
|
|
@@ -161,6 +169,7 @@ export declare function camelCaseToKebabCase(camelCase: string): string;
|
|
|
161
169
|
*
|
|
162
170
|
* @param {string} camelCase 'aBC' or 'ABC'
|
|
163
171
|
* @returns {string} 'a_b_c'
|
|
172
|
+
* @category Util
|
|
164
173
|
*/
|
|
165
174
|
export declare function camelCase2Underscore(camelCase: string): string;
|
|
166
175
|
/**
|
|
@@ -173,13 +182,20 @@ export declare function camelCase2Underscore(camelCase: string): string;
|
|
|
173
182
|
*
|
|
174
183
|
* @param {string} str The string to trim.
|
|
175
184
|
* @returns {string} Trimmed string.
|
|
185
|
+
* @category Util
|
|
176
186
|
*/
|
|
177
187
|
export declare function mTrim(str: string): string;
|
|
178
188
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
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
|
+
*
|
|
181
196
|
* @param {string} str The string to make a newline.
|
|
182
197
|
* @returns {string} A newline with `br`.
|
|
198
|
+
* @category DOM
|
|
183
199
|
*/
|
|
184
200
|
export declare function newLine(str: string): string;
|
|
185
201
|
/**
|
|
@@ -201,6 +217,7 @@ export declare function newLine(str: string): string;
|
|
|
201
217
|
*
|
|
202
218
|
* @param {object} obj The value to clone.
|
|
203
219
|
* @returns {object} Returns the deep cloned value.
|
|
220
|
+
* @category Util
|
|
204
221
|
*/
|
|
205
222
|
export declare function deepCopyObject(obj: any): any;
|
|
206
223
|
/**
|
|
@@ -219,13 +236,23 @@ export declare function deepCopyObject(obj: any): any;
|
|
|
219
236
|
* false
|
|
220
237
|
* true
|
|
221
238
|
* ```
|
|
239
|
+
*
|
|
240
|
+
* @param {string} str The string to check.
|
|
241
|
+
* @returns {boolean} Return the result of checking.
|
|
242
|
+
* @category Util
|
|
222
243
|
*/
|
|
223
244
|
export declare function isJsonString(str: string): boolean;
|
|
224
245
|
/**
|
|
225
|
-
*
|
|
226
|
-
*
|
|
246
|
+
* Produce a random string of number, `generateRndNum(7)` => '7658495'.
|
|
247
|
+
*
|
|
248
|
+
* ```
|
|
249
|
+
* generateRndNum(4); // '9730'
|
|
250
|
+
* generateRndNum(7); // '2262490'
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
227
253
|
* @param {number} n Length
|
|
228
254
|
* @returns {string} Return the random string.
|
|
255
|
+
* @category Util
|
|
229
256
|
*/
|
|
230
257
|
export declare function generateRndNum(n?: number): string;
|
|
231
258
|
/**
|
|
@@ -252,15 +279,54 @@ export declare function floatFixed(num: string, size?: number): string;
|
|
|
252
279
|
*/
|
|
253
280
|
export declare function cancelBubble(e: any): void;
|
|
254
281
|
/**
|
|
255
|
-
*
|
|
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
|
|
256
296
|
*/
|
|
257
297
|
export declare function hasClass(obj: any, cls: string): boolean;
|
|
258
298
|
/**
|
|
259
|
-
*
|
|
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
|
|
260
313
|
*/
|
|
261
314
|
export declare function addClass(obj: any, cls: string): void;
|
|
262
315
|
/**
|
|
263
|
-
*
|
|
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
|
|
264
330
|
*/
|
|
265
331
|
export declare function removeClass(obj: any, cls: string): void;
|
|
266
332
|
/**
|
|
@@ -275,6 +341,8 @@ export declare function removeClass(obj: any, cls: string): void;
|
|
|
275
341
|
* ```
|
|
276
342
|
*
|
|
277
343
|
* Reference: [Lodash](https://lodash.com/docs/4.17.15#throttle)
|
|
344
|
+
*
|
|
345
|
+
* @category Util
|
|
278
346
|
*/
|
|
279
347
|
export declare function throttle(func: any, wait: number, options?: {
|
|
280
348
|
leading?: boolean;
|
|
@@ -290,6 +358,8 @@ export declare function throttle(func: any, wait: number, options?: {
|
|
|
290
358
|
* console.log('The debounced function will only be invoked in 1000 milliseconds, the other invoking will disappear during the wait time.');
|
|
291
359
|
* }, 1000, true);
|
|
292
360
|
* ```
|
|
361
|
+
*
|
|
362
|
+
* @category Util
|
|
293
363
|
*/
|
|
294
364
|
export declare function debounce(func: any, wait: number, immediate?: any): any;
|
|
295
365
|
/**
|
|
@@ -322,6 +392,7 @@ export declare function friendlyInterval(start?: number, end?: number, options?:
|
|
|
322
392
|
* @param {boolean} options.isNaNAsNumber 是否 NaN 算数字(默认不算)
|
|
323
393
|
* @param {boolean} options.isUnFiniteAsNumber 是否 无限 算数字(默认不算)
|
|
324
394
|
* @returns {boolean} true 是数字
|
|
395
|
+
* @category Util
|
|
325
396
|
*/
|
|
326
397
|
export declare function isNumber(num: any, options?: {
|
|
327
398
|
isNaNAsNumber?: boolean;
|
|
@@ -334,31 +405,111 @@ export declare function isNumber(num: any, options?: {
|
|
|
334
405
|
*/
|
|
335
406
|
export declare function doFn(fn: any, ...params: any[]): any;
|
|
336
407
|
/**
|
|
337
|
-
*
|
|
338
|
-
*
|
|
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
|
+
*
|
|
339
429
|
* @param {string} key 键
|
|
340
|
-
* @
|
|
430
|
+
* @returns {any} 返回值
|
|
431
|
+
* @category Cache Data
|
|
341
432
|
*/
|
|
342
433
|
export declare function setSessionStorage(key: string, value?: any): void;
|
|
343
434
|
/**
|
|
344
|
-
*
|
|
345
|
-
*
|
|
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
|
+
*
|
|
346
456
|
* @param {string} key 键
|
|
347
|
-
* @returns {
|
|
457
|
+
* @returns {any} 返回值
|
|
458
|
+
* @category Cache Data
|
|
348
459
|
*/
|
|
349
460
|
export declare function getSessionStorage(key: string): any;
|
|
350
461
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
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
|
+
*
|
|
353
483
|
* @param {string} key 键
|
|
354
|
-
* @
|
|
484
|
+
* @returns {any} 返回值
|
|
485
|
+
* @category Cache Data
|
|
355
486
|
*/
|
|
356
487
|
export declare function setLocalStorage(key: string, value?: any): void;
|
|
357
488
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
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
|
+
*
|
|
360
510
|
* @param {string} key 键
|
|
361
|
-
* @returns {
|
|
511
|
+
* @returns {any} 返回值
|
|
512
|
+
* @category Cache Data
|
|
362
513
|
*/
|
|
363
514
|
export declare function getLocalStorage(key: string): any;
|
|
364
515
|
/**
|
|
@@ -388,6 +539,7 @@ export declare function getLocalStorage(key: string): any;
|
|
|
388
539
|
* @param {string} url -- css资源路径
|
|
389
540
|
* @param {string} options.id -- link标签id
|
|
390
541
|
* @returns {Promise<boolean>} true -- 加载成功
|
|
542
|
+
* @category Load Resource
|
|
391
543
|
*/
|
|
392
544
|
export declare function loadCSS(url: string, options?: {
|
|
393
545
|
id?: string;
|
|
@@ -424,6 +576,7 @@ export declare function loadCSS(url: string, options?: {
|
|
|
424
576
|
* @param {number} options.timeout -- 超时时长
|
|
425
577
|
* @param {boolean} options.isDefer -- 是否添加 defer 标签
|
|
426
578
|
* @returns {Promise<boolean>} -- true 成功
|
|
579
|
+
* @category Load Resource
|
|
427
580
|
*/
|
|
428
581
|
export declare function loadScript(url: string, options?: {
|
|
429
582
|
id?: string;
|
|
@@ -437,15 +590,34 @@ export declare function loadScript(url: string, options?: {
|
|
|
437
590
|
*/
|
|
438
591
|
export declare function mNow(): number;
|
|
439
592
|
/**
|
|
440
|
-
*
|
|
441
|
-
*
|
|
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
|
|
442
603
|
*/
|
|
443
604
|
export declare function setCookie(name: string, value: string, days: number, domain: string): void;
|
|
444
605
|
/**
|
|
445
|
-
*
|
|
446
|
-
*
|
|
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
|
|
447
616
|
*/
|
|
448
617
|
export declare function getCookie(name: string): string;
|
|
618
|
+
/**
|
|
619
|
+
* @hidden
|
|
620
|
+
*/
|
|
449
621
|
interface WebPerformance {
|
|
450
622
|
[key: string]: string | number;
|
|
451
623
|
}
|
|
@@ -490,6 +662,7 @@ interface WebPerformance {
|
|
|
490
662
|
*
|
|
491
663
|
* @param {boolean} camelCase -- false(默认) 以下划线形式返回数据 true 以驼峰形式返回数据
|
|
492
664
|
* @returns {Promise<object>} 加载数据
|
|
665
|
+
* @category Web Performance
|
|
493
666
|
*/
|
|
494
667
|
export declare function getPerformance(camelCase?: boolean): Promise<WebPerformance | Error>;
|
|
495
668
|
/**
|
|
@@ -527,10 +700,11 @@ export declare function getPerformance(camelCase?: boolean): Promise<WebPerforma
|
|
|
527
700
|
*
|
|
528
701
|
* @param {number} rate -- 0.1 ~ 1 => 1% ~ 100%
|
|
529
702
|
* @returns {boolean} true 命中
|
|
703
|
+
* @category Calculate and Formula
|
|
530
704
|
*/
|
|
531
705
|
export declare function inRate(rate: number): boolean;
|
|
532
706
|
/**
|
|
533
|
-
* 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.
|
|
534
708
|
*
|
|
535
709
|
* ZH: 判断是否是安全的 PWA 环境
|
|
536
710
|
*
|
|
@@ -547,6 +721,7 @@ export declare function inRate(rate: number): boolean;
|
|
|
547
721
|
* ```
|
|
548
722
|
*
|
|
549
723
|
* @returns {boolean} true 是
|
|
724
|
+
* @category Browser Information
|
|
550
725
|
*/
|
|
551
726
|
export declare function isSafePWAEnv(): boolean;
|
|
552
727
|
/**
|
|
@@ -568,18 +743,18 @@ export declare function isSafePWAEnv(): boolean;
|
|
|
568
743
|
*
|
|
569
744
|
* Results:
|
|
570
745
|
*
|
|
571
|
-
* |
|
|
572
|
-
* | --- | --- | --- |
|
|
573
|
-
* | System |
|
|
574
|
-
* | System version |
|
|
575
|
-
* | Platform |
|
|
576
|
-
* | Engine |
|
|
577
|
-
* | Engine version |
|
|
578
|
-
* | Supporter |
|
|
579
|
-
* | Supporter version |
|
|
580
|
-
* | Shell |
|
|
581
|
-
* | Shell version |
|
|
582
|
-
* | 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 |
|
|
583
758
|
*
|
|
584
759
|
* Example: Determine the environment of the mobile QQ.
|
|
585
760
|
*
|
|
@@ -589,6 +764,7 @@ export declare function isSafePWAEnv(): boolean;
|
|
|
589
764
|
* ```
|
|
590
765
|
*
|
|
591
766
|
* @returns 浏览器信息
|
|
767
|
+
* @category Browser Information
|
|
592
768
|
*/
|
|
593
769
|
export declare function getBrowserInfo(): {
|
|
594
770
|
engine: string;
|
|
@@ -635,12 +811,13 @@ export declare function cutCHSString(str: string, len: number, hasDot?: boolean)
|
|
|
635
811
|
*
|
|
636
812
|
* @param {number} timeout 超时时间 / 单位:秒
|
|
637
813
|
* @returns {Promise<string>} document is loaded? 'complete' 'load' / 'timeout'
|
|
814
|
+
* @category Load Resource
|
|
638
815
|
*/
|
|
639
816
|
export declare function windowLoaded(timeout?: number): Promise<string | Error>;
|
|
640
817
|
/**
|
|
641
818
|
* EN: Add `<style>` in `<head>`.
|
|
642
819
|
*
|
|
643
|
-
* ZH: 添加样式标签; style: 样式标签内的字符串; id: `<style>` 标签的 `id`; 返回:
|
|
820
|
+
* ZH: 添加样式标签; style: 样式标签内的字符串; id: `<style>` 标签的 `id`; 返回: 添加成功/失败
|
|
644
821
|
*
|
|
645
822
|
* Example 1: Add the `<style>` with `id`, and repeated invoking will update the content instead of adding a new one.
|
|
646
823
|
*
|
|
@@ -668,20 +845,18 @@ export declare function windowLoaded(timeout?: number): Promise<string | Error>;
|
|
|
668
845
|
* addStyle(
|
|
669
846
|
* `
|
|
670
847
|
* body {
|
|
671
|
-
* background-color: #
|
|
848
|
+
* background-color: #444;
|
|
672
849
|
* }
|
|
673
850
|
* `
|
|
674
851
|
* );
|
|
675
852
|
* // <style>
|
|
676
853
|
* // body {
|
|
677
|
-
* // background-color: #
|
|
854
|
+
* // background-color: #444;
|
|
678
855
|
* // }
|
|
679
856
|
* // </style>
|
|
680
857
|
* ```
|
|
681
858
|
*
|
|
682
|
-
* @
|
|
683
|
-
* @param options.id `id` in `<style>`
|
|
684
|
-
* @returns Success/Fail
|
|
859
|
+
* @category DOM
|
|
685
860
|
*/
|
|
686
861
|
export declare function addStyle(style: string, options?: {
|
|
687
862
|
id?: string;
|
|
@@ -715,6 +890,7 @@ export declare function addStyle(style: string, options?: {
|
|
|
715
890
|
* @param {function} logFn The function with Log.
|
|
716
891
|
* @param {function} errorFn The function with Error.
|
|
717
892
|
* @returns {object} 新实例
|
|
893
|
+
* @category Debug
|
|
718
894
|
*/
|
|
719
895
|
export declare function genCustomConsole(prefix?: string, options?: {
|
|
720
896
|
isClosed?: boolean;
|
|
@@ -772,6 +948,7 @@ export declare function isNonEmptyArray(arr: any[]): boolean;
|
|
|
772
948
|
* @param {string[]} attributes Data Attributes
|
|
773
949
|
* @param {any} validValue Given Value for verifying.
|
|
774
950
|
* @returns {boolean} Return TRUE if the data is valid.
|
|
951
|
+
* @category Util
|
|
775
952
|
*/
|
|
776
953
|
export declare function isValidData(data: any, attributes: string[], validValue: any): boolean;
|
|
777
954
|
/**
|
|
@@ -814,7 +991,74 @@ export declare function genHashCode(str: string): number;
|
|
|
814
991
|
* @param {Date|number|string} dateIns Original Date
|
|
815
992
|
* @param {string} format Format String
|
|
816
993
|
* @returns {string} Return the formatted date string.
|
|
994
|
+
* @category Util
|
|
817
995
|
*/
|
|
818
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;
|
|
819
1063
|
export {};
|
|
820
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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,WAAe,GAAG,MAAM,CAOnE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,K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