util-helpers 5.4.1 → 5.5.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 (62) hide show
  1. package/README.md +1 -0
  2. package/dist/util-helpers.js +52 -3
  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/AsyncMemo.js +1 -2
  7. package/esm/VERSION.js +2 -3
  8. package/esm/checkResult.js +27 -0
  9. package/esm/compressImage.js +1 -2
  10. package/esm/fileReader.js +1 -2
  11. package/esm/formatMoney.js +1 -2
  12. package/esm/index.js +1 -0
  13. package/esm/numberToChinese.js +2 -2
  14. package/esm/randomString.js +1 -2
  15. package/esm/safeDate.js +1 -2
  16. package/esm/transformObjectValue.js +1 -2
  17. package/lib/AsyncMemo.js +1 -2
  18. package/lib/VERSION.js +2 -3
  19. package/lib/checkResult.js +29 -0
  20. package/lib/compressImage.js +1 -2
  21. package/lib/fileReader.js +1 -2
  22. package/lib/formatMoney.js +1 -2
  23. package/lib/index.js +2 -0
  24. package/lib/numberToChinese.js +2 -2
  25. package/lib/randomString.js +1 -2
  26. package/lib/safeDate.js +1 -2
  27. package/lib/transformObjectValue.js +1 -2
  28. package/lib/utils/config.js +3 -2
  29. package/lib/utils/native.js +11 -5
  30. package/lib/utils/setup.js +3 -1
  31. package/package.json +5 -11
  32. package/types/AsyncMemo.d.ts +1 -1
  33. package/types/ajax.d.ts +2 -2
  34. package/types/calculateCursorPosition.d.ts +2 -2
  35. package/types/checkFileType.d.ts +2 -2
  36. package/types/checkResult.d.ts +34 -0
  37. package/types/compressImage.d.ts +1 -1
  38. package/types/dataURLToBlob.d.ts +1 -1
  39. package/types/download.d.ts +3 -3
  40. package/types/fileReader.d.ts +1 -1
  41. package/types/gcd.d.ts +1 -1
  42. package/types/getExtname.d.ts +1 -1
  43. package/types/getMimeType.d.ts +2 -2
  44. package/types/index.d.ts +3 -2
  45. package/types/isBankCard.d.ts +1 -1
  46. package/types/isBusinessLicense.d.ts +1 -1
  47. package/types/isChinese.d.ts +3 -3
  48. package/types/isHMCard.d.ts +1 -1
  49. package/types/isIdCard.d.ts +2 -2
  50. package/types/isPassport.d.ts +1 -1
  51. package/types/isPassword.d.ts +1 -1
  52. package/types/isSocialCreditCode.d.ts +1 -1
  53. package/types/isSwiftCode.d.ts +1 -1
  54. package/types/isTWCard.d.ts +1 -1
  55. package/types/isUrl.d.ts +1 -1
  56. package/types/isVehicle.d.ts +1 -1
  57. package/types/lcm.d.ts +1 -1
  58. package/types/numberToChinese.d.ts +1 -1
  59. package/types/parseIdCard.d.ts +1 -1
  60. package/types/safeDate.d.ts +1 -1
  61. package/types/setDataURLPrefix.d.ts +2 -2
  62. package/types/validatePassword.d.ts +1 -1
package/esm/AsyncMemo.js CHANGED
@@ -35,6 +35,5 @@ var AsyncMemo = (function () {
35
35
  };
36
36
  return AsyncMemo;
37
37
  }());
38
- var AsyncMemo$1 = AsyncMemo;
39
38
 
40
- export { AsyncMemo$1 as default };
39
+ export { AsyncMemo as default };
package/esm/VERSION.js CHANGED
@@ -1,4 +1,3 @@
1
- var VERSION = "5.4.1";
2
- var VERSION$1 = VERSION;
1
+ var VERSION = "5.5.0";
3
2
 
