util-helpers 5.1.3 → 5.2.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 (45) hide show
  1. package/README.md +1 -0
  2. package/dist/util-helpers.js +681 -72
  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 +1 -1
  7. package/esm/getFileType.js +2 -2
  8. package/esm/getMimeType.js +43 -0
  9. package/esm/index.js +1 -0
  10. package/lib/VERSION.js +1 -1
  11. package/lib/getFileType.js +2 -2
  12. package/lib/getMimeType.js +45 -0
  13. package/lib/index.js +2 -0
  14. package/package.json +18 -18
  15. package/types/AsyncMemo.d.ts +1 -1
  16. package/types/BlobUrl.d.ts +41 -0
  17. package/types/ajax.d.ts +2 -2
  18. package/types/calculateCursorPosition.d.ts +2 -2
  19. package/types/checkFileType.d.ts +2 -2
  20. package/types/compressImage.d.ts +1 -1
  21. package/types/dataURLToBlob.d.ts +1 -1
  22. package/types/download.d.ts +3 -3
  23. package/types/fileReader.d.ts +1 -1
  24. package/types/gcd.d.ts +1 -1
  25. package/types/getFileType.d.ts +1 -1
  26. package/types/getMimeType.d.ts +25 -0
  27. package/types/index.d.ts +3 -2
  28. package/types/isBankCard.d.ts +1 -1
  29. package/types/isBusinessLicense.d.ts +1 -1
  30. package/types/isChinese.d.ts +3 -3
  31. package/types/isHMCard.d.ts +1 -1
  32. package/types/isIdCard.d.ts +2 -2
  33. package/types/isPassport.d.ts +1 -1
  34. package/types/isPassword.d.ts +1 -1
  35. package/types/isSocialCreditCode.d.ts +1 -1
  36. package/types/isSwiftCode.d.ts +1 -1
  37. package/types/isTWCard.d.ts +1 -1
  38. package/types/isUrl.d.ts +1 -1
  39. package/types/isVehicle.d.ts +1 -1
  40. package/types/lcm.d.ts +1 -1
  41. package/types/numberToChinese.d.ts +1 -1
  42. package/types/parseIdCard.d.ts +1 -1
  43. package/types/safeDate.d.ts +1 -1
  44. package/types/setDataURLPrefix.d.ts +2 -2
  45. package/types/validatePassword.d.ts +1 -1
package/esm/VERSION.js CHANGED
@@ -1,4 +1,4 @@
1
- var VERSION = "5.1.3";
1
+ var VERSION = "5.2.0";
2
2
  var VERSION$1 = VERSION;
3
3
 
4
4
  export { VERSION$1 as default };
@@ -4,8 +4,8 @@ import { isUploadFile } from './utils/file.util.js';
4
4
 
5
5
  var config = {
6
6
  image: 'image/*,.jpeg,.jpg,.gif,.bmp,.png,.webp',
7
- audio: 'audio/*,.mp3,.wav',
8
- video: 'video/*,.mp4,.webm,.ogg,.ogv,.ogm',
7
+ audio: 'audio/*,.mp3,.wav,.aac,.flac',
8
+ video: 'video/*,.mp4,.webm,.ogg',
9
9
  pdf: 'application/pdf,.pdf',
10
10
  word: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,.doc,.docx',
11
11
  excel: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,.xls,.xlsx'
@@ -0,0 +1,43 @@
1
+ import { isString, nth } from 'ut2';
2
+ import { nativeUndefined } from './utils/native.js';
3
+
4
+ var mimeTypes = [
5
+ ['text/plain', ['txt']],
6
+ ['text/css', ['css']],
7
+ ['text/html', ['htm', 'html']],
8
+ ['text/javascript', ['js', 'mjs']],
9
+ ['text/csv', ['csv']],
10
+ ['text/markdown', ['md', 'markdown']],
11
+ ['image/gif', ['gif']],
12
+ ['image/jpeg', ['jpg', 'jpeg', 'jfif', 'pjpeg', 'pjp']],
13
+ ['image/png', ['png']],
14
+ ['image/svg+xml', ['svg']],
15
+ ['image/webp', ['webp']],
16
+ ['image/apng', ['apng']],
17
+ ['image/avif', ['avif']],
18
+ ['image/bmp', ['bmp']],
19
+ ['image/x-icon', ['ico', 'cur']],
20
+ ['image/tiff', ['tif', 'tiff']],
21
+ ['application/xml', ['xml']],
22
+ ['application/zip', ['zip']],
23
+ ['application/pdf', ['pdf']],
24
+ ['application/json', ['json']],
25
+ ['application/yaml', ['yaml', 'yml']],
26
+ ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', ['doc', 'docx']],
27
+ ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ['xls', 'xlsx']],
28
+ ['audio/mp3', ['mp3']],
29
+ ['audio/wav', ['wav']],
30
+ ['audio/aac', ['aac']],
31
+ ['audio/flac', ['flac']],
32
+ ['video/mp4', ['mp4']],
33
+ ['video/ogg', ['ogg']],
34
+ ['video/webm', ['webm']],
35
+ ['video/quicktime', ['mov']]
36
+ ];
37
+ function getMimeType(fileName) {
38
+ var _a;
39
+ var ext = isString(fileName) ? nth(fileName.split('.'), -1) : '';
40
+ return ext ? (_a = mimeTypes.find(function (item) { return item[1].includes(ext); })) === null || _a === void 0 ? void 0 : _a[0] : nativeUndefined;
41
+ }
42
+
43
+ export { getMimeType as default };
package/esm/index.js CHANGED
@@ -48,6 +48,7 @@ export { default as download } from './download.js';
48
48
  export { default as getFileBlob } from './getFileBlob.js';
