util-helpers 4.23.0 → 5.0.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 (72) hide show
  1. package/dist/util-helpers.js +159 -322
  2. package/dist/util-helpers.js.map +1 -1
  3. package/dist/util-helpers.min.js +1 -1
  4. package/dist/util-helpers.min.js.map +1 -1
  5. package/esm/VERSION.js +1 -1
  6. package/esm/compressImage.js +2 -2
  7. package/esm/formatBankCard.js +3 -5
  8. package/esm/formatMobile.js +4 -6
  9. package/esm/getImageInfo.js +14 -47
  10. package/esm/index.js +0 -8
  11. package/esm/isBusinessLicense.js +1 -2
  12. package/esm/isSocialCreditCode.js +1 -3
  13. package/esm/loadImage.js +17 -44
  14. package/esm/loadImageWithBlob.js +17 -45
  15. package/lib/VERSION.js +1 -1
  16. package/lib/compressImage.js +2 -2
  17. package/lib/formatBankCard.js +3 -5
  18. package/lib/formatMobile.js +4 -6
  19. package/lib/getImageInfo.js +14 -47
  20. package/lib/index.js +1 -9
  21. package/lib/isBusinessLicense.js +1 -2
  22. package/lib/isSocialCreditCode.js +1 -3
  23. package/lib/loadImage.js +16 -43
  24. package/lib/loadImageWithBlob.js +16 -44
  25. package/package.json +11 -11
  26. package/types/AsyncMemo.d.ts +2 -2
  27. package/types/ajax.d.ts +2 -2
  28. package/types/calculateCursorPosition.d.ts +2 -2
  29. package/types/compressImage.d.ts +3 -5
  30. package/types/dataURLToBlob.d.ts +1 -1
  31. package/types/download.d.ts +3 -3
  32. package/types/fileReader.d.ts +1 -1
  33. package/types/formatBankCard.d.ts +1 -3
  34. package/types/formatMobile.d.ts +0 -2
  35. package/types/gcd.d.ts +1 -1
  36. package/types/getImageInfo.d.ts +1 -2
  37. package/types/index.d.ts +2 -10
  38. package/types/isBankCard.d.ts +1 -1
  39. package/types/isBusinessLicense.d.ts +1 -3
  40. package/types/isChinese.d.ts +3 -3
  41. package/types/isHMCard.d.ts +1 -1
  42. package/types/isIdCard.d.ts +2 -2
  43. package/types/isPassport.d.ts +1 -1
  44. package/types/isPassword.d.ts +1 -1
  45. package/types/isSocialCreditCode.d.ts +1 -3
  46. package/types/isSwiftCode.d.ts +1 -1
  47. package/types/isTWCard.d.ts +1 -1
  48. package/types/isUrl.d.ts +1 -1
  49. package/types/isVehicle.d.ts +1 -1
  50. package/types/lcm.d.ts +1 -1
  51. package/types/loadImage.d.ts +1 -10
  52. package/types/loadImageWithBlob.d.ts +3 -5
  53. package/types/numberToChinese.d.ts +1 -1
  54. package/types/parseIdCard.d.ts +1 -1
  55. package/types/safeDate.d.ts +1 -1
  56. package/types/setDataURLPrefix.d.ts +2 -2
  57. package/types/validatePassword.d.ts +1 -1
  58. package/esm/blobToDataURL.js +0 -7
  59. package/esm/isPromiseLike.js +0 -7
  60. package/esm/normalizeString.js +0 -7
  61. package/esm/utils/Cache.js +0 -47
  62. package/esm/waitTime.js +0 -8
  63. package/lib/blobToDataURL.js +0 -9
  64. package/lib/isPromiseLike.js +0 -9
  65. package/lib/normalizeString.js +0 -9
  66. package/lib/utils/Cache.js +0 -49
  67. package/lib/waitTime.js +0 -10
  68. package/types/blobToDataURL.d.ts +0 -29
  69. package/types/isPromiseLike.d.ts +0 -19
  70. package/types/normalizeString.d.ts +0 -26
  71. package/types/utils/Cache.d.ts +0 -14
  72. package/types/waitTime.d.ts +0 -24
@@ -2,52 +2,24 @@
2
2
 
3
3
  var native = require('./utils/native.js');
4
4
  var getFileBlob = require('./getFileBlob.js');
5
- var Cache = require('./utils/Cache.js');
6
5
 