4
- export { VERSION$1 as default };
3
+ export { VERSION as default };
@@ -0,0 +1,27 @@
1
+ import { __awaiter, __spreadArray, __read, __generator } from 'tslib';
2
+ import { tryit } from 'ut2';
3
+
4
+ var checkResult = function () {
5
+ var args_1 = [];
6
+ for (var _i = 0; _i < arguments.length; _i++) {
7
+ args_1[_i] = arguments[_i];
8
+ }
9
+ return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (fn) {
10
+ var _a, _b, err, ret;
11
+ if (fn === void 0) { fn = function () { return true; }; }
12
+ var args = [];
13
+ for (_a = 1; _a < arguments.length; _a++) {
14
+ args[_a - 1] = arguments[_a];
15
+ }
16
+ return __generator(this, function (_c) {
17
+ switch (_c.label) {
18
+ case 0: return [4, tryit(fn).apply(void 0, __spreadArray([], __read(args), false))];
19
+ case 1:
20
+ _b = __read.apply(void 0, [_c.sent(), 2]), err = _b[0], ret = _b[1];
21
+ return [2, !err && ret !== false];
22
+ }
23
+ });
24
+ });
25
+ };
26
+
27
+ export { checkResult as default };
@@ -67,6 +67,5 @@ var compressImage = function (img, options) {
67
67
  .catch(reject);
68
68
  });
69
69
  };
70
- var compressImage$1 = compressImage;
71
70
 
72
- export { compressImage$1 as default };
71
+ export { compressImage as default };
package/esm/fileReader.js CHANGED
@@ -17,6 +17,5 @@ var fileReader = function (blob, type) {
17
17
  reader.onerror = function (error) { return reject(error); };
18
18
  });
19
19
  };
20
- var fileReader$1 = fileReader;
21
20
 
22
- export { fileReader$1 as default };
21
+ export { fileReader as default };
@@ -62,6 +62,5 @@ var formatMoney = function (num, options) {
62
62
  var _e = __read(strNum.split('.'), 2), intStr = _e[0], decStr = _e[1];
63
63
  return symbol + formatInt(intStr, thousand) + formatDec(decStr, precision, decimal);
64
64
  };
65
- var formatMoney$1 = formatMoney;
66
65
 
67
- export { formatMoney$1 as default };
66
+ export { formatMoney as default };
package/esm/index.js CHANGED
@@ -20,6 +20,7 @@ export { default as isHMCard } from './isHMCard.js';
20
20
  export { default as isTWCard } from './isTWCard.js';
21
21
  export { default as isSwiftCode } from './isSwiftCode.js';
22
22
  export { default as isValidNumber } from './isValidNumber.js';
23
+ export { default as checkResult } from './checkResult.js';
23
24
  export { default as formatMoney } from './formatMoney.js';
24
25
  export { default as formatBankCard } from './formatBankCard.js';
25
26
  export { default as replaceChar } from './replaceChar.js';
@@ -93,8 +93,8 @@ function numberToChinese(num, options) {
93
93
  unitChar = chnUnitChar.slice();
94
94
  decimal = decimal || '点';
95
95
  }
96
- var unitWan = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.w) || '万';
97
- var unitYi = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.y) || '亿';
96
+ var unitWan = unitConfig.w || '万';
97
+ var unitYi = unitConfig.y || '亿';
98
98
  var unitWanYi = unitWan + unitYi;
99
99
  unitSection = ['', unitWan, unitYi, unitWanYi];
100
100
  if (zero) {
@@ -29,6 +29,5 @@ var randomString = function (len, pool) {
29
29
  }
30
30
  return internalRandomString(toNumber(len), _pool);
31
31
  };
32
- var randomString$1 = randomString;
33
32
 
34
- export { randomString$1 as default };
33
+ export { randomString as default };
package/esm/safeDate.js CHANGED
@@ -11,6 +11,5 @@ var safeDate = function (value) {
11
11
  }
12
12
  return typeof safeValue === 'undefined' ? new Date() : new Date(safeValue);
13
13
  };
14
- var safeDate$1 = safeDate;
15
14
 
16
- export { safeDate$1 as default };
15
+ export { safeDate as default };
@@ -20,6 +20,5 @@ var transformObjectValue = function (data, fn, deep) {
20
20
  }
21
21
  return data;
22
22
  };
23
- var transformObjectValue$1 = transformObjectValue;
24
23
 
25
- export { transformObjectValue$1 as default };
24
+ export { transformObjectValue as default };
package/lib/AsyncMemo.js CHANGED
@@ -37,6 +37,5 @@ var AsyncMemo = (function () {
37
37
  };
38
38
  return AsyncMemo;
39
39
  }());