49
49
  export { default as getFileType } from './getFileType.js';
50
50
  export { default as getImageInfo } from './getImageInfo.js';
51
+ export { default as getMimeType } from './getMimeType.js';
51
52
  export { default as loadImage } from './loadImage.js';
52
53
  export { default as loadImageWithBlob } from './loadImageWithBlob.js';
53
54
  export { default as loadScript } from './loadScript.js';
package/lib/VERSION.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var VERSION = "5.1.3";
3
+ var VERSION = "5.2.0";
4
4
  var VERSION$1 = VERSION;
5
5
 
6
6
  module.exports = VERSION$1;
@@ -6,8 +6,8 @@ var file_util = require('./utils/file.util.js');
6
6
 
7
7
  var config = {
8
8
  image: 'image/*,.jpeg,.jpg,.gif,.bmp,.png,.webp',
9
- audio: 'audio/*,.mp3,.wav',
10
- video: 'video/*,.mp4,.webm,.ogg,.ogv,.ogm',
9
+ audio: 'audio/*,.mp3,.wav,.aac,.flac',
10
+ video: 'video/*,.mp4,.webm,.ogg',
11
11
  pdf: 'application/pdf,.pdf',
12
12
  word: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,.doc,.docx',
13
13
  excel: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,.xls,.xlsx'
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var ut2 = require('ut2');
4
+ var native = require('./utils/native.js');
5
+
6
+ var mimeTypes = [
7
+ ['text/plain', ['txt']],
8
+ ['text/css', ['css']],
9
+ ['text/html', ['htm', 'html']],
10
+ ['text/javascript', ['js', 'mjs']],
11
+ ['text/csv', ['csv']],
12
+ ['text/markdown', ['md', 'markdown']],
13
+ ['image/gif', ['gif']],
14
+ ['image/jpeg', ['jpg', 'jpeg', 'jfif', 'pjpeg', 'pjp']],
15
+ ['image/png', ['png']],
16
+ ['image/svg+xml', ['svg']],
17
+ ['image/webp', ['webp']],
18
+ ['image/apng', ['apng']],
19
+ ['image/avif', ['avif']],
20
+ ['image/bmp', ['bmp']],
21
+ ['image/x-icon', ['ico', 'cur']],
22
+ ['image/tiff', ['tif', 'tiff']],
23
+ ['application/xml', ['xml']],
24
+ ['application/zip', ['zip']],
25
+ ['application/pdf', ['pdf']],
26
+ ['application/json', ['json']],
27
+ ['application/yaml', ['yaml', 'yml']],
28
+ ['application/vnd.openxmlformats-officedocument.wordprocessingml.document', ['doc', 'docx']],
29
+ ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ['xls', 'xlsx']],
30
+ ['audio/mp3', ['mp3']],
31
+ ['audio/wav', ['wav']],
32
+ ['audio/aac', ['aac']],
33
+ ['audio/flac', ['flac']],
34
+ ['video/mp4', ['mp4']],
35
+ ['video/ogg', ['ogg']],
36
+ ['video/webm', ['webm']],
37
+ ['video/quicktime', ['mov']]
38
+ ];
39
+ function getMimeType(fileName) {
40
+ var _a;
41
+ var ext = ut2.isString(fileName) ? ut2.nth(fileName.split('.'), -1) : '';
42
+ return ext ? (_a = mimeTypes.find(function (item) { return item[1].includes(ext); })) === null || _a === void 0 ? void 0 : _a[0] : native.nativeUndefined;
43
+ }
44
+
45
+ module.exports = getMimeType;
package/lib/index.js CHANGED
@@ -50,6 +50,7 @@ var download = require('./download.js');
50
50
  var getFileBlob = require('./getFileBlob.js');