7
- var cache = new Cache({ max: 1 });
8
- cache.on('del', function (v) {
9
- if (v.r) {
10
- try {
11
- native.revokeObjectURL(v.data.image.src);
12
- }
13
- catch (_a) {
14
- }
15
- }
16
- });
17
- function loadImageWithBlob(img, cacheOptions, ajaxOptions) {
18
- if (cacheOptions === void 0) { cacheOptions = true; }
19
- var _cacheOptions = {
20
- useCache: typeof cacheOptions === 'object' ? cacheOptions.useCache !== false : cacheOptions !== false,
21
- autoRevokeOnDel: typeof cacheOptions === 'object' ? cacheOptions.autoRevokeOnDel !== false : !!cacheOptions
22
- };
6
+ function loadImageWithBlob(img, ajaxOptions) {
23
7
  return new Promise(function (resolve, reject) {
24
- if (_cacheOptions.useCache && cache.has(img)) {
25
- resolve(cache.get(img).data);
26
- }
27
- else {
28
- getFileBlob(img, ajaxOptions)
29
- .then(function (blob) {
30
- var url = native.createObjectURL(blob);
31
- var image = new Image();
32
- image.onload = function () {
33
- var result = { blob: blob, image: image };
34
- if (_cacheOptions.useCache) {
35
- cache.set(img, {
36
- data: result,
37
- r: _cacheOptions.autoRevokeOnDel
38
- });
39
- }
40
- resolve(result);
41
- };
42
- image.onerror = function (err) {
43
- native.revokeObjectURL(url);
44
- console.error("[loadImageWithBlob] The image load failed, '".concat(img, "'."));
45
- reject(err);
46
- };
47
- image.src = url;
48
- })
49
- .catch(reject);
50
- }
8
+ getFileBlob(img, ajaxOptions)
9
+ .then(function (blob) {
10
+ var url = native.createObjectURL(blob);
11
+ var image = new Image();
12
+ image.onload = function () {
13
+ resolve({ blob: blob, image: image });
14
+ };
15
+ image.onerror = function (err) {
16
+ native.revokeObjectURL(url);
17
+ console.error("[loadImageWithBlob] The image load failed, '".concat(img, "'."));
18
+ reject(err);
19
+ };
20
+ image.src = url;
21
+ })
22
+ .catch(reject);
51
23
  });
52
24
  }
53
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "4.23.0",
3
+ "version": "5.0.0",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -51,20 +51,20 @@
51
51
  },
52
52
  "homepage": "https://doly-dev.github.io/util-helpers/index.html",
53
53
  "devDependencies": {
54
- "@babel/core": "^7.24.5",
55
- "@babel/preset-env": "^7.24.5",
56
- "@babel/preset-typescript": "^7.24.1",
54
+ "@babel/core": "^7.24.7",
55
+ "@babel/preset-env": "^7.24.7",
56
+ "@babel/preset-typescript": "^7.24.7",
57
57
  "@commitlint/cli": "^17.8.1",
58
58
  "@commitlint/config-conventional": "^17.8.1",
59
59
  "@commitlint/cz-commitlint": "^17.8.1",
60
- "@rollup/plugin-commonjs": "^25.0.7",
60
+ "@rollup/plugin-commonjs": "^25.0.8",
61
61
  "@rollup/plugin-node-resolve": "^15.2.3",
62
- "@rollup/plugin-replace": "^5.0.5",
62
+ "@rollup/plugin-replace": "^5.0.7",
63
63
  "@rollup/plugin-terser": "^0.4.4",
64
64
  "@rollup/plugin-typescript": "^11.1.6",
65
65
  "@types/jest": "^29.5.12",
66
- "@typescript-eslint/eslint-plugin": "^7.9.0",
67
- "@typescript-eslint/parser": "^7.9.0",
66
+ "@typescript-eslint/eslint-plugin": "^7.13.0",
67
+ "@typescript-eslint/parser": "^7.13.0",
68
68
  "babel-jest": "^29.7.0",
69
69
  "babel-plugin-minify-replace": "^0.5.0",
70
70
  "commitizen": "^4.3.0",
@@ -78,8 +78,8 @@
78
78
  "jest-environment-jsdom": "^29.7.0",
79
79
  "jsdoc": "^4.0.3",
80
80
  "lint-staged": "^13.3.0",
81
- "prettier": "^3.2.5",
82
- "rollup": "^4.17.2",
81
+ "prettier": "^3.3.2",
82
+ "rollup": "^4.18.0",
83
83
  "typescript": "^5.4.5"
84
84
  },