40
- var AsyncMemo$1 = AsyncMemo;
41
40
 
42
- module.exports = AsyncMemo$1;
41
+ module.exports = AsyncMemo;
package/lib/VERSION.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var VERSION = "5.4.1";
4
- var VERSION$1 = VERSION;
3
+ var VERSION = "5.5.0";
5
4
 
6
- module.exports = VERSION$1;
5
+ module.exports = VERSION;
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var ut2 = require('ut2');
5
+
6
+ var checkResult = function () {
7
+ var args_1 = [];
8
+ for (var _i = 0; _i < arguments.length; _i++) {
9
+ args_1[_i] = arguments[_i];
10
+ }
11
+ return tslib.__awaiter(void 0, tslib.__spreadArray([], tslib.__read(args_1), false), void 0, function (fn) {
12
+ var _a, _b, err, ret;
13
+ if (fn === void 0) { fn = function () { return true; }; }
14
+ var args = [];
15
+ for (_a = 1; _a < arguments.length; _a++) {
16
+ args[_a - 1] = arguments[_a];
17
+ }
18
+ return tslib.__generator(this, function (_c) {
19
+ switch (_c.label) {
20
+ case 0: return [4, ut2.tryit(fn).apply(void 0, tslib.__spreadArray([], tslib.__read(args), false))];
21
+ case 1:
22
+ _b = tslib.__read.apply(void 0, [_c.sent(), 2]), err = _b[0], ret = _b[1];
23
+ return [2, !err && ret !== false];
24
+ }
25
+ });
26
+ });
27
+ };
28
+
29
+ module.exports = checkResult;
@@ -69,6 +69,5 @@ var compressImage = function (img, options) {
69
69
  .catch(reject);
70
70
  });
71
71
  };
72
- var compressImage$1 = compressImage;
73
72
 
74
- module.exports = compressImage$1;
73
+ module.exports = compressImage;
package/lib/fileReader.js CHANGED
@@ -19,6 +19,5 @@ var fileReader = function (blob, type) {
19
19
  reader.onerror = function (error) { return reject(error); };
20
20
  });
21
21
  };
22
- var fileReader$1 = fileReader;
23
22
 
24
- module.exports = fileReader$1;
23
+ module.exports = fileReader;
@@ -64,6 +64,5 @@ var formatMoney = function (num, options) {
64
64
  var _e = tslib.__read(strNum.split('.'), 2), intStr = _e[0], decStr = _e[1];
65
65
  return symbol + formatInt(intStr, thousand) + formatDec(decStr, precision, decimal);
66
66
  };
67
- var formatMoney$1 = formatMoney;
68
67
 
69
- module.exports = formatMoney$1;
68
+ module.exports = formatMoney;
package/lib/index.js CHANGED
@@ -22,6 +22,7 @@ var isHMCard = require('./isHMCard.js');
22
22
  var isTWCard = require('./isTWCard.js');
23
23
  var isSwiftCode = require('./isSwiftCode.js');
24
24
  var isValidNumber = require('./isValidNumber.js');
25
+ var checkResult = require('./checkResult.js');
25
26
  var formatMoney = require('./formatMoney.js');
26
27
  var formatBankCard = require('./formatBankCard.js');
27
28
  var replaceChar = require('./replaceChar.js');
@@ -93,6 +94,7 @@ exports.isHMCard = isHMCard;
93
94
  exports.isTWCard = isTWCard;
94
95
  exports.isSwiftCode = isSwiftCode;
95
96
  exports.isValidNumber = isValidNumber;
97
+ exports.checkResult = checkResult;
96
98
  exports.formatMoney = formatMoney;
97
99
  exports.formatBankCard = formatBankCard;
98
100
  exports.replaceChar = replaceChar;
@@ -95,8 +95,8 @@ function numberToChinese(num, options) {
95
95
  unitChar = chnUnitChar.slice();
96
96
  decimal = decimal || '点';
97
97
  }
98
- var unitWan = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.w) || '万';
99
- var unitYi = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.y) || '亿';
98
+ var unitWan = unitConfig.w || '万';
99
+ var unitYi = unitConfig.y || '亿';
100
100
  var unitWanYi = unitWan + unitYi;
101
101
  unitSection = ['', unitWan, unitYi, unitWanYi];