51
51
  var getFileType = require('./getFileType.js');
52
52
  var getImageInfo = require('./getImageInfo.js');
53
+ var getMimeType = require('./getMimeType.js');
53
54
  var loadImage = require('./loadImage.js');
54
55
  var loadImageWithBlob = require('./loadImageWithBlob.js');
55
56
  var loadScript = require('./loadScript.js');
@@ -118,6 +119,7 @@ exports.download = download;
118
119
  exports.getFileBlob = getFileBlob;
119
120
  exports.getFileType = getFileType;
120
121
  exports.getImageInfo = getImageInfo;
122
+ exports.getMimeType = getMimeType;
121
123
  exports.loadImage = loadImage;
122
124
  exports.loadImageWithBlob = loadImageWithBlob;
123
125
  exports.loadScript = loadScript;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "5.1.3",
3
+ "version": "5.2.0",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -51,36 +51,36 @@
51
51
  },
52
52
  "homepage": "https://doly-dev.github.io/util-helpers/index.html",
53
53
  "devDependencies": {
54
- "@babel/core": "^7.24.7",
55
- "@babel/preset-env": "^7.24.7",
56
- "@babel/preset-typescript": "^7.24.7",
54
+ "@babel/core": "^7.25.8",
55
+ "@babel/preset-env": "^7.25.8",
56
+ "@babel/preset-typescript": "^7.25.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
60
  "@rollup/plugin-commonjs": "^25.0.8",
61
- "@rollup/plugin-node-resolve": "^15.2.3",
61
+ "@rollup/plugin-node-resolve": "^15.3.0",
62
62
  "@rollup/plugin-replace": "^5.0.7",
63
63
  "@rollup/plugin-terser": "^0.4.4",
64
64
  "@rollup/plugin-typescript": "^11.1.6",
65
- "@types/jest": "^29.5.12",
66
- "@typescript-eslint/eslint-plugin": "^7.16.0",
67
- "@typescript-eslint/parser": "^7.16.0",
65
+ "@types/jest": "^29.5.13",
66
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
67
+ "@typescript-eslint/parser": "^7.18.0",
68
68
  "babel-jest": "^29.7.0",
69
69
  "babel-plugin-minify-replace": "^0.5.0",
70
- "commitizen": "^4.3.0",
70
+ "commitizen": "^4.3.1",
71
71
  "cross-env": "^7.0.3",
72
72
  "docdash": "^2.0.2",
73
- "eslint": "^8.57.0",
74
- "husky": "^9.0.11",
73
+ "eslint": "^8.57.1",
74
+ "husky": "^9.1.6",
75
75
  "inquirer": "^8.2.6",
76
76
  "jest": "^29.7.0",
77
77
  "jest-canvas-mock": "^2.5.2",
78
78
  "jest-environment-jsdom": "^29.7.0",
79
- "jsdoc": "^4.0.3",
79
+ "jsdoc": "^4.0.4",
80
80
  "lint-staged": "^13.3.0",
81
- "prettier": "^3.3.2",
82
- "rollup": "^4.18.1",
83
- "typescript": "^5.5.3"
81
+ "prettier": "^3.3.3",
82
+ "rollup": "^4.24.0",
83
+ "typescript": "^5.6.3"
84
84
  },
85
85
  "lint-staged": {
86
86
  "**/*.ts": "eslint",
@@ -92,9 +92,9 @@
92
92
  }
93
93
  },
