@daysnap/utils 0.0.41 → 0.0.42

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.
Files changed (174) hide show
  1. package/README.md +21 -4
  2. package/docs/README.md +20 -4
  3. package/docs/modules.md +228 -93
  4. package/es/base64ToBlob.js +11 -17
  5. package/es/blobToBase64.js +10 -10
  6. package/es/canvasToBlob.js +4 -6
  7. package/es/clone.d.ts +4 -6
  8. package/es/clone.js +18 -8
  9. package/es/cloneSimple.d.ts +7 -0
  10. package/es/cloneSimple.js +9 -0
  11. package/es/compareVersion.js +27 -40
  12. package/es/compressImage.js +11 -13
  13. package/es/createHexColorByHash.js +59 -56
  14. package/es/debounce.d.ts +5 -0
  15. package/es/debounce.js +14 -0
  16. package/es/downloadFile.js +7 -7
  17. package/es/each.js +11 -10
  18. package/es/filterBankCardNo.js +4 -2
  19. package/es/filterCRLF.js +2 -2
  20. package/es/filterEmoji.js +13 -6
  21. package/es/filterIdCard.js +2 -2
  22. package/es/filterName.js +12 -12
  23. package/es/filterPhone.js +3 -4
  24. package/es/formatAmount.js +18 -20
  25. package/es/formatDate.js +28 -29
  26. package/es/getBlobByUrl.js +17 -18
  27. package/es/getDayMillisecond.js +3 -4
  28. package/es/getImageInfo.js +9 -9
  29. package/es/getRandomColor.js +2 -2
  30. package/es/getVideoInfo.js +11 -11
  31. package/es/inBrowser.js +2 -2
  32. package/es/index.d.ts +4 -0
  33. package/es/index.js +5 -1
  34. package/es/isAndroid.js +2 -2
  35. package/es/isArray.js +2 -2
  36. package/es/isBoolean.js +2 -2
  37. package/es/isEmail.js +2 -2
  38. package/es/isEmpty.js +2 -2
  39. package/es/isEmptyObject.js +2 -2
  40. package/es/isError.js +2 -2
  41. package/es/isFunction.js +2 -2
  42. package/es/isIOS.js +2 -2
  43. package/es/isIdCard.js +2 -2
  44. package/es/isJSONString.js +8 -7
  45. package/es/isLan.js +29 -28
  46. package/es/isLicenseCode.js +2 -2
  47. package/es/isMobile.js +7 -6
  48. package/es/isNull.js +2 -2
  49. package/es/isNumber.js +2 -2
  50. package/es/isObject.js +2 -2
  51. package/es/isPhone.js +2 -2
  52. package/es/isPromise.js +2 -2
  53. package/es/isRegExp.js +2 -2
  54. package/es/isString.js +2 -2
  55. package/es/isURL.d.ts +4 -0
  56. package/es/isURL.js +6 -0
  57. package/es/isUndefined.js +2 -2
  58. package/es/isWeixin.js +2 -2
  59. package/es/isWindow.js +2 -2
  60. package/es/loadResource.d.ts +1 -1
  61. package/es/loadResource.js +27 -23
  62. package/es/omit.js +7 -9
  63. package/es/padding.js +5 -5
  64. package/es/parseDate.js +7 -7
  65. package/es/parseError.js +15 -16
  66. package/es/parseObject.d.ts +2 -1
  67. package/es/parseObject.js +9 -8
  68. package/es/parsePath.js +7 -7
  69. package/es/parseQuery.d.ts +1 -1
  70. package/es/parseQuery.js +13 -24
  71. package/es/pick.js +7 -8
  72. package/es/replaceCrlf.js +2 -2
  73. package/es/reserve.js +2 -2
  74. package/es/round.js +38 -39
  75. package/es/sleep.d.ts +4 -2
  76. package/es/sleep.js +8 -7
  77. package/es/storage/factory.d.ts +2 -2
  78. package/es/storage/factory.js +44 -54
  79. package/es/storage/index.d.ts +4 -4
  80. package/es/storage/index.js +10 -10
  81. package/es/stringTrim.d.ts +3 -1
  82. package/es/stringTrim.js +17 -19
  83. package/es/stringifyQuery.d.ts +1 -1
  84. package/es/stringifyQuery.js +11 -8
  85. package/es/throttle.d.ts +5 -0
  86. package/es/throttle.js +17 -0
  87. package/es/typeOf.d.ts +1 -1
  88. package/es/typeOf.js +2 -2
  89. package/lib/base64ToBlob.js +14 -23
  90. package/lib/blobToBase64.js +13 -15
  91. package/lib/canvasToBlob.js +7 -11
  92. package/lib/clone.d.ts +4 -6
  93. package/lib/clone.js +21 -13
  94. package/lib/cloneSimple.d.ts +7 -0
  95. package/lib/cloneSimple.js +13 -0
  96. package/lib/compareVersion.js +30 -46
  97. package/lib/compressImage.js +15 -19
  98. package/lib/createHexColorByHash.js +60 -60
  99. package/lib/debounce.d.ts +5 -0
  100. package/lib/debounce.js +18 -0
  101. package/lib/downloadFile.js +10 -12
  102. package/lib/each.js +14 -15
  103. package/lib/filterBankCardNo.js +7 -7
  104. package/lib/filterCRLF.js +5 -7
  105. package/lib/filterEmoji.js +16 -11
  106. package/lib/filterIdCard.js +5 -7
  107. package/lib/filterName.js +15 -17
  108. package/lib/filterPhone.js +6 -9
  109. package/lib/formatAmount.js +21 -25
  110. package/lib/formatDate.js +32 -35
  111. package/lib/getBlobByUrl.js +20 -23
  112. package/lib/getDayMillisecond.js +6 -9
  113. package/lib/getImageInfo.js +12 -14
  114. package/lib/getRandomColor.js +5 -7
  115. package/lib/getVideoInfo.js +14 -16
  116. package/lib/inBrowser.js +5 -7
  117. package/lib/index.d.ts +4 -0
  118. package/lib/index.js +84 -708
  119. package/lib/isAndroid.js +5 -7
  120. package/lib/isArray.js +5 -7
  121. package/lib/isBoolean.js +5 -7
  122. package/lib/isEmail.js +5 -7
  123. package/lib/isEmpty.js +7 -9
  124. package/lib/isEmptyObject.js +5 -7
  125. package/lib/isError.js +5 -7
  126. package/lib/isFunction.js +5 -7
  127. package/lib/isIOS.js +5 -7
  128. package/lib/isIdCard.js +5 -7
  129. package/lib/isJSONString.js +12 -13
  130. package/lib/isLan.js +32 -33
  131. package/lib/isLicenseCode.js +5 -7
  132. package/lib/isMobile.js +10 -11
  133. package/lib/isNull.js +5 -7
  134. package/lib/isNumber.js +5 -7
  135. package/lib/isObject.js +5 -7
  136. package/lib/isPhone.js +5 -7
  137. package/lib/isPromise.js +5 -7
  138. package/lib/isRegExp.js +5 -7
  139. package/lib/isString.js +5 -7
  140. package/lib/isURL.d.ts +4 -0
  141. package/lib/isURL.js +10 -0
  142. package/lib/isUndefined.js +5 -7
  143. package/lib/isWeixin.js +5 -7
  144. package/lib/isWindow.js +5 -7
  145. package/lib/loadResource.d.ts +1 -1
  146. package/lib/loadResource.js +31 -29
  147. package/lib/omit.js +10 -15
  148. package/lib/padding.js +8 -10
  149. package/lib/parseDate.js +10 -12
  150. package/lib/parseError.js +21 -24
  151. package/lib/parseObject.d.ts +2 -1
  152. package/lib/parseObject.js +12 -13
  153. package/lib/parsePath.js +10 -12
  154. package/lib/parseQuery.d.ts +1 -1
  155. package/lib/parseQuery.js +17 -31
  156. package/lib/pick.js +10 -13
  157. package/lib/replaceCrlf.js +5 -7
  158. package/lib/reserve.js +6 -8
  159. package/lib/round.js +41 -44
  160. package/lib/sleep.d.ts +4 -2
  161. package/lib/sleep.js +11 -12
  162. package/lib/storage/factory.d.ts +2 -2
  163. package/lib/storage/factory.js +47 -60
  164. package/lib/storage/index.d.ts +4 -4
  165. package/lib/storage/index.js +12 -17
  166. package/lib/stringTrim.d.ts +3 -1
  167. package/lib/stringTrim.js +20 -24
  168. package/lib/stringifyQuery.d.ts +1 -1
  169. package/lib/stringifyQuery.js +15 -14
  170. package/lib/throttle.d.ts +5 -0
  171. package/lib/throttle.js +21 -0
  172. package/lib/typeOf.d.ts +1 -1
  173. package/lib/typeOf.js +5 -7
  174. package/package.json +15 -17