102
102
  if (zero) {
@@ -31,6 +31,5 @@ var randomString = function (len, pool) {
31
31
  }
32
32
  return internalRandomString(ut2.toNumber(len), _pool);
33
33
  };
34
- var randomString$1 = randomString;
35
34
 
36
- module.exports = randomString$1;
35
+ module.exports = randomString;
package/lib/safeDate.js CHANGED
@@ -13,6 +13,5 @@ var safeDate = function (value) {
13
13
  }
14
14
  return typeof safeValue === 'undefined' ? new Date() : new Date(safeValue);
15
15
  };
16
- var safeDate$1 = safeDate;
17
16
 
18
- module.exports = safeDate$1;
17
+ module.exports = safeDate;
@@ -22,6 +22,5 @@ var transformObjectValue = function (data, fn, deep) {
22
22
  }
23
23
  return data;
24
24
  };
25
- var transformObjectValue$1 = transformObjectValue;
26
25
 
27
- module.exports = transformObjectValue$1;
26
+ module.exports = transformObjectValue;
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- exports.config = {
3
+ var config = {
4
4
  disableWarning: true
5
5
  };
6
6
  function setDisableWarning(bool) {
7
- exports.config.disableWarning = !!bool;
7
+ config.disableWarning = !!bool;
8
8
  }
9
9
 
10
+ exports.config = config;
10
11
  exports.setDisableWarning = setDisableWarning;
@@ -3,8 +3,14 @@
3
3
  var ut2 = require('ut2');
4
4
  var setup = require('./setup.js');
5
5
 
6
- exports.nativeUndefined = void 0;
7
- exports.objectKeys = Object.keys;
8
- exports.objectValues = Object.values;
9
- exports.createObjectURL = setup.URLExisted ? URL.createObjectURL : ut2.constant('');
10
- exports.revokeObjectURL = setup.URLExisted ? URL.revokeObjectURL : ut2.noop;
6
+ var nativeUndefined = void 0;
7
+ var objectKeys = Object.keys;
8
+ var objectValues = Object.values;
9
+ var createObjectURL = setup.URLExisted ? URL.createObjectURL : ut2.constant('');
10
+ var revokeObjectURL = setup.URLExisted ? URL.revokeObjectURL : ut2.noop;
11
+
12
+ exports.createObjectURL = createObjectURL;
13
+ exports.nativeUndefined = nativeUndefined;
14
+ exports.objectKeys = objectKeys;
15
+ exports.objectValues = objectValues;
16
+ exports.revokeObjectURL = revokeObjectURL;
@@ -1,3 +1,5 @@
1
1
  'use strict';
2
2
 
3
- exports.URLExisted = typeof URL !== 'undefined';
3
+ var URLExisted = typeof URL !== 'undefined';
4
+
5
+ exports.URLExisted = URLExisted;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "5.4.1",
3
+ "version": "5.5.0",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -11,9 +11,7 @@
11
11
  "test": "jest --verbose",
12
12
  "test:coverage": "jest --coverage",
13
13
  "test:coverage:local": "cross-env COVERAGE_LOCAL=1 jest --coverage && open ./coverage/lcov-report/index.html",
14
- "build": "npm run build:module && npm run build:dist && npm run build:types",
15
- "build:module": "rm -rf esm && rm -rf lib && rollup -c rollup.module.config.mjs",
16
- "build:dist": "rm -rf dist && rollup -c rollup.umd.config.mjs",
14
+ "build": "rm -rf esm lib dist && rollup -c && npm run build:types",
17
15
  "build:types": "rm -rf types && tsc -p tsconfig.build.json -d --outDir types --emitDeclarationOnly",
18
16
  "build:doc": "npm run doc",
19
17
  "doc": "rm -rf docs && rm -rf docs-src && tsc -p tsconfig.build.json -t esnext --outDir docs-src && jsdoc -c conf.json && rm -rf docs-src",
@@ -51,22 +49,17 @@
51
49
  },
52
50
  "homepage": "https://doly-dev.github.io/util-helpers/index.html",
