util-helpers 4.17.2 → 4.18.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.
Files changed (168) hide show
  1. package/README.md +1 -1
  2. package/dist/util-helpers.js +305 -184
  3. package/dist/util-helpers.js.map +1 -1
  4. package/dist/util-helpers.min.js +1 -1
  5. package/dist/util-helpers.min.js.map +1 -1
  6. package/esm/VERSION.js +4 -0
  7. package/esm/calculateCursorPosition.js +3 -3
  8. package/esm/divide.js +2 -2
  9. package/esm/download.js +1 -2
  10. package/esm/filterTree.js +1 -1
  11. package/esm/findTreeNode.js +1 -1
  12. package/esm/findTreeNodes.js +1 -1
  13. package/esm/findTreeSelect.js +1 -1
  14. package/esm/formatBankCard.js +2 -2
  15. package/esm/formatMobile.js +2 -2
  16. package/esm/formatMoney.js +3 -3
  17. package/esm/index.js +6 -1
  18. package/esm/isBankCard.js +2 -2
  19. package/esm/isBusinessLicense.js +2 -2
  20. package/esm/isChinese.js +2 -2
  21. package/esm/isEmail.js +2 -2
  22. package/esm/isHMCard.js +2 -2
  23. package/esm/isIPv4.js +2 -2
  24. package/esm/isIPv6.js +2 -2
  25. package/esm/isIdCard.js +2 -2
  26. package/esm/isMobile.js +2 -2
  27. package/esm/isPassport.js +2 -2
  28. package/esm/isPostcode.js +2 -2
  29. package/esm/isPromiseLike.js +3 -1
  30. package/esm/isQQ.js +2 -2
  31. package/esm/isSocialCreditCode.js +2 -2
  32. package/esm/isSwiftCode.js +2 -2
  33. package/esm/isTWCard.js +2 -2
  34. package/esm/isTelephone.js +2 -2
  35. package/esm/isUrl.js +2 -2
  36. package/esm/isValidNumber.js +1 -1
  37. package/esm/isVehicle.js +2 -2
  38. package/esm/isWX.js +2 -2
  39. package/esm/listToTree.js +1 -1
  40. package/esm/minus.js +2 -2
  41. package/esm/normalizeString.js +2 -6
  42. package/esm/padZero.js +2 -2
  43. package/esm/plus.js +2 -2
  44. package/esm/replaceChar.js +2 -2
  45. package/esm/round.js +2 -2
  46. package/esm/strlen.js +2 -2
  47. package/esm/times.js +2 -2
  48. package/esm/transformFieldNames.js +1 -1
  49. package/esm/treeToList.js +1 -1
  50. package/esm/utils/config.js +1 -2
  51. package/esm/utils/math.util.js +1 -4
  52. package/esm/waitTime.js +3 -3
  53. package/lib/VERSION.js +6 -0
  54. package/lib/calculateCursorPosition.js +3 -3
  55. package/lib/divide.js +2 -2
  56. package/lib/download.js +4 -5
  57. package/lib/filterTree.js +3 -3
  58. package/lib/findTreeNode.js +2 -2
  59. package/lib/findTreeNodes.js +2 -2
  60. package/lib/findTreeSelect.js +2 -2
  61. package/lib/formatBankCard.js +2 -2
  62. package/lib/formatMobile.js +2 -2
  63. package/lib/formatMoney.js +3 -3
  64. package/lib/index.js +3 -5
  65. package/lib/isBankCard.js +2 -2
  66. package/lib/isBusinessLicense.js +2 -2
  67. package/lib/isChinese.js +2 -2
  68. package/lib/isEmail.js +2 -2
  69. package/lib/isHMCard.js +2 -2
  70. package/lib/isIPv4.js +2 -2
  71. package/lib/isIPv6.js +2 -2
  72. package/lib/isIdCard.js +2 -2
  73. package/lib/isMobile.js +2 -2
  74. package/lib/isPassport.js +2 -2
  75. package/lib/isPostcode.js +2 -2
  76. package/lib/isPromiseLike.js +3 -1
  77. package/lib/isQQ.js +2 -2
  78. package/lib/isSocialCreditCode.js +2 -2
  79. package/lib/isSwiftCode.js +2 -2
  80. package/lib/isTWCard.js +2 -2
  81. package/lib/isTelephone.js +2 -2
  82. package/lib/isUrl.js +2 -2
  83. package/lib/isValidNumber.js +2 -2
  84. package/lib/isVehicle.js +2 -2
  85. package/lib/isWX.js +2 -2
  86. package/lib/listToTree.js +2 -2
  87. package/lib/minus.js +2 -2
  88. package/lib/normalizeString.js +2 -6
  89. package/lib/padZero.js +2 -2
  90. package/lib/plus.js +2 -2
  91. package/lib/replaceChar.js +2 -2
  92. package/lib/round.js +2 -2
  93. package/lib/strlen.js +2 -2
  94. package/lib/times.js +2 -2
  95. package/lib/transformFieldNames.js +2 -2
  96. package/lib/treeToList.js +2 -2
  97. package/lib/utils/config.js +0 -1
  98. package/lib/utils/math.util.js +5 -8
  99. package/lib/waitTime.js +3 -3
  100. package/package.json +22 -23
  101. package/types/VERSION.d.ts +8 -0
  102. package/types/ajax.d.ts +1 -1
  103. package/types/blobToDataURL.d.ts +1 -1
  104. package/types/calculateCursorPosition.d.ts +1 -1
  105. package/types/download.d.ts +7 -3
  106. package/types/filterTree.d.ts +3 -1
  107. package/types/formatBankCard.d.ts +1 -1
  108. package/types/formatMobile.d.ts +1 -1
  109. package/types/index.d.ts +7 -1
  110. package/types/isIdCard.d.ts +3 -1
  111. package/types/isPromiseLike.d.ts +1 -0
  112. package/types/normalizeString.d.ts +2 -1
  113. package/types/numberToChinese.d.ts +1 -1
  114. package/types/padZero.d.ts +1 -1
  115. package/types/replaceChar.d.ts +4 -1
  116. package/types/setDataURLPrefix.d.ts +2 -1
  117. package/types/treeToList.d.ts +3 -6
  118. package/types/utils/config.d.ts +1 -2
  119. package/types/waitTime.d.ts +2 -1
  120. package/esm/utils/constants.js +0 -4
  121. package/esm/utils/convertToString.js +0 -7
  122. package/esm/utils/type/isBlob.js +0 -7
  123. package/esm/utils/type/isNaN.js +0 -7
  124. package/esm/utils/type/isNil.js +0 -8
  125. package/esm/utils/type/isNull.js +0 -5
  126. package/esm/utils/type/isNumber.js +0 -7
  127. package/esm/utils/type/isObject.js +0 -6
  128. package/esm/utils/type/isString.js +0 -7
  129. package/esm/utils/type/isSymbol.js +0 -7
  130. package/esm/utils/type/isType.js +0 -6
  131. package/esm/utils/type/isUndefined.js +0 -5
  132. package/lib/utils/constants.js +0 -4
  133. package/lib/utils/convertToString.js +0 -9
  134. package/lib/utils/type/isBlob.js +0 -9
  135. package/lib/utils/type/isNaN.js +0 -9
  136. package/lib/utils/type/isNil.js +0 -10
  137. package/lib/utils/type/isNull.js +0 -7
  138. package/lib/utils/type/isNumber.js +0 -9
  139. package/lib/utils/type/isObject.js +0 -8
  140. package/lib/utils/type/isString.js +0 -9
  141. package/lib/utils/type/isSymbol.js +0 -9
  142. package/lib/utils/type/isType.js +0 -8
  143. package/lib/utils/type/isUndefined.js +0 -7
  144. package/types/utils/constants.d.ts +0 -2
  145. package/types/utils/convertToString.d.ts +0 -8
  146. package/types/utils/type/index.d.ts +0 -28
  147. package/types/utils/type/isArguments.d.ts +0 -18
  148. package/types/utils/type/isArray.d.ts +0 -18
  149. package/types/utils/type/isArrayBuffer.d.ts +0 -21
  150. package/types/utils/type/isBlob.d.ts +0 -23
  151. package/types/utils/type/isBoolean.d.ts +0 -18
  152. package/types/utils/type/isDate.d.ts +0 -18
  153. package/types/utils/type/isError.d.ts +0 -18
  154. package/types/utils/type/isFunction.d.ts +0 -18
  155. package/types/utils/type/isMap.d.ts +0 -18
  156. package/types/utils/type/isNaN.d.ts +0 -18
  157. package/types/utils/type/isNil.d.ts +0 -11
  158. package/types/utils/type/isNull.d.ts +0 -18
  159. package/types/utils/type/isNumber.d.ts +0 -27
  160. package/types/utils/type/isObject.d.ts +0 -21
  161. package/types/utils/type/isRegExp.d.ts +0 -18
  162. package/types/utils/type/isSet.d.ts +0 -18
  163. package/types/utils/type/isString.d.ts +0 -18
  164. package/types/utils/type/isSymbol.d.ts +0 -18
  165. package/types/utils/type/isType.d.ts +0 -11
  166. package/types/utils/type/isUndefined.d.ts +0 -21
  167. package/types/utils/type/isWeakMap.d.ts +0 -18
  168. package/types/utils/type/isWeakSet.d.ts +0 -18