package/lib/isAndroid.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isAndroid = isAndroid;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAndroid = void 0;
7
4
  /**
8
5
  * 校验是否是安卓
9
6
  */
10
7
  function isAndroid() {
11
- return /android/.test(navigator.userAgent.toLowerCase());
12
- }
8
+ return /android/.test(navigator.userAgent.toLowerCase());
9
+ }
10
+ exports.isAndroid = isAndroid;
package/lib/isArray.js CHANGED
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isArray = isArray;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isArray = void 0;
7
4
  /**
8
5
  * 判断是否是数组
9
6
  * @param val 待判断值
10
7
  * @returns 是否
11
8
  */
12
9
  function isArray(val) {
13
- return Array.isArray(val);
14
- }
10
+ return Array.isArray(val);
11
+ }
12
+ exports.isArray = isArray;
package/lib/isBoolean.js CHANGED
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isBoolean = isBoolean;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBoolean = void 0;
7
4
  /**
8
5
  * 判断是否是布尔值
9
6
  * @param val 需要判断的值
10
7
  */
11
8
  function isBoolean(val) {
12
- return typeof val === 'boolean';
13
- }
9
+ return typeof val === 'boolean';
10
+ }
11
+ exports.isBoolean = isBoolean;
package/lib/isEmail.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isEmail = isEmail;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmail = void 0;
7
4
  /**
8
5
  * 校验是否是邮箱
9
6
  */
