mazey 3.5.4 → 3.6.1
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 +217 -178
- package/lib/index.cjs.js +3666 -2775
- package/lib/index.d.ts +308 -43
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +3660 -2776
- package/lib/mazey.min.js +2 -2
- package/package.json +1 -1
- package/scripts/env.sh +2 -0
- package/README_CN.md +0 -359
- package/examples/index.html +0 -21
- package/examples/index.ts +0 -121
- package/images/mazey-v1.4.39.svg +0 -1
- package/src/index.ts +0 -2260
- package/src/preview.js +0 -47
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,19 +236,30 @@ 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
|
/**
|
|
237
259
|
* @method generateUniqueNum
|
|
238
260
|
* @description 根据时间生成唯一标志的数字 mGenerateUniqueNum() => 1538324722364123。
|
|
239
261
|
* @param {number} n 随机数的长度
|
|
262
|
+
* @category Util
|
|
240
263
|
*/
|
|
241
264
|
export declare function generateUniqueNum(n?: number): string;
|
|
242
265
|
/**
|
|
@@ -244,28 +267,70 @@ export declare function generateUniqueNum(n?: number): string;
|
|
|
244
267
|
* @description 浮点数转为百分比 0.2 => 20%。
|
|
245
268
|
* @param {number} num 浮点数
|
|
246
269
|
* @param {number} fixSize 保留几位浮点数
|
|
270
|
+
* @category Util
|
|
247
271
|
*/
|
|
248
272
|
export declare function floatToPercent(num: number, fixSize?: number): string;
|
|
249
273
|
/**
|
|
250
274
|
* @method floatFixed
|
|
251
275
|
* @description 浮点数保留指定位。
|
|
276
|
+
* @category Util
|
|
252
277
|
*/
|
|
253
278
|
export declare function floatFixed(num: string, size?: number): string;
|
|
254
279
|
/**
|
|
255
280
|
* @method cancelBubble
|
|
256
281
|
* @description 阻止冒泡。
|
|
282
|
+
* @category Util
|
|
257
283
|
*/
|
|
258
284
|
export declare function cancelBubble(e: any): void;
|
|
259
285
|
/**
|
|
260
|
-
*
|
|
286
|
+
* Modify `class`.
|
|
287
|
+
*
|
|
288
|
+
* ```
|
|
289
|
+
* const dom = document.querySelector('#box');
|
|
290
|
+
*
|
|
291
|
+
* // Determine `class`
|
|
292
|
+
* hasClass(dom, 'test');
|
|
293
|
+
* // Add `class`
|
|
294
|
+
* addClass(dom, 'test');
|
|
295
|
+
* // Remove `class`
|
|
296
|
+
* removeClass(dom, 'test');
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @category DOM
|
|
261
300
|
*/
|
|
262
301
|
export declare function hasClass(obj: any, cls: string): boolean;
|
|
263
302
|
/**
|
|
264
|
-
*
|
|
303
|
+
* Modify `class`.
|
|
304
|
+
*
|
|
305
|
+
* ```
|
|
306
|
+
* const dom = document.querySelector('#box');
|
|
307
|
+
*
|
|
308
|
+
* // Determine `class`
|
|
309
|
+
* hasClass(dom, 'test');
|
|
310
|
+
* // Add `class`
|
|
311
|
+
* addClass(dom, 'test');
|
|
312
|
+
* // Remove `class`
|
|
313
|
+
* removeClass(dom, 'test');
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @category DOM
|
|
265
317
|
*/
|
|
266
318
|
export declare function addClass(obj: any, cls: string): void;
|
|
267
319
|
/**
|
|
268
|
-
*
|
|
320
|
+
* Modify `class`.
|
|
321
|
+
*
|
|
322
|
+
* ```
|
|
323
|
+
* const dom = document.querySelector('#box');
|
|
324
|
+
*
|
|
325
|
+
* // Determine `class`
|
|
326
|
+
* hasClass(dom, 'test');
|
|
327
|
+
* // Add `class`
|
|
328
|
+
* addClass(dom, 'test');
|
|
329
|
+
* // Remove `class`
|
|
330
|
+
* removeClass(dom, 'test');
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
333
|
+
* @category DOM
|
|
269
334
|
*/
|
|
270
335
|
export declare function removeClass(obj: any, cls: string): void;
|
|
271
336
|
/**
|
|
@@ -280,6 +345,8 @@ export declare function removeClass(obj: any, cls: string): void;
|
|
|
280
345
|
* ```
|
|
281
346
|
*
|
|
282
347
|
* Reference: [Lodash](https://lodash.com/docs/4.17.15#throttle)
|
|
348
|
+
*
|
|
349
|
+
* @category Util
|
|
283
350
|
*/
|
|
284
351
|
export declare function throttle(func: any, wait: number, options?: {
|
|
285
352
|
leading?: boolean;
|
|
@@ -295,6 +362,8 @@ export declare function throttle(func: any, wait: number, options?: {
|
|
|
295
362
|
* console.log('The debounced function will only be invoked in 1000 milliseconds, the other invoking will disappear during the wait time.');
|
|
296
363
|
* }, 1000, true);
|
|
297
364
|
* ```
|
|
365
|
+
*
|
|
366
|
+
* @category Util
|
|
298
367
|
*/
|
|
299
368
|
export declare function debounce(func: any, wait: number, immediate?: any): any;
|
|
300
369
|
/**
|
|
@@ -304,6 +373,7 @@ export declare function debounce(func: any, wait: number, immediate?: any): any;
|
|
|
304
373
|
* @param {number/Date} end 结束时间戳 1585325367122
|
|
305
374
|
* @param {string} options.type 返回类型 d: 2(天) text: 2 天 4 时...
|
|
306
375
|
* @returns {string/number} 取决于 type
|
|
376
|
+
* @category Util
|
|
307
377
|
*/
|
|
308
378
|
export declare function friendlyInterval(start?: number, end?: number, options?: {
|
|
309
379
|
type?: string;
|
|
@@ -327,6 +397,7 @@ export declare function friendlyInterval(start?: number, end?: number, options?:
|
|
|
327
397
|
* @param {boolean} options.isNaNAsNumber 是否 NaN 算数字(默认不算)
|
|
328
398
|
* @param {boolean} options.isUnFiniteAsNumber 是否 无限 算数字(默认不算)
|
|
329
399
|
* @returns {boolean} true 是数字
|
|
400
|
+
* @category Util
|
|
330
401
|
*/
|
|
331
402
|
export declare function isNumber(num: any, options?: {
|
|
332
403
|
isNaNAsNumber?: boolean;
|
|
@@ -336,34 +407,115 @@ export declare function isNumber(num: any, options?: {
|
|
|
336
407
|
* @method doFn
|
|
337
408
|
* @description 执行有效函数
|
|
338
409
|
* @param {function} fn 等待被执行的未知是否有效的函数
|
|
410
|
+
* @category Util
|
|
339
411
|
*/
|
|
340
412
|
export declare function doFn(fn: any, ...params: any[]): any;
|
|
341
413
|
/**
|
|
342
|
-
*
|
|
343
|
-
*
|
|
414
|
+
* EN: Handle Storage (Keep fit for JSON, it can tansfer format automatically).
|
|
415
|
+
*
|
|
416
|
+
* ZH: 存储/获取数据到 sessionStorage/localStorage
|
|
417
|
+
*
|
|
418
|
+
* ```
|
|
419
|
+
* setSessionStorage('test', '123');
|
|
420
|
+
* getSessionStorage('test'); // 123
|
|
421
|
+
* setLocalStorage('test', '123');
|
|
422
|
+
* getLocalStorage('test'); // 123
|
|
423
|
+
*
|
|
424
|
+
* // or package in usage
|
|
425
|
+
* const projectName = 'mazey';
|
|
426
|
+
* function mSetLocalStorage (key, value) {
|
|
427
|
+
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
428
|
+
* }
|
|
429
|
+
*
|
|
430
|
+
* function mGetLocalStorage (key) {
|
|
431
|
+
* return getLocalStorage(`${projectName}_${key}`);
|
|
432
|
+
* }
|
|
433
|
+
* ```
|
|
434
|
+
*
|
|
344
435
|
* @param {string} key 键
|
|
345
|
-
* @
|
|
436
|
+
* @returns {any} 返回值
|
|
437
|
+
* @category Cache Data
|
|
346
438
|
*/
|
|
347
439
|
export declare function setSessionStorage(key: string, value?: any): void;
|
|
348
440
|
/**
|
|
349
|
-
*
|
|
350
|
-
*
|
|
441
|
+
* EN: Handle Storage (Keep fit for JSON, it can tansfer format automatically).
|
|
442
|
+
*
|
|
443
|
+
* ZH: 存储/获取数据到 sessionStorage/localStorage
|
|
444
|
+
*
|
|
445
|
+
* ```
|
|
446
|
+
* setSessionStorage('test', '123');
|
|
447
|
+
* getSessionStorage('test'); // 123
|
|
448
|
+
* setLocalStorage('test', '123');
|
|
449
|
+
* getLocalStorage('test'); // 123
|
|
450
|
+
*
|
|
451
|
+
* // or package in usage
|
|
452
|
+
* const projectName = 'mazey';
|
|
453
|
+
* function mSetLocalStorage (key, value) {
|
|
454
|
+
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
455
|
+
* }
|
|
456
|
+
*
|
|
457
|
+
* function mGetLocalStorage (key) {
|
|
458
|
+
* return getLocalStorage(`${projectName}_${key}`);
|
|
459
|
+
* }
|
|
460
|
+
* ```
|
|
461
|
+
*
|
|
351
462
|
* @param {string} key 键
|
|
352
|
-
* @returns {
|
|
463
|
+
* @returns {any} 返回值
|
|
464
|
+
* @category Cache Data
|
|
353
465
|
*/
|
|
354
466
|
export declare function getSessionStorage(key: string): any;
|
|
355
467
|
/**
|
|
356
|
-
*
|
|
357
|
-
*
|
|
468
|
+
* EN: Handle Storage (Keep fit for JSON, it can tansfer format automatically).
|
|
469
|
+
*
|
|
470
|
+
* ZH: 存储/获取数据到 sessionStorage/localStorage
|
|
471
|
+
*
|
|
472
|
+
* ```
|
|
473
|
+
* setSessionStorage('test', '123');
|
|
474
|
+
* getSessionStorage('test'); // 123
|
|
475
|
+
* setLocalStorage('test', '123');
|
|
476
|
+
* getLocalStorage('test'); // 123
|
|
477
|
+
*
|
|
478
|
+
* // or package in usage
|
|
479
|
+
* const projectName = 'mazey';
|
|
480
|
+
* function mSetLocalStorage (key, value) {
|
|
481
|
+
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
482
|
+
* }
|
|
483
|
+
*
|
|
484
|
+
* function mGetLocalStorage (key) {
|
|
485
|
+
* return getLocalStorage(`${projectName}_${key}`);
|
|
486
|
+
* }
|
|
487
|
+
* ```
|
|
488
|
+
*
|
|
358
489
|
* @param {string} key 键
|
|
359
|
-
* @
|
|
490
|
+
* @returns {any} 返回值
|
|
491
|
+
* @category Cache Data
|
|
360
492
|
*/
|
|
361
493
|
export declare function setLocalStorage(key: string, value?: any): void;
|
|
362
494
|
/**
|
|
363
|
-
*
|
|
364
|
-
*
|
|
495
|
+
* EN: Handle Storage (Keep fit for JSON, it can tansfer format automatically).
|
|
496
|
+
*
|
|
497
|
+
* ZH: 存储/获取数据到 sessionStorage/localStorage
|
|
498
|
+
*
|
|
499
|
+
* ```
|
|
500
|
+
* setSessionStorage('test', '123');
|
|
501
|
+
* getSessionStorage('test'); // 123
|
|
502
|
+
* setLocalStorage('test', '123');
|
|
503
|
+
* getLocalStorage('test'); // 123
|
|
504
|
+
*
|
|
505
|
+
* // or package in usage
|
|
506
|
+
* const projectName = 'mazey';
|
|
507
|
+
* function mSetLocalStorage (key, value) {
|
|
508
|
+
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
509
|
+
* }
|
|
510
|
+
*
|
|
511
|
+
* function mGetLocalStorage (key) {
|
|
512
|
+
* return getLocalStorage(`${projectName}_${key}`);
|
|
513
|
+
* }
|
|
514
|
+
* ```
|
|
515
|
+
*
|
|
365
516
|
* @param {string} key 键
|
|
366
|
-
* @returns {
|
|
517
|
+
* @returns {any} 返回值
|
|
518
|
+
* @category Cache Data
|
|
367
519
|
*/
|
|
368
520
|
export declare function getLocalStorage(key: string): any;
|
|
369
521
|
/**
|
|
@@ -441,16 +593,33 @@ export declare function loadScript(url: string, options?: {
|
|
|
441
593
|
/**
|
|
442
594
|
* @method mNow
|
|
443
595
|
* @description 获取时间戳
|
|
596
|
+
* @category Util
|
|
444
597
|
*/
|
|
445
598
|
export declare function mNow(): number;
|
|
446
599
|
/**
|
|
447
|
-
*
|
|
448
|
-
*
|
|
600
|
+
* EN: Handle Cookie.
|
|
601
|
+
*
|
|
602
|
+
* ZH: 设置/获取 Cookie
|
|
603
|
+
*
|
|
604
|
+
* ```
|
|
605
|
+
* setCookie('test', '123', 30, 'example.com'); // key value day domain
|
|
606
|
+
* getCookie('test'); // 123
|
|
607
|
+
* ```
|
|
608
|
+
*
|
|
609
|
+
* @category Cache Data
|
|
449
610
|
*/
|
|
450
611
|
export declare function setCookie(name: string, value: string, days: number, domain: string): void;
|
|
451
612
|
/**
|
|
452
|
-
*
|
|
453
|
-
*
|
|
613
|
+
* EN: Handle Cookie.
|
|
614
|
+
*
|
|
615
|
+
* ZH: 设置/获取 Cookie
|
|
616
|
+
*
|
|
617
|
+
* ```
|
|
618
|
+
* setCookie('test', '123', 30, 'example.com'); // key value day domain
|
|
619
|
+
* getCookie('test'); // 123
|
|
620
|
+
* ```
|
|
621
|
+
*
|
|
622
|
+
* @category Cache Data
|
|
454
623
|
*/
|
|
455
624
|
export declare function getCookie(name: string): string;
|
|
456
625
|
/**
|
|
@@ -500,6 +669,7 @@ interface WebPerformance {
|
|
|
500
669
|
*
|
|
501
670
|
* @param {boolean} camelCase -- false(默认) 以下划线形式返回数据 true 以驼峰形式返回数据
|
|
502
671
|
* @returns {Promise<object>} 加载数据
|
|
672
|
+
* @category Web Performance
|
|
503
673
|
*/
|
|
504
674
|
export declare function getPerformance(camelCase?: boolean): Promise<WebPerformance | Error>;
|
|
505
675
|
/**
|
|
@@ -537,10 +707,11 @@ export declare function getPerformance(camelCase?: boolean): Promise<WebPerforma
|
|
|
537
707
|
*
|
|
538
708
|
* @param {number} rate -- 0.1 ~ 1 => 1% ~ 100%
|
|
539
709
|
* @returns {boolean} true 命中
|
|
710
|
+
* @category Calculate and Formula
|
|
540
711
|
*/
|
|
541
712
|
export declare function inRate(rate: number): boolean;
|
|
542
713
|
/**
|
|
543
|
-
* EN: Determine if it is a secure PWA environment that it can run.
|
|
714
|
+
* EN: Detect the margin of Safety. Determine if it is a secure PWA environment that it can run.
|
|
544
715
|
*
|
|
545
716
|
* ZH: 判断是否是安全的 PWA 环境
|
|
546
717
|
*
|
|
@@ -557,6 +728,7 @@ export declare function inRate(rate: number): boolean;
|
|
|
557
728
|
* ```
|
|
558
729
|
*
|
|
559
730
|
* @returns {boolean} true 是
|
|
731
|
+
* @category Browser Information
|
|
560
732
|
*/
|
|
561
733
|
export declare function isSafePWAEnv(): boolean;
|
|
562
734
|
/**
|
|
@@ -578,18 +750,18 @@ export declare function isSafePWAEnv(): boolean;
|
|
|
578
750
|
*
|
|
579
751
|
* Results:
|
|
580
752
|
*
|
|
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 |
|
|
753
|
+
* | Attribute | Description | Type | Values |
|
|
754
|
+
* | --- | --- | --- | --- |
|
|
755
|
+
* | **system** | System | string | android, ios, windows, macos, linux |
|
|
756
|
+
* | systemVs | System version | string | windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 <br />macos: ... |
|
|
757
|
+
* | platform | Platform | string | desktop, mobile |
|
|
758
|
+
* | engine | Engine | string | webkit, gecko, presto, trident |
|
|
759
|
+
* | engineVs | Engine version | string | - |
|
|
760
|
+
* | supporter | Supporter | string | edge, opera, chrome, safari, firefox, iexplore |
|
|
761
|
+
* | supporterVs | Supporter version | string | - |
|
|
762
|
+
* | shell | Shell | string | (Optional) wechat, qq_browser, qq_app, uc, 360, 2345, sougou, liebao, maxthon, bilibili |
|
|
763
|
+
* | shellVs | Shell version | string | (Optional) 20/... |
|
|
764
|
+
* | appleType | Apple device type | string | (Optional) ipad, iphone, ipod, iwatch |
|
|
593
765
|
*
|
|
594
766
|
* Example: Determine the environment of the mobile QQ.
|
|
595
767
|
*
|
|
@@ -618,6 +790,7 @@ export declare function getBrowserInfo(): {
|
|
|
618
790
|
* @description 去除HTML标签
|
|
619
791
|
* @param {string} str 带html标签的字符串
|
|
620
792
|
* @returns {string} 字符串
|
|
793
|
+
* @category Util
|
|
621
794
|
*/
|
|
622
795
|
export declare function clearHtml(str: string): string;
|
|
623
796
|
/**
|
|
@@ -626,7 +799,8 @@ export declare function clearHtml(str: string): string;
|
|
|
626
799
|
* @param {string} str 要截取的字符串
|
|
627
800
|
* @param {number} len
|
|
628
801
|
* @param {boolean} hasDot
|
|
629
|
-
* @
|
|
802
|
+
* @returns {string} 返回截取后的字符串
|
|
803
|
+
* @category Util
|
|
630
804
|
*/
|
|
631
805
|
export declare function cutCHSString(str: string, len: number, hasDot?: boolean): string;
|
|
632
806
|
/**
|
|
@@ -652,7 +826,7 @@ export declare function windowLoaded(timeout?: number): Promise<string | Error>;
|
|
|
652
826
|
/**
|
|
653
827
|
* EN: Add `<style>` in `<head>`.
|
|
654
828
|
*
|
|
655
|
-
* ZH: 添加样式标签; style: 样式标签内的字符串; id: `<style>` 标签的 `id`; 返回:
|
|
829
|
+
* ZH: 添加样式标签; style: 样式标签内的字符串; id: `<style>` 标签的 `id`; 返回: 添加成功/失败
|
|
656
830
|
*
|
|
657
831
|
* Example 1: Add the `<style>` with `id`, and repeated invoking will update the content instead of adding a new one.
|
|
658
832
|
*
|
|
@@ -680,20 +854,18 @@ export declare function windowLoaded(timeout?: number): Promise<string | Error>;
|
|
|
680
854
|
* addStyle(
|
|
681
855
|
* `
|
|
682
856
|
* body {
|
|
683
|
-
* background-color: #
|
|
857
|
+
* background-color: #444;
|
|
684
858
|
* }
|
|
685
859
|
* `
|
|
686
860
|
* );
|
|
687
861
|
* // <style>
|
|
688
862
|
* // body {
|
|
689
|
-
* // background-color: #
|
|
863
|
+
* // background-color: #444;
|
|
690
864
|
* // }
|
|
691
865
|
* // </style>
|
|
692
866
|
* ```
|
|
693
867
|
*
|
|
694
|
-
* @
|
|
695
|
-
* @param options.id `id` in `<style>`
|
|
696
|
-
* @returns Success/Fail
|
|
868
|
+
* @category DOM
|
|
697
869
|
*/
|
|
698
870
|
export declare function addStyle(style: string, options?: {
|
|
699
871
|
id?: string;
|
|
@@ -727,6 +899,7 @@ export declare function addStyle(style: string, options?: {
|
|
|
727
899
|
* @param {function} logFn The function with Log.
|
|
728
900
|
* @param {function} errorFn The function with Error.
|
|
729
901
|
* @returns {object} 新实例
|
|
902
|
+
* @category Debug
|
|
730
903
|
*/
|
|
731
904
|
export declare function genCustomConsole(prefix?: string, options?: {
|
|
732
905
|
isClosed?: boolean;
|
|
@@ -740,6 +913,9 @@ export declare function genCustomConsole(prefix?: string, options?: {
|
|
|
740
913
|
* Verify the validity of axios response.
|
|
741
914
|
*
|
|
742
915
|
* Reference: [Handling Errors](https://axios-http.com/docs/handling_errors)
|
|
916
|
+
*
|
|
917
|
+
* @category Util
|
|
918
|
+
* @hidden
|
|
743
919
|
*/
|
|
744
920
|
export declare function zAxiosIsValidRes(res: any, options?: {
|
|
745
921
|
validStatusRange?: number[];
|
|
@@ -747,6 +923,8 @@ export declare function zAxiosIsValidRes(res: any, options?: {
|
|
|
747
923
|
}): boolean;
|
|
748
924
|
/**
|
|
749
925
|
* Verify the validity of a non-empty array.
|
|
926
|
+
*
|
|
927
|
+
* @category Util
|
|
750
928
|
*/
|
|
751
929
|
export declare function isNonEmptyArray(arr: any[]): boolean;
|
|
752
930
|
/**
|
|
@@ -784,22 +962,29 @@ export declare function isNonEmptyArray(arr: any[]): boolean;
|
|
|
784
962
|
* @param {string[]} attributes Data Attributes
|
|
785
963
|
* @param {any} validValue Given Value for verifying.
|
|
786
964
|
* @returns {boolean} Return TRUE if the data is valid.
|
|
965
|
+
* @category Util
|
|
787
966
|
*/
|
|
788
967
|
export declare function isValidData(data: any, attributes: string[], validValue: any): boolean;
|
|
789
968
|
/**
|
|
790
969
|
* 语义化文件大小, 把字节转换成正常文件大小.
|
|
970
|
+
*
|
|
971
|
+
* @category Util
|
|
791
972
|
*/
|
|
792
973
|
export declare function getFileSize(size: number): string;
|
|
793
974
|
/**
|
|
794
975
|
* Detect webp support.
|
|
795
976
|
*
|
|
796
977
|
* Reference: [Detect WEBP Support with JavaScript](https://davidwalsh.name/detect-webp)
|
|
978
|
+
*
|
|
979
|
+
* @category Browser Information
|
|
797
980
|
*/
|
|
798
981
|
export declare function isSupportWebp(): Promise<boolean>;
|
|
799
982
|
/**
|
|
800
983
|
* Generate a Hash Code from a string.
|
|
801
984
|
*
|
|
802
985
|
* Reference: [Generate a Hash from string in Javascript](https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery)
|
|
986
|
+
*
|
|
987
|
+
* @category Util
|
|
803
988
|
*/
|
|
804
989
|
export declare function genHashCode(str: string): number;
|
|
805
990
|
/**
|
|
@@ -826,7 +1011,87 @@ export declare function genHashCode(str: string): number;
|
|
|
826
1011
|
* @param {Date|number|string} dateIns Original Date
|
|
827
1012
|
* @param {string} format Format String
|
|
828
1013
|
* @returns {string} Return the formatted date string.
|
|
1014
|
+
* @category Util
|
|
829
1015
|
*/
|
|
830
1016
|
export declare function formatDate(dateIns?: Date | number | string, format?: string): string;
|
|
1017
|
+
/**
|
|
1018
|
+
* Get event container.
|
|
1019
|
+
*
|
|
1020
|
+
* @category Event
|
|
1021
|
+
* @hidden
|
|
1022
|
+
*/
|
|
1023
|
+
export declare function getDefineListeners(): DefineListeners;
|
|
1024
|
+
/**
|
|
1025
|
+
* Add event.
|
|
1026
|
+
*
|
|
1027
|
+
* @param type
|
|
1028
|
+
* @param fn
|
|
1029
|
+
* @category Event
|
|
1030
|
+
*/
|
|
1031
|
+
export declare function addEvent(type: string, fn: any): void;
|
|
1032
|
+
/**
|
|
1033
|
+
* Invoke event.
|
|
1034
|
+
*
|
|
1035
|
+
* @param type
|
|
1036
|
+
* @category Event
|
|
1037
|
+
*/
|
|
1038
|
+
export declare function invokeEvent(type: string): void;
|
|
1039
|
+
/**
|
|
1040
|
+
* Remove event.
|
|
1041
|
+
*
|
|
1042
|
+
* @param type
|
|
1043
|
+
* @param fn
|
|
1044
|
+
* @category Event
|
|
1045
|
+
*/
|
|
1046
|
+
export declare function removeEvent(type: string, fn: any): void;
|
|
1047
|
+
/**
|
|
1048
|
+
* Check if the given string is a valid url.
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```js
|
|
1052
|
+
* console.log(isUrl('https://www.google.com')); // true
|
|
1053
|
+
* console.log(isUrl('https://www.google.com/')); // true
|
|
1054
|
+
* console.log(isUrl('https://www.google.com/?q=hello')); // true
|
|
1055
|
+
* console.log(isUrl('https://www.google.com/?q=hello#world')); // true
|
|
1056
|
+
* console.log(isUrl('https://www.google.com/#world')); // true
|
|
1057
|
+
* console.log(isUrl('https://www.google.com/#')); // true
|
|
1058
|
+
* console.log(isUrl('https://www.google.com/#?q=hello')); // true
|
|
1059
|
+
* console.log(isUrl('https://www.google.com/#?q=hello#world')); // true
|
|
1060
|
+
* ```
|
|
1061
|
+
*
|
|
1062
|
+
* @param url
|
|
1063
|
+
* @returns {boolean} Return true if the given url is a valid url.
|
|
1064
|
+
* @category URL
|
|
1065
|
+
*/
|
|
1066
|
+
export declare function isValidUrl(url: string): boolean;
|
|
1067
|
+
/**
|
|
1068
|
+
* Check if the given string is a mobile phone number.
|
|
1069
|
+
*
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```js
|
|
1072
|
+
* console.log(isMobile('13800138000')); // true
|
|
1073
|
+
* console.log(isMobile('1380013800')); // false
|
|
1074
|
+
* console.log(isMobile('138001380000')); // false
|
|
1075
|
+
* console.log(isMobile('1380013800a')); // false
|
|
1076
|
+
* ```
|
|
1077
|
+
*
|
|
1078
|
+
* @param mobile
|
|
1079
|
+
* @returns {boolean} Return true if the given string is a mobile phone number.
|
|
1080
|
+
* @category Util
|
|
1081
|
+
*/
|
|
1082
|
+
export declare function isValidPhoneNumber(mobile: string): boolean;
|
|
1083
|
+
/**
|
|
1084
|
+
* Check if the given string is a valid email.
|
|
1085
|
+
*
|
|
1086
|
+
* @example
|
|
1087
|
+
* ```js
|
|
1088
|
+
* console.log(isValidEmail('mazeyqian@gmail.com')); // true
|
|
1089
|
+
* ```
|
|
1090
|
+
*
|
|
1091
|
+
* @param email
|
|
1092
|
+
* @returns {boolean} Return true if the given string is a valid email.
|
|
1093
|
+
* @category Util
|
|
1094
|
+
*/
|
|
1095
|
+
export declare function isValidEmail(email: string): boolean;
|
|
831
1096
|
export {};
|
|
832
1097
|
//# 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;;;;;;;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