mazey 3.6.3 → 3.6.4
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 +29 -17
- package/lib/index.cjs.js +218 -123
- package/lib/index.d.ts +72 -14
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +213 -123
- package/lib/mazey.min.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,9 @@ Import from [npm](https://www.npmjs.com/package/mazey).
|
|
|
37
37
|
```
|
|
38
38
|
import { isNumber } from 'mazey';
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const x = Infinity;
|
|
41
|
+
isNumber(x); // <=> typeof x === 'string' && !isNaN(x) && isFinite(x)
|
|
42
|
+
// Output: false
|
|
41
43
|
```
|
|
42
44
|
|
|
43
45
|
Import from CDN.
|
|
@@ -45,7 +47,9 @@ Import from CDN.
|
|
|
45
47
|
```
|
|
46
48
|
<script type="text/javascript" src="//i.mazey.net/mazey/lib/mazey.min.js"></script>
|
|
47
49
|
<script>
|
|
48
|
-
|
|
50
|
+
const x = Infinity;
|
|
51
|
+
mazey.isNumber(x, { isUnFiniteAsNumber: true }); // <=> typeof x === 'string' && !isNaN(x)
|
|
52
|
+
// Output: true
|
|
49
53
|
</script>
|
|
50
54
|
```
|
|
51
55
|
|
|
@@ -63,14 +67,14 @@ There ara some examples maintained by hand below. For more information, please c
|
|
|
63
67
|
* [windowLoaded](#windowloaded)
|
|
64
68
|
- [Util](#util)
|
|
65
69
|
* [isNumber](#isnumber)
|
|
66
|
-
* [
|
|
70
|
+
* [isJSONString](#isjsonstring)
|
|
67
71
|
* [isValidData](#isvaliddata)
|
|
68
72
|
* [generateRndNum](#generaterndnum)
|
|
69
73
|
* [formatDate](#formatdate)
|
|
70
74
|
* [debounce](#debounce)
|
|
71
75
|
* [throttle](#throttle)
|
|
72
|
-
* [
|
|
73
|
-
* [
|
|
76
|
+
* [convertCamelToKebab](#convertcameltokebab)
|
|
77
|
+
* [convertCamelToUnder](#convertcameltounder)
|
|
74
78
|
* [deepCopyObject](#deepcopyobject)
|
|
75
79
|
* [mTrim](#mtrim)
|
|
76
80
|
- [URL](#url)
|
|
@@ -210,15 +214,15 @@ isNumber(NaN, { isNaNAsNumber: true, isUnFiniteAsNumber: true }); // true
|
|
|
210
214
|
@returns {boolean} true 是数字
|
|
211
215
|
@category Util -->
|
|
212
216
|
|
|
213
|
-
####
|
|
217
|
+
#### isJSONString
|
|
214
218
|
|
|
215
219
|
Check whether it is a valid JSON string.
|
|
216
220
|
|
|
217
221
|
Usage:
|
|
218
222
|
|
|
219
223
|
```
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
isJSONString(`['a', 'b', 'c']`);
|
|
225
|
+
isJSONString(`["a", "b", "c"]`);
|
|
222
226
|
```
|
|
223
227
|
|
|
224
228
|
Output:
|
|
@@ -340,26 +344,26 @@ Reference: [Lodash](https://lodash.com/docs/4.17.15#throttle)
|
|
|
340
344
|
|
|
341
345
|
<!-- @category Util -->
|
|
342
346
|
|
|
343
|
-
####
|
|
347
|
+
#### convertCamelToKebab
|
|
344
348
|
|
|
345
349
|
Transfer CamelCase to KebabCase.
|
|
346
350
|
|
|
347
351
|
```
|
|
348
|
-
|
|
349
|
-
|
|
352
|
+
convertCamelToKebab('ABC'); // a-b-c
|
|
353
|
+
convertCamelToKebab('aBC'); // a-b-c
|
|
350
354
|
```
|
|
351
355
|
|
|
352
356
|
<!-- @param {string} camelCase 'aBC' or 'ABC'
|
|
353
357
|
@returns {string} 'a-b-c'
|
|
354
358
|
@category Util -->
|
|
355
359
|
|
|
356
|
-
####
|
|
360
|
+
#### convertCamelToUnder
|
|
357
361
|
|
|
358
362
|
Transfer CamelCase to Underscore.
|
|
359
363
|
|
|
360
364
|
```
|
|
361
|
-
|
|
362
|
-
|
|
365
|
+
convertCamelToUnder('ABC'); // a_b_c
|
|
366
|
+
convertCamelToUnder('aBC'); // a_b_c
|
|
363
367
|
```
|
|
364
368
|
|
|
365
369
|
<!-- @param {string} camelCase 'aBC' or 'ABC'
|
|
@@ -465,6 +469,10 @@ Usage:
|
|
|
465
469
|
```
|
|
466
470
|
getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4');
|
|
467
471
|
getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']);
|
|
472
|
+
getDomain('http://example.com:7890/test/thanks', ['hostname']);
|
|
473
|
+
getDomain('http://example.com:7890/test/thanks', ['host']); // With Port
|
|
474
|
+
getDomain('http://example.com:7890/test/thanks', ['origin']);
|
|
475
|
+
getDomain('http://example.com:7890/test/thanks?id=1', ['origin', 'pathname', 'search']);
|
|
468
476
|
```
|
|
469
477
|
|
|
470
478
|
Output:
|
|
@@ -472,10 +480,14 @@ Output:
|
|
|
472
480
|
```
|
|
473
481
|
example.com
|
|
474
482
|
example.com/test/thanks
|
|
483
|
+
example.com
|
|
484
|
+
example.com:7890
|
|
485
|
+
http://example.com:7890
|
|
486
|
+
http://example.com:7890/test/thanks?id=1
|
|
475
487
|
```
|
|
476
488
|
|
|
477
489
|
<!-- @param {string} url
|
|
478
|
-
@param {array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
|
|
490
|
+
@param {array} rules Object.keys(location), ['href', 'origin', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
|
|
479
491
|
@category URL -->
|
|
480
492
|
|
|
481
493
|
#### updateQueryParam
|
|
@@ -730,7 +742,7 @@ Output:
|
|
|
730
742
|
Results:
|
|
731
743
|
|
|
732
744
|
| Attribute | Description | Type | Values |
|
|
733
|
-
|
|
|
745
|
+
| :------------ | :------------ | :------------ | :------------ |
|
|
734
746
|
| **system** | System | string | android, ios, windows, macos, linux |
|
|
735
747
|
| systemVs | System version | string | windows: 2000, xp, 2003, vista, 7, 8, 8.1, 10 <br />macos: ... |
|
|
736
748
|
| platform | Platform | string | desktop, mobile |
|
|
@@ -802,7 +814,7 @@ Output:
|
|
|
802
814
|
Results:
|
|
803
815
|
|
|
804
816
|
| Attribute | Description | Type | Values |
|
|
805
|
-
|
|
|
817
|
+
| :------------ | :------------ | :------------ | :------------ |
|
|
806
818
|
| dns_time | DNS Lookup | number | domainLookupEnd - domainLookupStart |
|
|
807
819
|
| tcp_time | Connection Negotiation | number | connectEnd - connectStart |
|
|
808
820
|
| response_time | Requests and Responses | number | responseStart - requestStart |
|