10
7
  function isEmail(val) {
11
- return /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(val);
12
- }
8
+ return /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(val);
9
+ }
10
+ exports.isEmail = isEmail;
package/lib/isEmpty.js CHANGED
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isEmpty = isEmpty;
7
- var _isNull = require("./isNull");
8
- var _isUndefined = require("./isUndefined");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmpty = void 0;
4
+ const isNull_1 = require("./isNull");
5
+ const isUndefined_1 = require("./isUndefined");
9
6
  /**
10
7
  * 校验是否为空 ''、undefined、null
11
8
  */
12
9
  function isEmpty(val) {
13
- return val === '' || (0, _isNull.isNull)(val) || (0, _isUndefined.isUndefined)(val);
14
- }
10
+ return val === '' || (0, isNull_1.isNull)(val) || (0, isUndefined_1.isUndefined)(val);
11
+ }
12
+ exports.isEmpty = isEmpty;
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isEmptyObject = isEmptyObject;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEmptyObject = void 0;
7
4
  /**
8
5
  * 判断是否是空对象
9
6
  * @param v 对象
10
7
  */
11
8
  function isEmptyObject(v) {
12
- return !Object.keys(v).length;
13
- }
9
+ return !Object.keys(v).length;
10
+ }
11
+ exports.isEmptyObject = isEmptyObject;
package/lib/isError.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isError = isError;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isError = void 0;
7
4
  /**
8
5
  * 校验是否是 error
9
6
  */
10
7
  function isError(val) {
11
- return val instanceof Error;
12
- }
8
+ return val instanceof Error;
9
+ }
10
+ exports.isError = isError;
package/lib/isFunction.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isFunction = isFunction;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFunction = void 0;
7
4
  /**
8
5
  * 校验是否是函数
9
6
  */
10
7
  function isFunction(val) {
11
- return typeof val === 'function';
12
- }
8
+ return typeof val === 'function';
9
+ }
10
+ exports.isFunction = isFunction;
package/lib/isIOS.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isIOS = isIOS;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isIOS = void 0;
7
4
  /**
8
5
  * 校验是否是ios
9
6
  */