53
51
  "devDependencies": {
54
- "@babel/core": "^7.26.0",
55
- "@babel/preset-env": "^7.26.0",
56
- "@babel/preset-typescript": "^7.26.0",
57
52
  "@commitlint/cli": "^17.8.1",
58
53
  "@commitlint/config-conventional": "^17.8.1",
59
54
  "@commitlint/cz-commitlint": "^17.8.1",
60
55
  "@rollup/plugin-commonjs": "^25.0.8",
61
- "@rollup/plugin-node-resolve": "^15.3.0",
56
+ "@rollup/plugin-node-resolve": "^15.3.1",
62
57
  "@rollup/plugin-replace": "^5.0.7",
63
58
  "@rollup/plugin-terser": "^0.4.4",
64
59
  "@rollup/plugin-typescript": "^11.1.6",
65
60
  "@types/jest": "^29.5.14",
66
61
  "@typescript-eslint/eslint-plugin": "^7.18.0",
67
62
  "@typescript-eslint/parser": "^7.18.0",
68
- "babel-jest": "^29.7.0",
69
- "babel-plugin-minify-replace": "^0.5.0",
70
63
  "commitizen": "^4.3.1",
71
64
  "cross-env": "^7.0.3",
72
65
  "docdash": "^2.0.2",
@@ -79,7 +72,8 @@
79
72
  "jsdoc": "^4.0.4",
80
73
  "lint-staged": "^13.3.0",
81
74
  "prettier": "^3.4.2",
82
- "rollup": "^4.28.0",
75
+ "rollup": "^4.28.1",
76
+ "ts-jest": "^29.2.5",
83
77
  "typescript": "^5.7.2"
84
78
  },