94
94
  "dependencies": {
95
- "cache2": "^3.0.0",
96
- "tslib": "^2.6.3",
97
- "ut2": "^1.11.0"
95
+ "cache2": "^3.1.1",
96
+ "tslib": "^2.8.0",
97
+ "ut2": "^1.13.0"
98
98
  },
99
99
  "publishConfig": {
100
100
  "registry": "https://registry.npmjs.org/"
@@ -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] 缓存策略
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Blob 对象 URL 记录。
3
+ *
4
+ * 便于管理项目中上传文件通过 `URL.createObjectURL` 生成的对象URL。
5
+ *
6
+ * 特点:
7
+ * 1. 避免重复创建,相同的 `Blob` 对象只会生成一个 URL 字符串
8
+ * 2. 当清除缓存时,自动释放内存
9
+ *
10
+ * @class
11
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/URL/createObjectURL_static | URL:createObjectURL()}
12
+ * @example
13
+ * const blobUrl = new BlobUrl();
14
+ *
15
+ */
16
+ declare class BlobUrl {
17
+ protected cache: Map<Blob, string>;
18
+ constructor();
19
+ /**
20
+ * 同 `URL.createObjectURL` 方法,创建一个对象 URL 字符串。
21
+ *
22
+ * 生成时内部会记录一个缓存,相同的 `Blob` 对象最多只会产生一个 URL 字符串。
23
+ *
24
+ * @param {Blob} obj 用于创建 URL 的 File、Blob 对象。
25
+ * @returns 一个包含对象 URL 的字符串,可用于引用指定源 object 的内容。
26
+ */
27
+ createObjectURL(obj: Blob): string | undefined;
28
+ /**
29
+ * 同 `URL.revokeObjectURL` 方法,释放对象 URL 。
30
+ *
31
+ * @param {string} url 通过调用 `createObjectURL()` 方法创建的对象 URL 的字符串。
32
+ */
33
+ revokeObjectURL(url: string): void;
34
+ /**
35
+ * 清理缓存。
36
+ *
37
+ * 迭代调用 `URL.revokeObjectURL` 来释放内存。
38
+ */
39
+ clear(): void;
40
+ }
41
+ export default BlobUrl;
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 当前输入原值
@@ -5,8 +5,8 @@ import { UploadFile } from './utils/file.util';
5
5
  * @static
6
6
  * @alias module:Other.checkFileType
7
7
  * @since 5.1.0
8
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/file#唯一文件类型说明符 唯一文件类型说明符}
9
- * @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml Media Types}
8
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/file#唯一文件类型说明符 | 唯一文件类型说明符}
9
+ * @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml | Media Types}
10
10
  * @param {File} file 文件对象。支持 antd `UploadFile` 对象。
11
11
  * @param {string} [accept] 文件类型说明符。
12
12
  * @returns {boolean} 如果 `file` 符合 `accept` 返回 `true`, 否则返回 `false`。
@@ -37,7 +37,7 @@ interface CompressImage {
37
37
  * @function
38
38
  * @alias module:Other.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] 自定义图片宽度,默认图片自身宽度