10
7
  function isIOS() {
11
- return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
12
- }
8
+ return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
9
+ }
10
+ exports.isIOS = isIOS;
package/lib/isIdCard.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isIdCard = isIdCard;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isIdCard = void 0;
7
4
  /**
8
5
  * 校验是否是身份证
9
6
  */
10
7
  function isIdCard(val) {
11
- return /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/.test(val);
12
- }
8
+ return /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/.test(val);
9
+ }
10
+ exports.isIdCard = isIdCard;
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isJSONString = isJSONString;
7
- var _isObject = require("./isObject");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isJSONString = void 0;
4
+ const isObject_1 = require("./isObject");
8
5
  /**
9
6
  * 是否是JSON 字符串
10
7
  * @param v
11
8
  */
12
9
  function isJSONString(v) {
13
- try {
14
- var obj = JSON.parse(v);
15
- return (0, _isObject.isObject)(obj);
16
- } catch (_unused) {
17
- return false;
18
- }
19
- }
10
+ try {
11
+ const obj = JSON.parse(v);
12
+ return (0, isObject_1.isObject)(obj);
13
+ }
14
+ catch (_a) {
15
+ return false;
16
+ }
17
+ }
18
+ exports.isJSONString = isJSONString;
package/lib/isLan.js CHANGED
@@ -1,41 +1,40 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isLan = isLan;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLan = void 0;
7
4
  /**
8
5
  * 判断 ip 是否是局域网 ip,仅支持 ipv4
9
6
  * @param ip ipv4 地址
10
7
  */
11
8
  function isLan(ip) {
12
- // eslint-disable-next-line no-param-reassign
13
- ip = ip.toLocaleLowerCase();
14
- if (ip === 'localhost') {
15
- return true;
16
- }
17
- if (ip === '') {
18
- return false;
19
- }
20
- var v = 0;
21
- var aNum = ip.split('.');
22
- if (aNum.length !== 4) {
23
- return false;
24
- }
25
- // eslint-disable-next-line no-bitwise
26
- v += parseInt(aNum[0], 10) << 24;
27
- // eslint-disable-next-line no-bitwise
28
- v += parseInt(aNum[1], 10) << 16;
29
- // eslint-disable-next-line no-bitwise
30
- v += parseInt(aNum[2], 10) << 8;
31
- // eslint-disable-next-line no-bitwise
32
- v += parseInt(aNum[3], 10) << 0;
33
- // eslint-disable-next-line no-bitwise
34
- v = v >> 16 & 0xffff;
35
- return (
9
+ // eslint-disable-next-line no-param-reassign
10
+ ip = ip.toLocaleLowerCase();
11
+ if (ip === 'localhost') {
12
+ return true;
13
+ }
14
+ if (ip === '') {
15
+ return false;
16
+ }
17
+ let v = 0;
18
+ const aNum = ip.split('.');
19
+ if (aNum.length !== 4) {
20
+ return false;
21
+ }
36
22
  // eslint-disable-next-line no-bitwise
37
- v >> 8 === 0x7f ||
23
+ v += parseInt(aNum[0], 10) << 24;
24
+ // eslint-disable-next-line no-bitwise
25
+ v += parseInt(aNum[1], 10) << 16;
26
+ // eslint-disable-next-line no-bitwise
27
+ v += parseInt(aNum[2], 10) << 8;
38
28
  // eslint-disable-next-line no-bitwise
39
- v >> 8 === 0xa || v === 0xc0a8 || v >= 0xac10 && v <= 0xac1f
40
- );
41
- }
29
+ v += parseInt(aNum[3], 10) << 0;
30
+ // eslint-disable-next-line no-bitwise
31
+ v = (v >> 16) & 0xffff;
32
+ return (
33
+ // eslint-disable-next-line no-bitwise
34
+ v >> 8 === 0x7f ||
35
+ // eslint-disable-next-line no-bitwise
36
+ v >> 8 === 0xa ||
37
+ v === 0xc0a8 ||
38
+ (v >= 0xac10 && v <= 0xac1f));
39
+ }
40
+ exports.isLan = isLan;
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isLicenseCode = isLicenseCode;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isLicenseCode = void 0;
7
4
  /**
8
5
  * 校验是否是车牌号
9
6
  * @param v 车牌号
10
7
  */