85
85
  "lint-staged": {
@@ -94,7 +94,7 @@
94
94
  "dependencies": {
95
95
  "cache2": "^2.0.5",
96
96
  "emitter-pro": "^1.2.1",
97
- "tslib": "^2.6.2",
97
+ "tslib": "^2.6.3",
98
98
  "ut2": "^1.9.1"
99
99
  },
100
100
  "publishConfig": {
@@ -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] 缓存策略
@@ -42,6 +42,6 @@ declare class AsyncMemo<DataType = any> {
42
42
  run(asyncFn: (...args: any[]) => Promise<DataType>, key?: string, options?: {
43
43
  ttl?: number;
44
44
  persisted?: boolean;
45
- }): Promise<any>;
45
+ }): Promise<DataType>;
46
46
  }
47
47
  export default AsyncMemo;
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] 是否异步执行操作
@@ -47,7 +47,7 @@ type AjaxOptions = {
47
47
  * @static
48
48
  * @alias module:Other.ajax
49
49
  * @since 4.16.0
50
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest | XMLHttpRequest}
50
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest XMLHttpRequest}
51
51
  * @param {string} url 地址
52
52
  * @param {AjaxOptions} [options] 配置项
53
53
  * @returns {Promise<object>} XHR 事件对象
@@ -9,8 +9,8 @@ type CalculateCursorPositionOptions = {
9
9
  * @static
10
10
  * @alias module:Other.calculateCursorPosition
11
11
  * @since 4.6.0
12
- * @see {@link https://2950v9.csb.app/ | h5示例}
13
- * @see {@link https://33ccy9.csb.app/ | react示例}
12
+ * @see {@link https://2950v9.csb.app/ h5示例}
13
+ * @see {@link https://33ccy9.csb.app/ react示例}
14
14
  * @param {number} prevPos 赋值前的光标位置,onChange/onInput的光标位置 e.target.selectionEnd
15
15
  * @param {string} prevCtrlValue 上一个格式化后的值
16
16
  * @param {string} rawValue 当前输入原值
@@ -19,8 +19,7 @@ type Options = {
19
19
  beforeCompress?: (imageWithBlob: Pick<Info, 'image' | 'blob'>, options: Options) => void;
20
20
  beforeDraw?: (info: Info, options: Options) => void;
21
21
  afterDraw?: (info: Info, options: Options) => void;
22
- cacheImage?: boolean | Parameters<typeof loadImageWithBlob>[1];
23
- ajaxOptions?: Parameters<typeof loadImageWithBlob>[2];
22
+ ajaxOptions?: Parameters<typeof loadImageWithBlob>[1];
24
23
  };
25
24
  interface CompressImage {
26
25
  (img: string | Blob, options: Omit<Options, 'format'> & {
@@ -38,7 +37,7 @@ interface CompressImage {
38
37
  * @function
39
38
  * @alias module:Other.compressImage
40
39
  * @since 4.20.0
41
- * @see {@link https://sytpwg.csb.app/ | 在线示例}
40
+ * @see {@link https://sytpwg.csb.app/ 在线示例}
42
41
  * @param {string | Blob} img 图片地址或 blob 对象
43
42
  * @param {Object} [options] 配置项
44
43
  * @param {number} [options.width] 自定义图片宽度,默认图片自身宽度
@@ -54,8 +53,7 @@ interface CompressImage {
54
53
  * @param {function} [options.beforeCompress] 图片加载完成,画布创建之前调用
55
54
  * @param {function} [options.beforeDraw] 图片载入画布之前调用
56
55
  * @param {function} [options.afterDraw] 图片载入画布之后调用
57
- * @param {boolean | CacheOptions} [options.cacheImage=true] 是否使用 `loadImageWithBlob` 缓存。
58
- * @param {AjaxOptions} [options.ajaxOptions] ajax 请求配置项,当传入的图片为字符串时才会触发请求。
56
+ * @param {AjaxOptions} [options.ajaxOptions] ajax 请求配置项,当传入图片地址时才会触发ajax请求。
59
57
  * @returns {Promise<Blob | string>} blob 对象 或 data url 图片
60
58
  * @example
61
59
  *
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Processor.dataURLToBlob
6
6
  * @since 4.1.0
7
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Glossary/Base64 | Base64}
7
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Glossary/Base64 Base64}
8
8
  * @param {string} data data: 协议的URL
9
9
  * @returns {Blob} Blob 对象
10
10
  * @example
@@ -38,9 +38,9 @@ type DownloadOptions = {
38
38
  * @static
39
39
  * @alias module:Other.download
40
40
  * @since 4.16.0
41
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers | Access-Control-Expose-Headers}
42
- * @see {@link https://zh.wikipedia.org/wiki/多用途互聯網郵件擴展 | MIME}
43
- * @see {@link https://9ykc9s.csb.app/ | 在线示例}
41
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers Access-Control-Expose-Headers}
42
+ * @see {@link https://zh.wikipedia.org/wiki/多用途互聯網郵件擴展 MIME}
43
+ * @see {@link https://9ykc9s.csb.app/ 在线示例}
44
44
  * @param {string|Blob|ArrayBuffer|TypedArray} data 字符串、blob数据或url地址
45
45
  * @param {string|DownloadOptions} [options] 文件名称 或 配置项
46
46
  * @returns {Promise<void>}
@@ -16,7 +16,7 @@ interface FileReader {
16
16
  *
17
17
  * @function
18
18
  * @alias module:Processor.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'] 读取类型
@@ -1,6 +1,4 @@
1
1
  type Options = {
2
- /** @deprecated */
3
- char?: string;
4
2
  spaceMark?: string;
5
3
  length?: number;
6
4
  };
@@ -26,7 +24,7 @@ type Options = {
26
24
  * // 脱敏银行卡
27
25
  * formatBankCard('6228********890'); // 6228 **** **** 890
28
26
  *
29
- * // 16位银行卡,"-"间隔
27
+ * // 自定义间隔符
30
28
  * formatBankCard('6228480402564890', {spaceMark: '-'}); // 6228-4804-0256-4890
31
29
  *
32
30
  */
@@ -1,6 +1,4 @@
1
1
  type Options = {
2
- /** @deprecated */
3
- char?: string;
4
2
  spaceMark?: string;
5
3
  };
6
4
  /**
package/types/gcd.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * @static
13
13
  * @alias module:Math.gcd
14
14
  * @since 4.20.0
15
- * @see {@link https://baike.baidu.com/item/最大公约数 | 最大公约数}
15
+ * @see {@link https://baike.baidu.com/item/最大公约数 最大公约数}
16
16
  * @param {...(number|string)} nums 两个或多个整数。
17
17
  * @returns {number} 最大公约数。
18
18
  * @example
@@ -19,7 +19,6 @@ import loadImageWithBlob from './loadImageWithBlob';
19
19
  * @alias module:Other.getImageInfo
20
20
  * @since 4.20.0
21
21
  * @param {string | Blob} img 图片地址或 blob 对象
22
- * @param {boolean | CacheOptions} [cacheOptions=true] 是否使用缓存。开启后,自动缓存最近上一次成功的结果,当图片地址或 blob 对象一致时,直接返回该缓存。避免连续请求同一个图片资源,重复加载。当缓存下一次成功加载的图片时,会自动释放上一次缓存的图片,也可以通过 `autoRevokeOnDel` 设置不释放缓存。
23
22
  * @param {AjaxOptions} [ajaxOptions] ajax 请求配置项,当传入的图片为字符串时才会触发请求。
24
23
  * @returns {Promise<ImageInfo>} 图片信息
25
24
  * @example
@@ -37,7 +36,7 @@ import loadImageWithBlob from './loadImageWithBlob';
37
36
  * });
38
37
  *
39
38
  */
40
- declare function getImageInfo(img: string | Blob, cacheOptions?: boolean | Parameters<typeof loadImageWithBlob>[1], ajaxOptions?: Parameters<typeof loadImageWithBlob>[2]): Promise<{
39
+ declare function getImageInfo(img: string | Blob, ajaxOptions?: Parameters<typeof loadImageWithBlob>[1]): Promise<{
41
40
  width: number;
42
41
  height: number;
43
42
  contrast: string;
package/types/index.d.ts CHANGED
@@ -22,7 +22,6 @@ export { default as isIPv6 } from './isIPv6';
22
22
  export { default as isUrl } from './isUrl';
23
23
  export { default as isBusinessLicense } from './isBusinessLicense';
24
24
  export { default as validatePassword } from './validatePassword';
25
- export { default as isPromiseLike } from './isPromiseLike';
26
25
  export { default as isHMCard } from './isHMCard';
27
26
  export { default as isTWCard } from './isTWCard';
28
27
  export { default as isSwiftCode } from './isSwiftCode';
@@ -39,11 +38,9 @@ export { default as replaceChar } from './replaceChar';
39
38
  export { default as numberToChinese } from './numberToChinese';
40
39
  export { default as bytesToSize } from './bytesToSize';
41
40
  export { default as parseIdCard } from './parseIdCard';
42
- export { default as blobToDataURL } from './blobToDataURL';
43
41
  export { default as fileReader } from './fileReader';
44
42
  export { default as dataURLToBlob } from './dataURLToBlob';
45
43
  export { default as setDataURLPrefix } from './setDataURLPrefix';
46
- export { default as normalizeString } from './normalizeString';
47
44
  export { default as safeDate } from './safeDate';
48
45
  export { default as formatMobile } from './formatMobile';
49
46
  export { default as padZero } from './padZero';
@@ -53,8 +50,8 @@ export { default as transformObjectValue } from './transformObjectValue';
53
50
  *
54
51
  * @module Math
55
52
  * @since 3.1.0
56
- * @see {@link https://github.com/camsong/blog/issues/9 | JavaScript 浮点数陷阱及解法}
57
- * @see {@link https://2zbuy.csb.app/ | JS浮点数计算测试}
53
+ * @see {@link https://github.com/camsong/blog/issues/9 JavaScript 浮点数陷阱及解法}
54
+ * @see {@link https://2zbuy.csb.app/ JS浮点数计算测试}
58
55
  * @example
59
56
  * // 从 4.12.0 版本开始,规范了有效数值。(注意:4.12.3 对有效数值重新定义)
60
57
  * // 有效数值即能通过 Number(value) 转为数字,且不能为 NaN 。
@@ -111,7 +108,6 @@ export { default as loadImageWithBlob } from './loadImageWithBlob';
111
108
  export { default as loadScript } from './loadScript';
112
109
  export { default as randomString } from './randomString';
113
110
  export { default as strlen } from './strlen';
114
- export { default as waitTime } from './waitTime';
115
111
  /**
116
112
  * 树结构数据查询、过滤、转换等处理方法
117
113
  *
@@ -135,8 +131,4 @@ export { default as findTreeSelect } from './findTreeSelect';
135
131
  export { setDisableWarning } from './utils/config';
136
132
  import VERSION from './VERSION';
137
133
  export { VERSION };
138
- /**
139
- * @deprecated 即将废弃,请使用 `VERSION`
140
- */
141
- export declare const version: string;
142
134
  export { default as AsyncMemo } from './AsyncMemo';
@@ -8,7 +8,7 @@ type Options = {
8
8
  * @static
9
9
  * @alias module:Validator.isBankCard
10
10
  * @since 1.1.0
11
- * @see {@link https://kf.qq.com/faq/170112ABnm6b170112FvquAn.html | 常用银行账号位数参考}
11
+ * @see {@link https://kf.qq.com/faq/170112ABnm6b170112FvquAn.html 常用银行账号位数参考}
12
12
  * @param {*} value 要检测的值
13
13
  * @param {Object} [options] 配置项
14
14
  * @param {boolean} [options.loose=false] 宽松模式,8-30位数字
@@ -1,6 +1,4 @@
1
1
  type Options = {
2
- /** @deprecated */
3
- loose?: boolean;
4
2
  checkCode?: boolean;
5
3
  };
6
4
  /**
@@ -9,7 +7,7 @@ type Options = {
9
7
  * @static
10
8
  * @alias module:Validator.isBusinessLicense
11
9
  * @since 3.5.0
12
- * @see {@link https://wenku.baidu.com/view/19873704cc1755270722087c.html | GS15—2006 工商行政管理市场主体注册号编制规则}
10
+ * @see {@link https://wenku.baidu.com/view/19873704cc1755270722087c.html GS15—2006 工商行政管理市场主体注册号编制规则}
13
11
  * @param {*} value 要检测的值
14
12
  * @param {Object} [options] 配置项
15
13
  * @param {boolean} [options.checkCode=true] 是否校验最后一位校验码,如果为false,不校验校验位。
@@ -8,9 +8,9 @@ type Options = {
8
8
  * @static
9
9
  * @alias module:Validator.isChinese
10
10
  * @since 1.1.0
11
- * @see {@link http://www.unicode.org/reports/tr38/#BlockListing | 4.4 Listing of Characters Covered by the Unihan Database}
12
- * @see {@link https://zh.wikipedia.org/wiki/Unicode字符平面映射 | Unicode字符平面映射}
13
- * @see {@link https://zh.wikipedia.org/wiki/Unicode區段 | Unicode区段}
11
+ * @see {@link http://www.unicode.org/reports/tr38/#BlockListing 4.4 Listing of Characters Covered by the Unihan Database}
12
+ * @see {@link https://zh.wikipedia.org/wiki/Unicode字符平面映射 Unicode字符平面映射}
13
+ * @see {@link https://zh.wikipedia.org/wiki/Unicode區段 Unicode区段}
14
14
  * @param {*} value 要检测的值
15
15
  * @param {Object} [options] 配置项
16
16
  * @param {boolean} [options.loose=false] 宽松模式。如果为true,只要包含中文即为true
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Validator.isHMCard
6
6
  * @since 4.0.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
@@ -10,8 +10,8 @@ type Options = {
10
10
  * @static
11
11
  * @alias module:Validator.isIdCard
12
12
  * @since 1.1.0
13
- * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码 | 中华人民共和国公民身份号码}
14
- * @see {@link https://baike.baidu.com/item/居民身份证号码 | 居民身份证号码}
13
+ * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码 中华人民共和国公民身份号码}
14
+ * @see {@link https://baike.baidu.com/item/居民身份证号码 居民身份证号码}
15
15
  * @param {*} value 要检测的值
16
16
  * @param {Object} [options] 配置项
17
17
  * @param {boolean} [options.loose=false] 宽松模式,支持15位身份证号码
@@ -5,7 +5,7 @@
5
5
  * @static
6
6
  * @alias module:Validator.isPassport
7
7
  * @since 1.1.0
8
- * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国护照#个人资料页 | 中华人民共和国护照#个人资料页}
8
+ * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国护照#个人资料页 中华人民共和国护照#个人资料页}
9
9
  * @param {*} value 要检测的值
10
10
  * @returns {boolean} 值是否为护照号
11
11
  * @example
@@ -8,7 +8,7 @@ import validatePassword from './validatePassword';
8
8
  * @alias module:Validator.isPassword
9
9
  * @requires module:Validator.validatePassword
10
10
  * @since 1.1.0
11
- * @see {@link https://baike.baidu.com/item/ASCII#3 | ASCII}
11
+ * @see {@link https://baike.baidu.com/item/ASCII#3 ASCII}
12
12
  * @param {*} value 要检测的值
13
13
  * @param {Object} [options] 配置项
14
14
  * @param {number} [options.level=2] 密码强度 1-包含一种字符 2-包含两种字符 3-包含三种字符。(大写字母、小写字母、数字、特殊字符)
@@ -1,6 +1,4 @@
1
1
  type Options = {
2
- /** @deprecated */
3
- loose?: boolean;
4
2
  checkCode?: boolean;
5
3
  };
6
4
  /**
@@ -9,7 +7,7 @@ type Options = {
9
7
  * @static
10
8
  * @alias module:Validator.isSocialCreditCode
11
9
  * @since 1.1.0
12
- * @see {@link https://zh.wikisource.org/zh-hans/GB_32100-2015_法人和其他组织统一社会信用代码编码规则 | GB 32100-2015 法人和其他组织统一社会信用代码编码规则}
10
+ * @see {@link https://zh.wikisource.org/zh-hans/GB_32100-2015_法人和其他组织统一社会信用代码编码规则 GB 32100-2015 法人和其他组织统一社会信用代码编码规则}
13
11
  * @param {*} value 要检测的值
14
12
  * @param {Object} [options] 配置项
15
13
  * @param {boolean} [options.checkCode=true] 是否校验最后一位校验码,如果为false,不校验校验位。
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Validator.isSwiftCode
6
6
  * @since 4.9.0
7
- * @see {@link https://zh.wikipedia.org/wiki/ISO_9362 | ISO 9362}
7
+ * @see {@link https://zh.wikipedia.org/wiki/ISO_9362 ISO 9362}
8
8
  * @param {*} value 要检测的值
9
9
  * @returns {boolean} 值是否为 Swift Code
10
10
  * @example
@@ -7,7 +7,7 @@ type Options = {
7
7
  * @static
8
8
  * @alias module:Validator.isTWCard
9
9
  * @since 4.0.0
10
- * @see {@link https://zh.wikipedia.org/wiki/台湾居民来往大陆通行证 | 台湾居民来往大陆通行证}
10
+ * @see {@link https://zh.wikipedia.org/wiki/台湾居民来往大陆通行证 台湾居民来往大陆通行证}
11
11
  * @param {*} value 要检测的值
12
12
  * @param {Object} [options] 配置项
13
13
  * @param {boolean} [options.loose=false] 宽松模式。如果为true,表示支持一次性短期通行证
package/types/isUrl.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Validator.isUrl
6
6
  * @since 3.4.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} 值是否为url
10
10
  * @example
@@ -4,7 +4,7 @@
4
4
  * @static
5
5
  * @alias module:Validator.isVehicle
6
6
  * @since 1.1.0
7
- * @see {@link https://baike.baidu.com/item/车牌号 | 车牌号}
7
+ * @see {@link https://baike.baidu.com/item/车牌号 车牌号}
8
8
  * @param {*} value 要检测的值
9
9
  * @returns {boolean} 值是否为车牌号
10
10
  * @example
package/types/lcm.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * @static
15
15
  * @alias module:Math.lcm
16
16
  * @since 4.20.0
17
- * @see {@link https://baike.baidu.com/item/最小公倍数 | 最小公倍数}
17
+ * @see {@link https://baike.baidu.com/item/最小公倍数 最小公倍数}
18
18
  * @param {...(number|string)} nums 两个或多个整数。
19
19
  * @returns {number} 最小公倍数。
20
20
  * @example
@@ -1,8 +1,3 @@
1
- /**
2
- * @typedef {Object} CacheOptions 缓存配置
3
- * @property {boolean} [useCache=true] 是否使用缓存
4
- * @property {boolean} [autoRevokeOnDel=true] 删除时自动释放缓存
5
- */
6
1
  /**
7
2
  * 加载图片。
8
3
  *
@@ -12,7 +7,6 @@
12
7
  * @alias module:Other.loadImage
13
8
  * @since 4.20.0
14
9
  * @param {string | Blob} img 图片地址或 blob 对象
15
- * @param {boolean | CacheOptions} [cacheOptions=true] 是否使用缓存。开启后,自动缓存最近上一次成功的结果,当图片地址或 blob 对象一致时,直接返回该缓存。避免连续请求同一个图片资源,重复加载。当缓存下一次成功加载的图片时,会自动释放上一次缓存的图片,也可以通过 `autoRevokeOnDel` 设置不释放缓存。
16
10
  * @returns {Promise<HTMLImageElement>} HTML图片元素
17
11
  * @example
18
12
  *
@@ -29,8 +23,5 @@
29
23
  * });
30
24
  *
31
25
  */
32
- declare function loadImage(img: string | Blob, cacheOptions?: boolean | {
33
- useCache?: boolean;
34
- autoRevokeOnDel?: boolean;
35
- }): Promise<HTMLImageElement>;
26
+ declare function loadImage(img: string | Blob): Promise<HTMLImageElement>;
36
27
  export default loadImage;
@@ -7,13 +7,14 @@ import getFileBlob from './getFileBlob';
7
7
  /**
8
8
  * 加载图片,返回图片元素和 blob 对象。
9
9
  *
10
+ * 如果传入图片地址,将通过 ajax 请求转为 blob 格式。
11
+ *
10
12
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
11
13
  *
12
14
  * @method
13
15
  * @alias module:Other.loadImageWithBlob
14
16
  * @since 4.20.0
15
17
  * @param {string | Blob} img 图片地址或 blob 对象
16
- * @param {boolean | CacheOptions} [cacheOptions=true] 是否使用缓存。开启后,自动缓存最近上一次成功的结果,当图片地址或 blob 对象一致时,直接返回该缓存。避免连续请求同一个图片资源,重复加载。当缓存下一次成功加载的图片时,会自动释放上一次缓存的图片,也可以通过 `autoRevokeOnDel` 设置不释放缓存。
17
18
  * @param {AjaxOptions} [ajaxOptions] ajax 请求配置项,当传入的图片为字符串时才会触发请求。
18
19
  * @returns {Promise<ImageWithBlob>} HTML图片元素和 blob 对象
19
20
  * @example
@@ -31,10 +32,7 @@ import getFileBlob from './getFileBlob';
31
32
  * });
32
33
  *
33
34
  */
34
- declare function loadImageWithBlob(img: string | Blob, cacheOptions?: boolean | {
35
- useCache?: boolean;
36
- autoRevokeOnDel?: boolean;
37
- }, ajaxOptions?: Parameters<typeof getFileBlob>[1]): Promise<{
35
+ declare function loadImageWithBlob(img: string | Blob, ajaxOptions?: Parameters<typeof getFileBlob>[1]): Promise<{
38
36
  image: HTMLImageElement;
39
37
  blob: Blob;
40
38
  }>;
@@ -17,7 +17,7 @@ type Options = {
17
17
  * @static
18
18
  * @alias module:Processor.numberToChinese
19
19
  * @since 1.2.0
20
- * @see {@link https://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=F5DAC3377DA99C8D78AE66735B6359C7 | 出版物上数字用法}
20
+ * @see {@link https://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=F5DAC3377DA99C8D78AE66735B6359C7 出版物上数字用法}
21
21
  * @param {number} num 数字
22
22
  * @param {Object} [options] 配置项
23
23
  * @param {boolean} [options.big5=false] 繁体
@@ -36,7 +36,7 @@ type IdCardInfo = {
36
36
  * @static
37
37
  * @alias module:Processor.parseIdCard
38
38
  * @since 4.0.0
39
- * @see {@link https://baike.baidu.com/item/居民身份证号码 | 居民身份证号码}
39
+ * @see {@link https://baike.baidu.com/item/居民身份证号码 居民身份证号码}
40
40
  * @param {string} id 身份证号码,支持15位
41
41
  * @returns {IdCardInfo | null} 省份、生日、性别,省/市/区/年/月/日/性别编码。如果解析失败将返回 null 。
42
42
  * @example
@@ -13,7 +13,7 @@ interface SafeDate {
13
13
  * @function
14
14
  * @alias module:Processor.safeDate
15
15
  * @since 4.4.0
16
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date | Date}
16
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date Date}
17
17
  * @param {string|number|Date} [value] 日期时间字符串、毫秒数、日期对象
18
18
  * @param {...number} [args] 月/日/时/分/秒/毫秒
19
19
  * @returns {Date} Date 实例日期对象
@@ -6,8 +6,8 @@
6
6
  * @static
7
7
  * @alias module:Processor.setDataURLPrefix
8
8
  * @since 4.1.0
9
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URLs}
10
- * @see {@link https://mimesniff.spec.whatwg.org/#understanding-mime-types | MIME types}
9
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URLs}
10
+ * @see {@link https://mimesniff.spec.whatwg.org/#understanding-mime-types MIME types}
11
11
  * @param {string} data 数据本身
12
12
  * @param {string} [mimeType="image/png"] MIME 类型
13
13
  * @param {boolean} [base64=true] 添加 base64 标识
@@ -23,7 +23,7 @@ type Options = {
23
23
  * @static
24
24
  * @alias module:Validator.validatePassword
25
25
  * @since 3.7.0
26
- * @see {@link https://baike.baidu.com/item/ASCII#3 | ASCII}
26
+ * @see {@link https://baike.baidu.com/item/ASCII#3 ASCII}
27
27
  * @param {string} value 要检测的值
28
28
  * @param {Object} [options] 配置项
29
29
  * @param {number} [options.level=2] 密码强度 1-包含一种字符 2-包含两种字符 3-包含三种字符。(大写字母、小写字母、数字、特殊字符)
@@ -1,7 +0,0 @@
1
- import fileReader from './fileReader.js';
2
-
3
- function blobToDataURL(blob) {
4
- return fileReader(blob);
5
- }
6
-
7
- export { blobToDataURL as default };
@@ -1,7 +0,0 @@
1
- import { isPromiseLike as isPromiseLike$1 } from 'ut2';
2
-
3
- function isPromiseLike(obj) {
4
- return isPromiseLike$1(obj);
5
- }
6
-
7
- export { isPromiseLike as default };
@@ -1,7 +0,0 @@
1
- import { toString } from 'ut2';
2
-
3
- function normalizeString(value) {
4
- return toString(value);
5
- }
6
-
7
- export { normalizeString as default };