package/lib/round.js CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ var ut2 = require('ut2');
3
4
  var divide = require('./divide.js');
4
5
  var times = require('./times.js');
5
6
  var math_util = require('./utils/math.util.js');
6
- var isNaN = require('./utils/type/isNaN.js');
7
7
 
8
8
  function round(num, precision) {
9
9
  if (precision === void 0) { precision = 0; }
10
10
  num = math_util.transformEffectiveNumber(num);
11
- if (isNaN(num)) {
11
+ if (ut2.isNaN(num)) {
12
12
  return Number.NaN;
13
13
  }
14
14
  var base = Math.pow(10, precision);
package/lib/strlen.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var normalizeString = require('./normalizeString.js');
3
+ var ut2 = require('ut2');
4
4
 
5
5
  function strlen(str) {
6
- var realStr = normalizeString(str);
6
+ var realStr = ut2.toString(str);
7
7
  var len = 0;
8
8
  for (var i = 0; i < realStr.length; i++) {
9
9
  var c = realStr.charCodeAt(i);
package/lib/times.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var tslib = require('tslib');
4
+ var ut2 = require('ut2');
4
5
  var math_util = require('./utils/math.util.js');
5
- var isNaN = require('./utils/type/isNaN.js');
6
6
 
7
7
  function times() {
8
8
  var nums = [];
@@ -15,7 +15,7 @@ function times() {
15
15
  }
16
16
  num1 = math_util.transformEffectiveNumber(num1);
17
17
  num2 = math_util.transformEffectiveNumber(num2);
18
- if (isNaN(num1) || isNaN(num2)) {
18
+ if (ut2.isNaN(num1) || ut2.isNaN(num2)) {
19
19
  return Number.NaN;
20
20
  }
21
21
  var num1Changed = math_util.float2Fixed(num1);
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var tslib = require('tslib');
4
- var isObject = require('./utils/type/isObject.js');
4
+ var ut2 = require('ut2');
5
5
 
6
6
  function transformFieldNames(data, fieldNames, childrenField, nodeAssign) {
7
7
  if (nodeAssign === void 0) { nodeAssign = 'spread'; }
@@ -13,7 +13,7 @@ function transformFieldNames(data, fieldNames, childrenField, nodeAssign) {
13
13
  }
14
14
  function recusion(arr) {
15
15
  return arr.map(function (item) {
16
- if (!isObject(item)) {
16
+ if (!ut2.isObject(item)) {
17
17
  return item;
18
18
  }
19
19
  var newItem = nodeAssign === 'spread' ? tslib.__assign({}, item) : item;
package/lib/treeToList.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var tslib = require('tslib');
4
- var isObject = require('./utils/type/isObject.js');
4
+ var ut2 = require('ut2');
5
5
 
6
6
  function treeToList(tree, childrenField) {
7
7
  var list = [];
@@ -10,7 +10,7 @@ function treeToList(tree, childrenField) {
10
10
  }
11
11
  function recusion(arr) {
12
12
  arr.forEach(function (item) {
13
- if (isObject(item)) {
13
+ if (ut2.isObject(item)) {
14
14
  var newItem = tslib.__assign({}, item);
15
15
  list.push(newItem);
16
16
  if (newItem[childrenField]) {
@@ -6,6 +6,5 @@ exports.config = {
6
6
  function setDisableWarning(bool) {
7
7
  exports.config.disableWarning = !!bool;
8
8
  }
9
- exports.version = "4.17.2";
10
9
 
11
10
  exports.setDisableWarning = setDisableWarning;
@@ -1,14 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var constants = require('./constants.js');
3
+ var ut2 = require('ut2');
4
4
  var devWarn = require('./devWarn.js');
5
- var isNumber = require('./type/isNumber.js');
6
- var isString = require('./type/isString.js');
7
- var isSymbol = require('./type/isSymbol.js');
8
5
 
9
6
  function transformEffectiveNumber(value) {
10
7
  var ret;
11
- if (isString(value)) {
8
+ if (ut2.isString(value)) {
12
9
  ret = value.trim();
13
10
  if (ret === '') {
14
11
  ret = Number(ret);
@@ -17,10 +14,10 @@ function transformEffectiveNumber(value) {
17
14
  ret = Number.NaN;
18
15
  }
19
16
  }
20
- else if (isSymbol(value)) {
17
+ else if (ut2.isSymbol(value)) {
21
18
  ret = Number.NaN;
22
19
  }
23
- else if (!isNumber(value)) {
20
+ else if (!ut2.isNumber(value)) {
24
21
  ret = Number(value);
25
22
  }
26
23
  else {
@@ -52,7 +49,7 @@ function float2Fixed(num) {
52
49
  return dLen > 0 ? strip(+num * Math.pow(10, dLen)) : +num;
53
50
  }
54
51
  function checkBoundary(num) {
55
- if (+num > constants.MAX_SAFE_INTEGER || +num < constants.MIN_SAFE_INTEGER) {
52
+ if (+num > ut2.MAX_SAFE_INTEGER || +num < ut2.MIN_SAFE_INTEGER) {
56
53
  devWarn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
57
54
  }
58
55
  }
package/lib/waitTime.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var ut2 = require('ut2');
4
+
3
5
  function waitTime(time) {
4
6
  if (time === void 0) { time = 1000; }
5
- return new Promise(function (resolve) {
6
- setTimeout(resolve, time);
7
- });
7
+ return ut2.sleep(time);
8
8
  }
9
9
 
10
10
  module.exports = waitTime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "4.17.2",
3
+ "version": "4.18.0",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -18,12 +18,11 @@
18
18
  "build": "npm run build:module && npm run build:dist && npm run build:types",
19
19
  "build:module": "rm -rf esm && rm -rf lib && rollup -c rollup.module.config.mjs",
20
20
  "build:dist": "rm -rf dist && rollup -c rollup.umd.config.mjs",
21
- "build:types": "rm -rf types && tsc -d --outDir types --emitDeclarationOnly",
21
+ "build:types": "rm -rf types && tsc -p tsconfig.build.json -d --outDir types --emitDeclarationOnly",
22
22
  "build:doc": "npm run doc",
23
- "doc": "rm -rf docs && rm -rf docs-src && tsc --outDir docs-src && jsdoc -c conf.json && rm -rf docs-src",
23
+ "doc": "rm -rf docs && rm -rf docs-src && tsc -p tsconfig.build.json --outDir docs-src && jsdoc -c conf.json && rm -rf docs-src",
24
24
  "doc:open": "open ./docs/index.html",
25
25
  "prettier": "prettier --write 'src/**/*.ts' && prettier --write 'test/**/*.ts'",
26
- "precommit": "lint-staged",
27
26
  "lint": "eslint src --ext .ts",
28
27
  "lint:fix": "eslint src --ext .ts --fix",
29
28
  "commit": "cz",
@@ -55,42 +54,41 @@
55
54
  },
56
55
  "homepage": "https://doly-dev.github.io/util-helpers/index.html",
57
56
  "devDependencies": {
58
- "@babel/core": "^7.21.4",
59
- "@babel/preset-env": "^7.21.4",
60
- "@babel/preset-typescript": "^7.21.4",
61
- "@commitlint/cli": "^11.0.0",
62
- "@commitlint/config-conventional": "^11.0.0",
57
+ "@babel/core": "^7.21.8",
58
+ "@babel/preset-env": "^7.21.5",
59
+ "@babel/preset-typescript": "^7.21.5",
60
+ "@commitlint/cli": "^17.6.3",
61
+ "@commitlint/config-conventional": "^17.6.3",
63
62
  "@rollup/plugin-commonjs": "^24.1.0",
64
63
  "@rollup/plugin-node-resolve": "^15.0.2",
65
64
  "@rollup/plugin-replace": "^5.0.2",
66
65
  "@rollup/plugin-terser": "^0.4.1",
67
66
  "@rollup/plugin-typescript": "^11.1.0",
68
67
  "@types/jest": "^29.5.1",
69
- "@typescript-eslint/eslint-plugin": "^5.59.1",
70
- "@typescript-eslint/parser": "^5.59.1",
68
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
69
+ "@typescript-eslint/parser": "^5.59.5",
71
70
  "babel-jest": "^29.5.0",
72
71
  "babel-plugin-minify-replace": "^0.5.0",
73
72
  "cross-env": "^7.0.3",
74
73
  "cz-conventional-changelog": "^3.3.0",
75
- "docdash": "^1.2.0",
76
- "eslint": "^8.39.0",
77
- "husky": "^4.3.6",
74
+ "docdash": "^2.0.1",
75
+ "eslint": "^8.40.0",
78
76
  "jest": "^29.5.0",
79
77
  "jest-environment-jsdom": "^29.5.0",
80
- "jsdoc": "^3.6.3",
81
- "lint-staged": "^11.1.2",
78
+ "jsdoc": "^4.0.2",
79
+ "lint-staged": "^13.2.2",
82
80
  "prettier": "^2.8.8",
83
- "rollup": "^3.21.0",
84
- "typescript": "^5.0.4"
81
+ "rollup": "^3.21.6",
82
+ "typescript": "^5.0.4",
83
+ "yorkie": "^2.0.0"
85
84
  },
86
85
  "lint-staged": {
87
86
  "**/*.ts": "eslint",
88
87
  "**/*.{js,ts,md}": "prettier --write"
89
88
  },
90
- "husky": {
91
- "hooks": {
92
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
93
- }
89
+ "gitHooks": {
90
+ "pre-commit": "lint-staged",
91
+ "commit-msg": "npx --no -- commitlint --edit \"$1\""
94
92
  },
95
93
  "config": {
96
94
  "commitizen": {
@@ -98,6 +96,7 @@
98
96
  }
99
97
  },
100
98
  "dependencies": {
101
- "tslib": "^2.5.0"
99
+ "tslib": "^2.5.0",
100
+ "ut2": "^1.0.0"
102
101
  }
103
102
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * util-helpers 版本号
3
+ *
4
+ * @static
5
+ * @since 4.18.0
6
+ */
7
+ declare const VERSION: string;
8
+ export default VERSION;
package/types/ajax.d.ts CHANGED
@@ -40,7 +40,7 @@ type AjaxOptions = {
40
40
  * @property {function} [onLoadEnd] 请求结束时触发,无论请求成功 (load) 还是失败 (abort 或 error)
41
41
  */
42
42
  /**
43
- * 请求<br/><br/>
43
+ * 请求
44
44
  *
45
45
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
46
46
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 将 Blob 或 File 对象转成 data:URL 格式的 Base64 字符串<br/><br/>
2
+ * 将 Blob 或 File 对象转成 data:URL 格式的 Base64 字符串
3
3
  *
4
4
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  type CalculateCursorPositionOptions = {
2
- placeholderChar?: string;
2
+ placeholderChar?: string | string[];
3
3
  maskReg?: RegExp;
4
4
  type?: 'mobile' | 'bankCard';
5
5
  };
@@ -29,7 +29,7 @@ type DownloadOptions = {
29
29
  * @property {TransformResponse} [options.transformResponse] 请求成功后触发,在传递给 then/catch 前,允许修改响应数据
30
30
  */
31
31
  /**
32
- * 下载<br/><br/>
32
+ * 下载
33
33
  *
34
34
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端,兼容 IE10+ 和现代浏览器。</em>
35
35
  *
@@ -45,8 +45,12 @@ type DownloadOptions = {
45
45
  * // 文本
46
46
  * download('hello world', 'text.txt');
47
47
  *
48
- * // 远程文件
49
- * download('/xxx.jpg', { dataType: 'url' });
48
+ * // 远程文件1
49
+ * // 不带协议的绝对地址,需要通过 dataType 指定为 url 类型
50
+ * download('/xxx.jpg', { dataType: 'url', fileName: 'test.jpg' });
51
+ *
52
+ * // 远程文件2
53
+ * download('https://example.com/xxx.jpg');
50
54
  *
51
55
  * // base64
52
56
  * download('data:image/png;base64,PGEgaWQ9ImEiPjxiIGlkPSJiIj5oZXkhPC9iPjwvYT4=', 'test.png');
@@ -1,6 +1,8 @@
1
1
  type NodeAssign = 'spread' | 'self';
2
2
  /**
3
- * 过滤/筛选树节点。<br/><br/>如果某节点被过滤掉,它的子节点也一并抛弃
3
+ * 过滤/筛选树节点。
4
+ *
5
+ * 如果某节点被过滤掉,它的子节点也一并抛弃。
4
6
  *
5
7
  * @static
6
8
  * @alias module:Tree.filterTree
@@ -30,5 +30,5 @@ type Options = {
30
30
  * formatBankCard('6228480402564890', {spaceMark: '-'}); // 6228-4804-0256-4890
31
31
  *
32
32
  */
33
- declare function formatBankCard(bankCardNo?: string, options?: Options): string;
33
+ declare function formatBankCard(bankCardNo?: string, options?: Options): any;
34
34
  export default formatBankCard;
@@ -28,5 +28,5 @@ type Options = {
28
28
  * formatMobile('13345678'); // 133 4567 8
29
29
  *
30
30
  */
31
- declare function formatMobile(mobileNo?: string, options?: Options): string;
31
+ declare function formatMobile(mobileNo?: string, options?: Options): any;
32
32
  export default formatMobile;
package/types/index.d.ts CHANGED
@@ -123,4 +123,10 @@ export { default as findTreeSelect } from './findTreeSelect';
123
123
  * @ignore
124
124
  * @since 3.6.1
125
125
  */
126
- export { setDisableWarning, version } from './utils/config';
126
+ export { setDisableWarning } from './utils/config';
127
+ import VERSION from './VERSION';
128
+ export { VERSION };
129
+ /**
130
+ * @deprecated 即将废弃,请使用 `VERSION`
131
+ */
132
+ export declare const version: string;
@@ -3,7 +3,9 @@ type Options = {
3
3
  checkCode?: boolean;
4
4
  };
5
5
  /**
6
- * 检测值是否为18位身份证号码。<br/>宽松模式下,支持15位身份证号码
6
+ * 检测值是否为18位身份证号码。
7
+ *
8
+ * 宽松模式下,支持15位身份证号码。
7
9
  *
8
10
  * @static
9
11
  * @alias module:Validator.isIdCard
@@ -4,6 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Validator.isPromiseLike
6
6
  * @since 3.8.0
7
+ * @deprecated 即将废弃,请使用 `import { isPromiseLike } 'ut2'`
7
8
  * @param {*} obj 要检测的值
8
9
  * @returns {boolean} 是否类似Promise对象
9
10
  * @example
@@ -5,6 +5,7 @@
5
5
  * @alias module:Processor.normalizeString
6
6
  * @since 4.3.0
7
7
  * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String#string_instances | String}
8
+ * @deprecated 即将废弃,请使用 `import { toString } 'ut2'`
8
9
  * @param {*} value 待处理的值
9
10
  * @returns {string} 规整化的值
10
11
  * @example
@@ -20,5 +21,5 @@
20
21
  * normalizeString('a'); // 'a'
21
22
  *
22
23
  */
23
- declare function normalizeString(value: any): string;
24
+ declare function normalizeString(value: any): any;
24
25
  export default normalizeString;
@@ -10,7 +10,7 @@ type Options = {
10
10
  };
11
11
  };
12
12
  /**
13
- * 数字转中文数字<br/><br/>
13
+ * 数字转中文数字
14
14
  *
15
15
  * 如果数字不在安全数字 -9007199254740991~9007199254740991 范围内,处理会有异常。
16
16
  *
@@ -21,5 +21,5 @@
21
21
  * padZero('688', 5); // 00688
22
22
  *
23
23
  */
24
- declare function padZero(value: string | number, size?: number): string;
24
+ declare function padZero(value: string | number, size?: number): any;
25
25
  export default padZero;
@@ -24,6 +24,9 @@ type Options = {
24
24
  * // 手机号 前3后4
25
25
  * replaceChar('13000000000'); // 130****0000
26
26
  *
27
+ * // 手机号 前2后4
28
+ * replaceChar('13000000000', { start: 2 }); // 13*****0000
29
+ *
27
30
  * // 身份证 前6后4
28
31
  * replaceChar('130701199310302288', { start: 6, end: -4 }); // 130701********2288
29
32
  *
@@ -50,5 +53,5 @@ type Options = {
50
53
  * replaceChar('林某某某', {start: 1, end: Infinity, repeat: 2}); // 林**
51
54
  *
52
55
  */
53
- declare function replaceChar(str: string, options?: Options): string;
56
+ declare function replaceChar(str: string, options?: Options): any;
54
57
  export default replaceChar;
@@ -1,5 +1,6 @@
1
1
  /**
2
- * 设置 DataURL 前缀、MIME 类型、base64 标识。<br/>
2
+ * 设置 DataURL 前缀、MIME 类型、base64 标识。
3
+ *
3
4
  * 如果你需要获取DataURL 的 MIME 类型和数据本身,推荐使用 <a href="https://www.npmjs.com/package/data-urls">data-urls</a>。
4
5
  *
5
6
  * @static
@@ -4,12 +4,9 @@
4
4
  * @static
5
5
  * @alias module:Tree.treeToList
6
6
  * @since 4.14.0
7
- * @template {Record<string,any>} T
8
- * @template {keyof T} K
9
- * @template {Omit<T, K>} R
10
- * @param {T[]} tree 列表数据
11
- * @param {K} childrenField 子级字段名称
12
- * @returns {R[]} 列表数据
7
+ * @param {object[]} tree 树结构数据
8
+ * @param {string} childrenField 子级字段名称
9
+ * @returns {object[]} 列表数据
13
10
  * @example
14
11
  * const menus = [{ "id": "1", "name": "首页", "code": "trade", "pid": null }, { "id": "2", "name": "交易管理", "code": "trade", "pid": null, "children": [{ "id": "3", "name": "交易查询", "code": "trade-1", "pid": "2", "children": [{ "id": "4", "name": "交易查询-查询操作", "code": "trade-1-1", "pid": "3" }] }] }, { "id": "5", "name": "权限管理", "code": "authorization", "pid": null, "children": [{ "id": "6", "name": "角色管理", "code": "authorization-1", "pid": "5" }, { "id": "7", "name": "用户管理", "code": "authorization-2", "pid": "5" }] }];
15
12
  *
@@ -9,5 +9,4 @@ declare const config: {
9
9
  * @param {boolean} bool 是否禁止warning提示
10
10
  */
11
11
  declare function setDisableWarning(bool: boolean): void;
12
- declare const version: string;
13
- export { config, setDisableWarning, version };
12
+ export { config, setDisableWarning };
@@ -4,6 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Other.waitTime
6
6
  * @since 4.2.0
7
+ * @deprecated 即将废弃,请使用 `import { sleep } from 'ut2'`
7
8
  * @param {number} [time=1000] 延时时间,单位毫秒
8
9
  * @returns {Promise<void>}
9
10
  * @example
@@ -18,5 +19,5 @@
18
19
  * });
19
20
  *
20
21
  */
21
- declare function waitTime(time?: number): Promise<unknown>;
22
+ declare function waitTime(time?: number): Promise<void>;
22
23
  export default waitTime;
@@ -1,4 +0,0 @@
1
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
2
- var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
3
-
4
- export { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER };
@@ -1,7 +0,0 @@
1
- import isString from './type/isString.js';
2
-
3
- function convertToString(value) {
4
- return isString(value) ? value : String(value);
5
- }
6
-
7
- export { convertToString as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function isBlob(value) {
4
- return isType(value, 'Blob');
5
- }
6
-
7
- export { isBlob as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function _isNaN(value) {
4
- return isType(value, 'Number') && isNaN(value);
5
- }
6
-
7
- export { _isNaN as default };
@@ -1,8 +0,0 @@
1
- import isUndefined from './isUndefined.js';
2
- import isNull from './isNull.js';
3
-
4
- function isNil(value) {
5
- return isUndefined(value) || isNull(value);
6
- }
7
-
8
- export { isNil as default };
@@ -1,5 +0,0 @@
1
- function isNull(value) {
2
- return value === null;
3
- }
4
-
5
- export { isNull as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function isNumber(value) {
4
- return isType(value, 'Number');
5
- }
6
-
7
- export { isNumber as default };
@@ -1,6 +0,0 @@
1
- function isObject(value) {
2
- var type = typeof value;
3
- return value != null && (type === 'object' || type === 'function');
4
- }
5
-
6
- export { isObject as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function isString(value) {
4
- return isType(value, 'String');
5
- }
6
-
7
- export { isString as default };
@@ -1,7 +0,0 @@
1
- import isType from './isType.js';
2
-
3
- function isSymbol(value) {
4
- return isType(value, 'Symbol');
5
- }
6
-
7
- export { isSymbol as default };
@@ -1,6 +0,0 @@
1
- var toString = Object.prototype.toString;
2
- function isType(value, typename) {
3
- return toString.call(value) === "[object ".concat(typename, "]");
4
- }
5
-
6
- export { isType as default };
@@ -1,5 +0,0 @@
1
- function isUndefined(value) {
2
- return value === void 0;
3
- }
4
-
5
- export { isUndefined as default };
@@ -1,4 +0,0 @@
1
- 'use strict';
2
-
3
- exports.MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
4
- exports.MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isString = require('./type/isString.js');
4
-
5
- function convertToString(value) {
6
- return isString(value) ? value : String(value);
7
- }
8
-
9
- module.exports = convertToString;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isType = require('./isType.js');
4
-
5
- function isBlob(value) {
6
- return isType(value, 'Blob');
7
- }
8
-
9
- module.exports = isBlob;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isType = require('./isType.js');
4
-
5
- function _isNaN(value) {
6
- return isType(value, 'Number') && isNaN(value);
7
- }
8
-
9
- module.exports = _isNaN;
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- var isUndefined = require('./isUndefined.js');
4
- var isNull = require('./isNull.js');
5
-
6
- function isNil(value) {
7
- return isUndefined(value) || isNull(value);
8
- }
9
-
10
- module.exports = isNil;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- function isNull(value) {
4
- return value === null;
5
- }
6
-
7
- module.exports = isNull;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var isType = require('./isType.js');
4
-
5
- function isNumber(value) {
6
- return isType(value, 'Number');
7
- }
8
-
9
- module.exports = isNumber;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- function isObject(value) {
4
- var type = typeof value;
5
- return value != null && (type === 'object' || type === 'function');
6
- }
7
-
8
- module.exports = isObject;