11
8
  function isLicenseCode(v) {
12
- return /(^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4,5}[A-Z0-9挂学警港澳]{1}$)/.test(v);
13
- }
9
+ return /(^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4,5}[A-Z0-9挂学警港澳]{1}$)/.test(v);
10
+ }
11
+ exports.isLicenseCode = isLicenseCode;
package/lib/isMobile.js CHANGED
@@ -1,16 +1,15 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isMobile = isMobile;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMobile = void 0;
7
4
  /**
8
5
  * 校验设备是否是手机
9
6
  */
10
7
  function isMobile() {
11
- if (typeof navigator === 'undefined' || typeof window === 'undefined') {
12
- return false;
13
- }
14
- var agent = navigator.userAgent || navigator.vendor || window.opera;
15
- return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substr(0, 4));
16
- }
8
+ if (typeof navigator === 'undefined' || typeof window === 'undefined') {
9
+ return false;
10
+ }
11
+ const agent = navigator.userAgent || navigator.vendor || window.opera;
12
+ return (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(agent) ||
13
+ /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(agent === null || agent === void 0 ? void 0 : agent.substr(0, 4)));
14
+ }
15
+ exports.isMobile = isMobile;
package/lib/isNull.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isNull = isNull;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNull = void 0;
7
4
  /**
8
5
  * 校验是否是 null
9
6
  */
10
7
  function isNull(val) {
11
- return val === null;
12
- }
8
+ return val === null;
9
+ }
10
+ exports.isNull = isNull;
package/lib/isNumber.js CHANGED
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isNumber = isNumber;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNumber = void 0;
7
4
  /**
8
5
  * 判断是否是数字
9
6
  * @param val 需要判断的值
10
7
  */
11
8
  function isNumber(val) {
12
- return /^\d$/.test(val);
13
- }
9
+ return /^\d$/.test(val);
10
+ }
11
+ exports.isNumber = isNumber;
package/lib/isObject.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isObject = isObject;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObject = void 0;
7
4
  /**
8
5
  * 校验是否是对象
9
6
  */
10
7
  function isObject(val) {
11
- return Object.prototype.toString.call(val) === '[object Object]';
12
- }
8
+ return Object.prototype.toString.call(val) === '[object Object]';
9
+ }
10
+ exports.isObject = isObject;
package/lib/isPhone.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isPhone = isPhone;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPhone = void 0;
7
4
  /**
8
5
  * 校验是否是手机号码
9
6
  */
10
7
  function isPhone(val) {
11
- return /^1\d{10}$/.test(val);
12
- }
8
+ return /^1\d{10}$/.test(val);
9
+ }
10
+ exports.isPhone = isPhone;
package/lib/isPromise.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isPromise = isPromise;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPromise = void 0;
7
4
  /**
8
5
  * 校验是否是 promise
9
6
  */
10
7
  function isPromise(val) {
11
- return val instanceof Promise || !!val.then || !!val["catch"];
12
- }
8
+ return val instanceof Promise || !!val.then || !!val.catch;
9
+ }
10
+ exports.isPromise = isPromise;
package/lib/isRegExp.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isRegExp = isRegExp;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRegExp = void 0;
7
4
  /**
8
5
  * 校验是否是正则表达式
9
6
  */
10
7
  function isRegExp(val) {
11
- return val instanceof RegExp;
12
- }
8
+ return val instanceof RegExp;
9
+ }
10
+ exports.isRegExp = isRegExp;
package/lib/isString.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isString = isString;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isString = void 0;
7
4
  /**
8
5
  * 校验是否是字符串
9
6
  */