85
79
  "lint-staged": {
@@ -8,7 +8,7 @@ import { Cache, CacheOptions } from 'cache2';
8
8
  * 3. 每个实例都有独立的缓存空间。相互之间隔离,缓存灵活配置,更多配置请查阅 [`cache2`](https://www.npmjs.com/package/cache2)。
9
9
  *
10
10
  * @class
11
- * @see {@link https://www.npmjs.com/package/cache2 | cache2}
11
+ * @see {@link https://www.npmjs.com/package/cache2 cache2}
12
12
  * @param {Object} [options] 缓存配置项,更多配置项可参考 [`cache2`](https://www.npmjs.com/package/cache2)
13
13
  * @param {number} [options.max] 最大缓存数量
14
14
  * @param {'replaced' | 'limited'} [options.maxStrategy] 缓存策略
package/types/ajax.d.ts CHANGED
@@ -19,7 +19,7 @@ type AjaxOptions = {
19
19
  onLoadEnd?: XMLHttpRequestListener;
20
20
  };
21
21
  /**
22
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest | XMLHttpRequest}
22
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest XMLHttpRequest}
23
23
  * @typedef {Object} AjaxOptions ajax 配置项
24
24
  * @property {string} [method="get"] 创建请求时使用的方法
25
25
  * @property {boolean} [async=true] 是否异步执行操作
@@ -46,7 +46,7 @@ type AjaxOptions = {
46
46
  *
47
47
  * @alias module:Browser.ajax
48
48
  * @since 4.16.0
49
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest | XMLHttpRequest}
49
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest XMLHttpRequest}
50
50
  * @param {string} url 地址
51
51
  * @param {AjaxOptions} [options] 配置项
52
52
  * @param {string} [options.method="get"] 创建请求时使用的方法。默认 `'get'`。
@@ -8,8 +8,8 @@ type CalculateCursorPositionOptions = {
8
8
  *
9
9
  * @alias module:Other.calculateCursorPosition
10
10
  * @since 4.6.0
11
- * @see {@link https://2950v9.csb.app/ | h5示例}
12
- * @see {@link https://33ccy9.csb.app/ | react示例}
11
+ * @see {@link https://2950v9.csb.app/ h5示例}
12
+ * @see {@link https://33ccy9.csb.app/ react示例}
13
13
  * @param {number} prevPos 赋值前的光标位置,onChange/onInput的光标位置 e.target.selectionEnd
14
14
  * @param {string} prevCtrlValue 上一个格式化后的值
15
15
  * @param {string} rawValue 当前输入原值
@@ -6,8 +6,8 @@ import { UploadFile } from './utils/file.util';
6
6
  *
7
7
  * @alias module:Browser.checkFileType
8
8
  * @since 5.1.0
9
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/file#唯一文件类型说明符 | 唯一文件类型说明符}
10
- * @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml | Media Types}
9
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/file#唯一文件类型说明符 唯一文件类型说明符}
10
+ * @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml Media Types}
11
11
  * @param {File} file 文件对象。支持 antd `UploadFile` 对象。
12
12
  * @param {string} [accept] 文件类型说明符。
13
13
  * @returns {boolean} 如果 `file` 符合 `accept` 返回 `true`, 否则返回 `false`。
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 检查函数执行结果。
3
+ *
4
+ * 如果函数执行异常或返回下列结果,则返回 `false` ,否则返回 `true`。
5
+ * 1. `Promise.reject()`
6
+ * 2. `Promise.resolve(false)`
7
+ * 3. `false`
8
+ *
9
+ * @alias module:Other.checkResult
10
+ * @since 5.5.0
11
+ * @param {Function} [fn=()=>true] 处理函数,默认 `()=>true`。
12
+ * @param {...*} [args] 展开参数,`fn` 执行参数。
13
+ * @returns {Promise<boolean>}
14
+ * @example
15
+ * await checkResult(()=>throw new Error()); // false
16
+ * await checkResult(()=>Promise.reject()); // false
17
+ * await checkResult(()=>Promise.resolve(false)); // false
18
+ * await checkResult(async ()=>false); // false
19
+ * await checkResult(()=>false); // false
20
+ *
21
+ * await checkResult(undefined); // true
22
+ * await checkResult(()=>true); // true
23
+ * await checkResult(()=>Promise.resolve()); // true
24
+ * await checkResult(async ()=>true); // true
25
+ * await checkResult(()=>null); // true
26
+ * await checkResult(()=>undefined); // true
27
+ * await checkResult(()=>'foo'); // true
28
+ *
29
+ * // 传入参数
30
+ * await checkResult((...args)=>args.length > 1); // false
31
+ * await checkResult((...args)=>args.length > 1, 'a', 'b'); // true
32
+ */
33
+ declare const checkResult: <P extends any[]>(fn?: (...args: P) => any | Promise<any>, ...args: P) => Promise<boolean>;
34
+ export default checkResult;
@@ -37,7 +37,7 @@ interface CompressImage {
37
37
  * @function
38
38
  * @alias module:Browser.compressImage
39
39
  * @since 4.20.0
40
- * @see {@link https://sytpwg.csb.app/ | 在线示例}
40
+ * @see {@link https://sytpwg.csb.app/ 在线示例}
41
41
  * @param {string | Blob} img 图片地址或 blob 对象
42
42
  * @param {Object} [options] 配置项
43
43
  * @param {number} [options.width] 自定义图片宽度,默认图片自身宽度
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @alias module:Browser.dataURLToBlob
5
5
  * @since 4.1.0
6
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Glossary/Base64 | Base64}
6
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Glossary/Base64 Base64}
7
7
  * @param {string} data data: 协议的URL
8
8
  * @returns {Blob} Blob 对象
9
9
  * @example
@@ -21,9 +21,9 @@ type DownloadOptions = {
21
21
  *
22
22
  * @alias module:Browser.download
23
23
  * @since 4.16.0
24
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers | Access-Control-Expose-Headers}
25
- * @see {@link https://zh.wikipedia.org/wiki/多用途互聯網郵件擴展 | MIME}
26
- * @see {@link https://9ykc9s.csb.app/ | 在线示例}
24
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers Access-Control-Expose-Headers}
25
+ * @see {@link https://zh.wikipedia.org/wiki/多用途互聯網郵件擴展 MIME}
26
+ * @see {@link https://9ykc9s.csb.app/ 在线示例}
27
27
  * @param {string|Blob|ArrayBuffer|TypedArray} data 字符串、blob数据或url地址
28
28
  * @param {string|Object} [options] 文件名称 或 配置项。
29
29
  * @param {string} [options.fileName] 文件名称。
@@ -16,7 +16,7 @@ interface FileReader {
16
16
  *
17
17
  * @function
18
18
  * @alias module:Browser.fileReader
19
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader | FileReader}
19
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader FileReader}
20
20
  * @since 4.16.0
21
21
  * @param {Blob} blob Blob 或 File 对象
22
22
  * @param {'arrayBuffer'|'binaryString'|'dataURL'|'text'} [type='dataURL'] 读取类型,默认`dataURL`。可选 `arrayBuffer` `binaryString` `dataURL` `text` 。
package/types/gcd.d.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @alias module:Math.gcd
13
13
  * @since 4.20.0
14
- * @see {@link https://baike.baidu.com/item/最大公约数 | 最大公约数}
14
+ * @see {@link https://baike.baidu.com/item/最大公约数 最大公约数}
15
15
  * @param {...(number|string)} nums 两个或多个整数。
16
16
  * @returns {number} 最大公约数。
17
17
  * @example
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @alias module:Other.getExtname
5
5
  * @since 5.4.0
6
- * @see {@link https://nodejs.org/docs/latest/api/path.html#pathextnamepath | Node.js path.extname}
6
+ * @see {@link https://nodejs.org/docs/latest/api/path.html#pathextnamepath Node.js path.extname}
7
7
  * @param {string} path 路径。
8
8
  * @returns 返回从最后一次出现 `.` 字符到路径最后一部分的字符串结尾。如果路径没有 `.` 或者除了第一个字符之外没有其他 `.` 字符,则返回空字符串。
9
9
  * @example
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * @alias module:Browser.getMimeType
5
5
  * @since 5.2.0
6
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/MIME_types | MIME 类型(IANA 媒体类型)}
7
- * @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml | Media Types}
6
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/MIME_types MIME 类型(IANA 媒体类型)}
7
+ * @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml Media Types}
8
8
  * @param {string} fileName 文件名。
9
9
  * @returns 如果找到,返回 MIME 类型字符串,否则返回 `undefined`。
10
10
  * @example
package/types/index.d.ts CHANGED
@@ -25,6 +25,7 @@ export { default as isHMCard } from './isHMCard';
25
25
  export { default as isTWCard } from './isTWCard';
26
26
  export { default as isSwiftCode } from './isSwiftCode';
27
27
  export { default as isValidNumber } from './isValidNumber';
28
+ export { default as checkResult } from './checkResult';
28
29
  /**
29
30
  * 数据处理
30
31
  *
@@ -45,8 +46,8 @@ export { default as transformObjectValue } from './transformObjectValue';
45
46
  * 数学计算,修正浮点数计算问题
46
47
  *
47
48
  * @module Math
48
- * @see {@link https://github.com/camsong/blog/issues/9 | JavaScript 浮点数陷阱及解法}
49
- * @see {@link https://2zbuy.csb.app/ | JS浮点数计算测试}
49
+ * @see {@link https://github.com/camsong/blog/issues/9 JavaScript 浮点数陷阱及解法}
50
+ * @see {@link https://2zbuy.csb.app/ JS浮点数计算测试}
50
51
  * @example
51
52
  * // 从 4.12.0 版本开始,规范了有效数值。(注意:4.12.3 对有效数值重新定义)
52
53
  * // 有效数值即能通过 Number(value) 转为数字,且不能为 NaN 。
@@ -7,7 +7,7 @@ type Options = {
7
7
  *
8
8
  * @alias module:Validator.isBankCard
9
9
  * @since 1.1.0
10
- * @see {@link https://kf.qq.com/faq/170112ABnm6b170112FvquAn.html | 常用银行账号位数参考}
10
+ * @see {@link https://kf.qq.com/faq/170112ABnm6b170112FvquAn.html 常用银行账号位数参考}
11
11
  * @param {*} value 要检测的值
12
12
  * @param {Object} [options] 配置项
13
13
  * @param {boolean} [options.loose=false] 宽松模式,默认`false`。正常模式10-21位数字(个人账户),宽松模式8-30位数字(企业账户)。
@@ -6,7 +6,7 @@ type Options = {
6
6
  *
7
7
  * @alias module:Validator.isBusinessLicense
8
8
  * @since 3.5.0
9
- * @see {@link https://wenku.baidu.com/view/19873704cc1755270722087c.html | GS15—2006 工商行政管理市场主体注册号编制规则}
9
+ * @see {@link https://wenku.baidu.com/view/19873704cc1755270722087c.html GS15—2006 工商行政管理市场主体注册号编制规则}
10
10
  * @param {*} value 要检测的值
11
11
  * @param {Object} [options] 配置项
12
12
  * @param {boolean} [options.checkCode=true] 是否校验最后一位校验码,默认`true`。如果为false,不校验校验位。
@@ -7,9 +7,9 @@ type Options = {
7
7
  *
8
8
  * @alias module:Validator.isChinese
9
9
  * @since 1.1.0
10
- * @see {@link http://www.unicode.org/reports/tr38/#BlockListing | 4.4 Listing of Characters Covered by the Unihan Database}
11
- * @see {@link https://zh.wikipedia.org/wiki/Unicode字符平面映射 | Unicode字符平面映射}
12
- * @see {@link https://zh.wikipedia.org/wiki/Unicode區段 | Unicode区段}
10
+ * @see {@link http://www.unicode.org/reports/tr38/#BlockListing 4.4 Listing of Characters Covered by the Unihan Database}
11
+ * @see {@link https://zh.wikipedia.org/wiki/Unicode字符平面映射 Unicode字符平面映射}
12
+ * @see {@link https://zh.wikipedia.org/wiki/Unicode區段 Unicode区段}
13
13
  * @param {*} value 要检测的值
14
14
  * @param {Object} [options] 配置项
15
15
  * @param {boolean} [options.loose=false] 宽松模式,默认`false`。如果为`true`,只要包含中文就返回`true`
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @alias module:Validator.isHMCard
5
5
  * @since 4.0.0
6
- * @see {@link https://zh.wikipedia.org/wiki/港澳居民来往内地通行证 | 港澳居民来往内地通行证}
6
+ * @see {@link https://zh.wikipedia.org/wiki/港澳居民来往内地通行证 港澳居民来往内地通行证}
7
7
  * @param {*} value 要检测的值
8
8
  * @returns {boolean} 是否为港澳居民来往内地通行证
9
9
  * @example
@@ -9,8 +9,8 @@ type Options = {
9
9
  *
10
10
  * @alias module:Validator.isIdCard
11
11
  * @since 1.1.0
12
- * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码 | 中华人民共和国公民身份号码}
13
- * @see {@link https://baike.baidu.com/item/居民身份证号码 | 居民身份证号码}
12
+ * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码 中华人民共和国公民身份号码}
13
+ * @see {@link https://baike.baidu.com/item/居民身份证号码 居民身份证号码}
14
14
  * @param {*} value 要检测的值
15
15
  * @param {Object} [options] 配置项
16
16
  * @param {boolean} [options.loose=false] 宽松模式,默认`false`。如果为`true`,支持15位身份证号码
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @alias module:Validator.isPassport
6
6
  * @since 1.1.0
7
- * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国护照#个人资料页 | 中华人民共和国护照#个人资料页}
7
+ * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国护照#个人资料页 中华人民共和国护照#个人资料页}
8
8
  * @param {*} value 要检测的值
9
9
  * @returns {boolean} 值是否为护照号
10
10
  * @example
@@ -7,7 +7,7 @@ import validatePassword from './validatePassword';
7
7
  * @alias module:Validator.isPassword
8
8
  * @requires module:Validator.validatePassword
9
9
  * @since 1.1.0
10
- * @see {@link https://baike.baidu.com/item/ASCII#3 | ASCII}
10
+ * @see {@link https://baike.baidu.com/item/ASCII#3 ASCII}
11
11
  * @param {*} value 要检测的值
12
12
  * @param {Object} [options] 配置项
13
13
  * @param {number} [options.level=2] 密码强度,默认`2`。`1`-包含一种字符 `2`-包含两种字符 `3`-包含三种字符。(大写字母、小写字母、数字、特殊字符)
@@ -6,7 +6,7 @@ type Options = {
6
6
  *
7
7
  * @alias module:Validator.isSocialCreditCode
8
8
  * @since 1.1.0
9
- * @see {@link https://zh.wikisource.org/zh-hans/GB_32100-2015_法人和其他组织统一社会信用代码编码规则 | GB 32100-2015 法人和其他组织统一社会信用代码编码规则}
9
+ * @see {@link https://zh.wikisource.org/zh-hans/GB_32100-2015_法人和其他组织统一社会信用代码编码规则 GB 32100-2015 法人和其他组织统一社会信用代码编码规则}
10
10
  * @param {*} value 要检测的值
11
11
  * @param {Object} [options] 配置项
12
12
  * @param {boolean} [options.checkCode=true] 是否校验最后一位校验码,如果为false,不校验校验位。