@@ -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
@@ -40,9 +40,9 @@ type DownloadOptions = {
40
40
  * @static
41
41
  * @alias module:Other.download
42
42
  * @since 4.16.0
43
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers Access-Control-Expose-Headers}
44
- * @see {@link https://zh.wikipedia.org/wiki/多用途互聯網郵件擴展 MIME}
45
- * @see {@link https://9ykc9s.csb.app/ 在线示例}
43
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers | Access-Control-Expose-Headers}
44
+ * @see {@link https://zh.wikipedia.org/wiki/多用途互聯網郵件擴展 | MIME}
45
+ * @see {@link https://9ykc9s.csb.app/ | 在线示例}
46
46
  * @param {string|Blob|ArrayBuffer|TypedArray} data 字符串、blob数据或url地址
47
47
  * @param {string|DownloadOptions} [options] 文件名称 或 配置项
48
48
  * @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'] 读取类型,默认`dataURL`。可选 `arrayBuffer` `binaryString` `dataURL` `text` 。
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
@@ -1,6 +1,6 @@
1
1
  import { UploadFile } from './utils/file.util';
2
2
  /**
3
- * 获取文件类型
3
+ * 获取文件类型。
4
4
  *
5
5
  * @static
6
6
  * @alias module:Other.getFileType
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 获取常用的 MIME 类型。
3
+ *
4
+ * 通过文件名后缀查找对于的 MIME 类型。
5
+ *
6
+ * @alias module:Other.getMimeType
7
+ * @since 5.2.0
8
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/MIME_types | MIME 类型(IANA 媒体类型)}
9
+ * @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml | Media Types}
10
+ * @param {string} fileName 文件名。
11
+ * @returns 如果找到,返回 MIME 类型字符串,否则返回 `undefined`。
12
+ * @example
13
+ * getMimeType('xxx.png'); // 'image/png'
14
+ * getMimeType('xxx.jpg'); // 'image/jpeg'
15
+ * getMimeType('xxx.mp3'); // 'audio/mp3'
16
+ * getMimeType('xxx.mp4'); // 'video/mp4'
17
+ * getMimeType('xxx.pdf'); // 'application/pdf'
18
+ * getMimeType('xxx.zip'); // 'application/zip'
19
+ * getMimeType('xxx.doc'); // 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
20
+ *
21
+ * // 不常用或未知类型
22
+ * getMimeTye('xxx.ci'); // undefined
23
+ */
24
+ declare function getMimeType(fileName: string): string | undefined;
25
+ export default getMimeType;
package/types/index.d.ts CHANGED
@@ -50,8 +50,8 @@ export { default as transformObjectValue } from './transformObjectValue';
50
50
  *
51
51
  * @module Math
52
52
  * @since 3.1.0
53
- * @see {@link https://github.com/camsong/blog/issues/9 JavaScript 浮点数陷阱及解法}
54
- * @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浮点数计算测试}
55
55
  * @example
56
56
  * // 从 4.12.0 版本开始,规范了有效数值。(注意:4.12.3 对有效数值重新定义)
57
57
  * // 有效数值即能通过 Number(value) 转为数字,且不能为 NaN 。
@@ -105,6 +105,7 @@ export { default as download } from './download';
105
105
  export { default as getFileBlob } from './getFileBlob';
106
106
  export { default as getFileType } from './getFileType';
107
107
  export { default as getImageInfo } from './getImageInfo';
108
+ export { default as getMimeType } from './getMimeType';
108
109
  export { default as loadImage } from './loadImage';
109
110
  export { default as loadImageWithBlob } from './loadImageWithBlob';
110
111
  export { default as loadScript } from './loadScript';
@@ -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] 宽松模式,默认`false`。正常模式10-21位数字(个人账户),宽松模式8-30位数字(企业账户)。
@@ -7,7 +7,7 @@ type Options = {
7
7
  * @static
8
8
  * @alias module:Validator.isBusinessLicense
9
9
  * @since 3.5.0
10
- * @see {@link https://wenku.baidu.com/view/19873704cc1755270722087c.html GS15—2006 工商行政管理市场主体注册号编制规则}
10
+ * @see {@link https://wenku.baidu.com/view/19873704cc1755270722087c.html | GS15—2006 工商行政管理市场主体注册号编制规则}
11
11
  * @param {*} value 要检测的值
12
12
  * @param {Object} [options] 配置项
13
13
  * @param {boolean} [options.checkCode=true] 是否校验最后一位校验码,默认`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] 宽松模式,默认`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] 宽松模式,默认`false`。如果为`true`,支持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] 密码强度,默认`2`。`1`-包含一种字符 `2`-包含两种字符 `3`-包含三种字符。(大写字母、小写字母、数字、特殊字符)
@@ -7,7 +7,7 @@ type Options = {
7
7
  * @static
8
8
  * @alias module:Validator.isSocialCreditCode
9
9
  * @since 1.1.0
10
- * @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 法人和其他组织统一社会信用代码编码规则}
11
11
  * @param {*} value 要检测的值
12
12
  * @param {Object} [options] 配置项
13
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] 宽松模式,默认`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
@@ -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] 繁体,默认`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/URI/Schemes/data | Data URLs}
10
+ * @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml | Media Types}
11
11
  * @param {string} data 数据本身
12
12
  * @param {string} [mimeType="image/png"] MIME 类型,默认`image/png`
13
13
  * @param {boolean} [base64=true] 添加 base64 标识,默认`true`
@@ -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] 密码强度,默认`2`。`1`-包含一种字符 `2`-包含两种字符 `3`-包含三种字符。(大写字母、小写字母、数字、特殊字符)