10
7
  function isString(val) {
11
- return typeof val === 'string';
12
- }
8
+ return typeof val === 'string';
9
+ }
10
+ exports.isString = isString;
package/lib/isURL.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 判断是否是 url
3
+ */
4
+ export declare function isURL(val: unknown): boolean;
package/lib/isURL.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isURL = void 0;
4
+ /**
5
+ * 判断是否是 url
6
+ */
7
+ function isURL(val) {
8
+ return /^(http)|(\.*\/)/.test(`${val}`);
9
+ }
10
+ exports.isURL = isURL;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isUndefined = isUndefined;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUndefined = void 0;
7
4
  /**
8
5
  * 校验是否是 undefined
9
6
  */
10
7
  function isUndefined(val) {
11
- return typeof val === 'undefined';
12
- }
8
+ return typeof val === 'undefined';
9
+ }
10
+ exports.isUndefined = isUndefined;
package/lib/isWeixin.js CHANGED
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isWeixin = isWeixin;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isWeixin = void 0;
7
4
  /**
8
5
  * 是否是微信环境
9
6
  */
10
7
  function isWeixin() {
11
- return /MicroMessenger/gi.test(navigator.userAgent);
12
- }
8
+ return /MicroMessenger/gi.test(navigator.userAgent);
9
+ }
10
+ exports.isWeixin = isWeixin;
package/lib/isWindow.js CHANGED
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isWindow = isWindow;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isWindow = void 0;
7
4
  /**
8
5
  * 判断是否是 window 对象
9
6
  * @param val 需要判断的值
10
7
  */
11
8
  function isWindow(val) {
12
- return val === window;
13
- }
9
+ return val === window;
10
+ }
11
+ exports.isWindow = isWindow;
@@ -4,4 +4,4 @@
4
4
  * @param type 类型
5
5
  * @param callback 回调函数
6
6
  */
7
- export declare function loadResource(res: string, type: 'js' | 'css' | 'style', callback?: any): void;
7
+ export declare function loadResource(res: string, type: 'js' | 'css' | 'style', callback?: () => void): void;
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.loadResource = loadResource;
7
- var _isFunction = require("./isFunction");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadResource = void 0;
4
+ const isFunction_1 = require("./isFunction");
8
5
  /**
9
6
  * 加载外部js、css、写入style样式
10
7
  * @param res 资源url或内容
@@ -12,26 +9,31 @@ var _isFunction = require("./isFunction");
12
9
  * @param callback 回调函数
13
10
  */
14
11
  function loadResource(res, type, callback) {
15
- var ref;
16
- if (type === 'js') {
17
- // 外部js
18
- ref = document.createElement('js');
19
- ref.setAttribute('type', 'text/javascript');
20
- ref.setAttribute('src', res);
21
- } else if (type === 'css') {
22
- // 外部css
23
- ref = document.createElement('link');
24
- ref.setAttribute('rel', 'stylesheet');
25
- ref.setAttribute('type', 'text/css');
26
- ref.setAttribute('href', res);
27
- } else if (type === 'style') {
28
- ref = document.createElement('style');
29
- ref.innerHTML = res;
30
- }
31
- if (ref) {
32
- document.querySelector('head').appendChild(ref);
33
- ref.onload = function () {
34
- if ((0, _isFunction.isFunction)(callback)) callback();
35
- };
36
- }
37
- }
12
+ var _a;
13
+ let ref = null;
14
+ if (type === 'js') {
15
+ // 外部js
16
+ ref = document.createElement('js');
17
+ ref.setAttribute('type', 'text/javascript');
18
+ ref.setAttribute('src', res);
19
+ }
20
+ else if (type === 'css') {
21
+ // 外部css
22
+ ref = document.createElement('link');
23
+ ref.setAttribute('rel', 'stylesheet');
24
+ ref.setAttribute('type', 'text/css');
25
+ ref.setAttribute('href', res);
26
+ }
27
+ else if (type === 'style') {
28
+ ref = document.createElement('style');
29
+ ref.innerHTML = res;
30
+ }
31
+ if (ref) {
32
+ (_a = document.querySelector('head')) === null || _a === void 0 ? void 0 : _a.appendChild(ref);
33
+ ref.onload = () => {
34
+ if ((0, isFunction_1.isFunction)(callback))
35
+ callback();
36
+ };
37
+ }
38
+ }
39
+ exports.loadResource = loadResource;