util-helpers 5.2.1 → 5.2.2
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.
- package/README.md +18 -17
- package/dist/util-helpers.js +75 -70
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/VERSION.js +1 -1
- package/esm/checkFileType.js +6 -4
- package/esm/getMimeType.js +2 -2
- package/esm/index.js +3 -3
- package/esm/utils/file.util.js +6 -3
- package/lib/VERSION.js +1 -1
- package/lib/checkFileType.js +6 -4
- package/lib/getMimeType.js +2 -2
- package/lib/index.js +6 -6
- package/lib/utils/file.util.js +5 -1
- package/package.json +1 -1
- package/types/VERSION.d.ts +1 -2
- package/types/ajax.d.ts +2 -3
- package/types/bytesToSize.d.ts +0 -1
- package/types/calculateCursorPosition.d.ts +0 -1
- package/types/checkFileType.d.ts +3 -2
- package/types/compressImage.d.ts +1 -1
- package/types/dataURLToBlob.d.ts +1 -2
- package/types/divide.d.ts +0 -1
- package/types/download.d.ts +1 -2
- package/types/fileReader.d.ts +1 -1
- package/types/filterTree.d.ts +0 -1
- package/types/findTreeNode.d.ts +0 -1
- package/types/findTreeNodes.d.ts +0 -1
- package/types/findTreeSelect.d.ts +0 -1
- package/types/formatBankCard.d.ts +0 -1
- package/types/formatMobile.d.ts +0 -1
- package/types/formatMoney.d.ts +0 -1
- package/types/gcd.d.ts +0 -1
- package/types/getFileBlob.d.ts +1 -2
- package/types/getFileType.d.ts +1 -3
- package/types/getImageInfo.d.ts +1 -2
- package/types/getMimeType.d.ts +1 -1
- package/types/index.d.ts +12 -10
- package/types/isBankCard.d.ts +0 -1
- package/types/isBusinessLicense.d.ts +0 -1
- package/types/isChinese.d.ts +0 -1
- package/types/isEmail.d.ts +0 -1
- package/types/isHMCard.d.ts +0 -1
- package/types/isIPv4.d.ts +0 -1
- package/types/isIPv6.d.ts +0 -1
- package/types/isIdCard.d.ts +0 -1
- package/types/isMobile.d.ts +0 -1
- package/types/isPassport.d.ts +0 -1
- package/types/isPassword.d.ts +0 -1
- package/types/isPostcode.d.ts +0 -1
- package/types/isQQ.d.ts +0 -1
- package/types/isSocialCreditCode.d.ts +0 -1
- package/types/isSwiftCode.d.ts +0 -1
- package/types/isTWCard.d.ts +0 -1
- package/types/isTelephone.d.ts +0 -1
- package/types/isUrl.d.ts +0 -1
- package/types/isValidNumber.d.ts +0 -1
- package/types/isVehicle.d.ts +0 -1
- package/types/isWX.d.ts +0 -1
- package/types/lcm.d.ts +0 -1
- package/types/listToTree.d.ts +0 -1
- package/types/loadImage.d.ts +1 -2
- package/types/loadImageWithBlob.d.ts +1 -1
- package/types/loadScript.d.ts +1 -2
- package/types/minus.d.ts +0 -1
- package/types/numberToChinese.d.ts +0 -1
- package/types/padZero.d.ts +0 -1
- package/types/parseIdCard.d.ts +0 -1
- package/types/plus.d.ts +0 -1
- package/types/replaceChar.d.ts +0 -1
- package/types/round.d.ts +0 -1
- package/types/setDataURLPrefix.d.ts +0 -1
- package/types/strlen.d.ts +0 -1
- package/types/times.d.ts +0 -1
- package/types/transformFieldNames.d.ts +0 -1
- package/types/transformObjectValue.d.ts +0 -1
- package/types/treeToList.d.ts +0 -1
- package/types/utils/config.d.ts +0 -1
- package/types/utils/file.util.d.ts +4 -0
- package/types/validatePassword.d.ts +0 -1
- package/types/BlobUrl.d.ts +0 -41
package/esm/VERSION.js
CHANGED
package/esm/checkFileType.js
CHANGED
|
@@ -2,7 +2,9 @@ import { isFile, isString, toString } from 'ut2';
|
|
|
2
2
|
import { isUploadFile, testExt } from './utils/file.util.js';
|
|
3
3
|
|
|
4
4
|
function checkFileType(file, accept) {
|
|
5
|
-
|
|
5
|
+
var _a, _b;
|
|
6
|
+
var isFileType = isFile(file);
|
|
7
|
+
if (!isFileType && !isUploadFile(file)) {
|
|
6
8
|
return false;
|
|
7
9
|
}
|
|
8
10
|
if (!isString(accept)) {
|
|
@@ -14,9 +16,9 @@ function checkFileType(file, accept) {
|
|
|
14
16
|
}
|
|
15
17
|
var ret = false;
|
|
16
18
|
var types = accept.toLowerCase().split(/,(?:\s+)?/);
|
|
17
|
-
var fileName = file.name.toLowerCase();
|
|
18
|
-
var fileType = file.type || '';
|
|
19
|
-
var fileUrl = file.url || '';
|
|
19
|
+
var fileName = (file.name || (!isFileType && (file.fileName || ((_a = file.originFileObj) === null || _a === void 0 ? void 0 : _a.name))) || '').toLowerCase();
|
|
20
|
+
var fileType = file.type || (!isFileType && ((_b = file.originFileObj) === null || _b === void 0 ? void 0 : _b.type)) || '';
|
|
21
|
+
var fileUrl = (!isFileType && file.url) || '';
|
|
20
22
|
types.some(function (type) {
|
|
21
23
|
if (type === '*' || fileType === type || (type.indexOf('.') === 0 && (testExt(fileName, type) || testExt(fileUrl, type)))) {
|
|
22
24
|
ret = true;
|
package/esm/getMimeType.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isString, nth } from 'ut2';
|
|
2
1
|
import { nativeUndefined } from './utils/native.js';
|
|
2
|
+
import { getFileNameExt } from './utils/file.util.js';
|
|
3
3
|
|
|
4
4
|
var mimeTypes = [
|
|
5
5
|
['text/plain', ['txt']],
|
|
@@ -36,7 +36,7 @@ var mimeTypes = [
|
|
|
36
36
|
];
|
|
37
37
|
function getMimeType(fileName) {
|
|
38
38
|
var _a;
|
|
39
|
-
var ext =
|
|
39
|
+
var ext = getFileNameExt(fileName).slice(1);
|
|
40
40
|
return ext ? (_a = mimeTypes.find(function (item) { return item[1].includes(ext); })) === null || _a === void 0 ? void 0 : _a[0] : nativeUndefined;
|
|
41
41
|
}
|
|
42
42
|
|
package/esm/index.js
CHANGED
|
@@ -26,8 +26,6 @@ export { default as replaceChar } from './replaceChar.js';
|
|
|
26
26
|
export { default as numberToChinese } from './numberToChinese.js';
|
|
27
27
|
export { default as bytesToSize } from './bytesToSize.js';
|
|
28
28
|
export { default as parseIdCard } from './parseIdCard.js';
|
|
29
|
-
export { default as fileReader } from './fileReader.js';
|
|
30
|
-
export { default as dataURLToBlob } from './dataURLToBlob.js';
|
|
31
29
|
export { default as setDataURLPrefix } from './setDataURLPrefix.js';
|
|
32
30
|
export { default as safeDate } from './safeDate.js';
|
|
33
31
|
export { default as formatMobile } from './formatMobile.js';
|
|
@@ -41,10 +39,11 @@ export { default as round } from './round.js';
|
|
|
41
39
|
export { default as gcd } from './gcd.js';
|
|
42
40
|
export { default as lcm } from './lcm.js';
|
|
43
41
|
export { default as ajax } from './ajax.js';
|
|
44
|
-
export { default as calculateCursorPosition } from './calculateCursorPosition.js';
|
|
45
42
|
export { default as checkFileType } from './checkFileType.js';
|
|
46
43
|
export { default as compressImage } from './compressImage.js';
|
|
44
|
+
export { default as dataURLToBlob } from './dataURLToBlob.js';
|
|
47
45
|
export { default as download } from './download.js';
|
|
46
|
+
export { default as fileReader } from './fileReader.js';
|
|
48
47
|
export { default as getFileBlob } from './getFileBlob.js';
|
|
49
48
|
export { default as getFileType } from './getFileType.js';
|
|
50
49
|
export { default as getImageInfo } from './getImageInfo.js';
|
|
@@ -52,6 +51,7 @@ export { default as getMimeType } from './getMimeType.js';
|
|
|
52
51
|
export { default as loadImage } from './loadImage.js';
|
|
53
52
|
export { default as loadImageWithBlob } from './loadImageWithBlob.js';
|
|
54
53
|
export { default as loadScript } from './loadScript.js';
|
|
54
|
+
export { default as calculateCursorPosition } from './calculateCursorPosition.js';
|
|
55
55
|
export { default as randomString } from './randomString.js';
|
|
56
56
|
export { default as strlen } from './strlen.js';
|
|
57
57
|
export { default as transformFieldNames } from './transformFieldNames.js';
|
package/esm/utils/file.util.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isString, nth, isObjectLike } from 'ut2';
|
|
2
2
|
|
|
3
|
+
function getFileNameExt(name) {
|
|
4
|
+
return isString(name) && name.indexOf('.') > 0 ? '.' + nth(name.split('.'), -1) : '';
|
|
5
|
+
}
|
|
3
6
|
function testExt(name, ext) {
|
|
4
|
-
return !!name && name
|
|
7
|
+
return !!name && getFileNameExt(name) === ext;
|
|
5
8
|
}
|
|
6
9
|
function isUploadFile(fileObj) {
|
|
7
10
|
if (isObjectLike(fileObj) && isString(fileObj.name)) {
|
|
@@ -10,4 +13,4 @@ function isUploadFile(fileObj) {
|
|
|
10
13
|
return false;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
export { isUploadFile, testExt };
|
|
16
|
+
export { getFileNameExt, isUploadFile, testExt };
|
package/lib/VERSION.js
CHANGED
package/lib/checkFileType.js
CHANGED
|
@@ -4,7 +4,9 @@ var ut2 = require('ut2');
|
|
|
4
4
|
var file_util = require('./utils/file.util.js');
|
|
5
5
|
|
|
6
6
|
function checkFileType(file, accept) {
|
|
7
|
-
|
|
7
|
+
var _a, _b;
|
|
8
|
+
var isFileType = ut2.isFile(file);
|
|
9
|
+
if (!isFileType && !file_util.isUploadFile(file)) {
|
|
8
10
|
return false;
|
|
9
11
|
}
|
|
10
12
|
if (!ut2.isString(accept)) {
|
|
@@ -16,9 +18,9 @@ function checkFileType(file, accept) {
|
|
|
16
18
|
}
|
|
17
19
|
var ret = false;
|
|
18
20
|
var types = accept.toLowerCase().split(/,(?:\s+)?/);
|
|
19
|
-
var fileName = file.name.toLowerCase();
|
|
20
|
-
var fileType = file.type || '';
|
|
21
|
-
var fileUrl = file.url || '';
|
|
21
|
+
var fileName = (file.name || (!isFileType && (file.fileName || ((_a = file.originFileObj) === null || _a === void 0 ? void 0 : _a.name))) || '').toLowerCase();
|
|
22
|
+
var fileType = file.type || (!isFileType && ((_b = file.originFileObj) === null || _b === void 0 ? void 0 : _b.type)) || '';
|
|
23
|
+
var fileUrl = (!isFileType && file.url) || '';
|
|
22
24
|
types.some(function (type) {
|
|
23
25
|
if (type === '*' || fileType === type || (type.indexOf('.') === 0 && (file_util.testExt(fileName, type) || file_util.testExt(fileUrl, type)))) {
|
|
24
26
|
ret = true;
|
package/lib/getMimeType.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var ut2 = require('ut2');
|
|
4
3
|
var native = require('./utils/native.js');
|
|
4
|
+
var file_util = require('./utils/file.util.js');
|
|
5
5
|
|
|
6
6
|
var mimeTypes = [
|
|
7
7
|
['text/plain', ['txt']],
|
|
@@ -38,7 +38,7 @@ var mimeTypes = [
|
|
|
38
38
|
];
|
|
39
39
|
function getMimeType(fileName) {
|
|
40
40
|
var _a;
|
|
41
|
-
var ext =
|
|
41
|
+
var ext = file_util.getFileNameExt(fileName).slice(1);
|
|
42
42
|
return ext ? (_a = mimeTypes.find(function (item) { return item[1].includes(ext); })) === null || _a === void 0 ? void 0 : _a[0] : native.nativeUndefined;
|
|
43
43
|
}
|
|
44
44
|
|
package/lib/index.js
CHANGED
|
@@ -28,8 +28,6 @@ var replaceChar = require('./replaceChar.js');
|
|
|
28
28
|
var numberToChinese = require('./numberToChinese.js');
|
|
29
29
|
var bytesToSize = require('./bytesToSize.js');
|
|
30
30
|
var parseIdCard = require('./parseIdCard.js');
|
|
31
|
-
var fileReader = require('./fileReader.js');
|
|
32
|
-
var dataURLToBlob = require('./dataURLToBlob.js');
|
|
33
31
|
var setDataURLPrefix = require('./setDataURLPrefix.js');
|
|
34
32
|
var safeDate = require('./safeDate.js');
|
|
35
33
|
var formatMobile = require('./formatMobile.js');
|
|
@@ -43,10 +41,11 @@ var round = require('./round.js');
|
|
|
43
41
|
var gcd = require('./gcd.js');
|
|
44
42
|
var lcm = require('./lcm.js');
|
|
45
43
|
var ajax = require('./ajax.js');
|
|
46
|
-
var calculateCursorPosition = require('./calculateCursorPosition.js');
|
|
47
44
|
var checkFileType = require('./checkFileType.js');
|
|
48
45
|
var compressImage = require('./compressImage.js');
|
|
46
|
+
var dataURLToBlob = require('./dataURLToBlob.js');
|
|
49
47
|
var download = require('./download.js');
|
|
48
|
+
var fileReader = require('./fileReader.js');
|
|
50
49
|
var getFileBlob = require('./getFileBlob.js');
|
|
51
50
|
var getFileType = require('./getFileType.js');
|
|
52
51
|
var getImageInfo = require('./getImageInfo.js');
|
|
@@ -54,6 +53,7 @@ var getMimeType = require('./getMimeType.js');
|
|
|
54
53
|
var loadImage = require('./loadImage.js');
|
|
55
54
|
var loadImageWithBlob = require('./loadImageWithBlob.js');
|
|
56
55
|
var loadScript = require('./loadScript.js');
|
|
56
|
+
var calculateCursorPosition = require('./calculateCursorPosition.js');
|
|
57
57
|
var randomString = require('./randomString.js');
|
|
58
58
|
var strlen = require('./strlen.js');
|
|
59
59
|
var transformFieldNames = require('./transformFieldNames.js');
|
|
@@ -97,8 +97,6 @@ exports.replaceChar = replaceChar;
|
|
|
97
97
|
exports.numberToChinese = numberToChinese;
|
|
98
98
|
exports.bytesToSize = bytesToSize;
|
|
99
99
|
exports.parseIdCard = parseIdCard;
|
|
100
|
-
exports.fileReader = fileReader;
|
|
101
|
-
exports.dataURLToBlob = dataURLToBlob;
|
|
102
100
|
exports.setDataURLPrefix = setDataURLPrefix;
|
|
103
101
|
exports.safeDate = safeDate;
|
|
104
102
|
exports.formatMobile = formatMobile;
|
|
@@ -112,10 +110,11 @@ exports.round = round;
|
|
|
112
110
|
exports.gcd = gcd;
|
|
113
111
|
exports.lcm = lcm;
|
|
114
112
|
exports.ajax = ajax;
|
|
115
|
-
exports.calculateCursorPosition = calculateCursorPosition;
|
|
116
113
|
exports.checkFileType = checkFileType;
|
|
117
114
|
exports.compressImage = compressImage;
|
|
115
|
+
exports.dataURLToBlob = dataURLToBlob;
|
|
118
116
|
exports.download = download;
|
|
117
|
+
exports.fileReader = fileReader;
|
|
119
118
|
exports.getFileBlob = getFileBlob;
|
|
120
119
|
exports.getFileType = getFileType;
|
|
121
120
|
exports.getImageInfo = getImageInfo;
|
|
@@ -123,6 +122,7 @@ exports.getMimeType = getMimeType;
|
|
|
123
122
|
exports.loadImage = loadImage;
|
|
124
123
|
exports.loadImageWithBlob = loadImageWithBlob;
|
|
125
124
|
exports.loadScript = loadScript;
|
|
125
|
+
exports.calculateCursorPosition = calculateCursorPosition;
|
|
126
126
|
exports.randomString = randomString;
|
|
127
127
|
exports.strlen = strlen;
|
|
128
128
|
exports.transformFieldNames = transformFieldNames;
|
package/lib/utils/file.util.js
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var ut2 = require('ut2');
|
|
4
4
|
|
|
5
|
+
function getFileNameExt(name) {
|
|
6
|
+
return ut2.isString(name) && name.indexOf('.') > 0 ? '.' + ut2.nth(name.split('.'), -1) : '';
|
|
7
|
+
}
|
|
5
8
|
function testExt(name, ext) {
|
|
6
|
-
return !!name && name
|
|
9
|
+
return !!name && getFileNameExt(name) === ext;
|
|
7
10
|
}
|
|
8
11
|
function isUploadFile(fileObj) {
|
|
9
12
|
if (ut2.isObjectLike(fileObj) && ut2.isString(fileObj.name)) {
|
|
@@ -12,5 +15,6 @@ function isUploadFile(fileObj) {
|
|
|
12
15
|
return false;
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
exports.getFileNameExt = getFileNameExt;
|
|
15
19
|
exports.isUploadFile = isUploadFile;
|
|
16
20
|
exports.testExt = testExt;
|
package/package.json
CHANGED
package/types/VERSION.d.ts
CHANGED
package/types/ajax.d.ts
CHANGED
|
@@ -44,12 +44,11 @@ type AjaxOptions = {
|
|
|
44
44
|
*
|
|
45
45
|
* <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
|
|
46
46
|
*
|
|
47
|
-
* @
|
|
48
|
-
* @alias module:Other.ajax
|
|
47
|
+
* @alias module:Browser.ajax
|
|
49
48
|
* @since 4.16.0
|
|
50
49
|
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest | XMLHttpRequest}
|
|
51
50
|
* @param {string} url 地址
|
|
52
|
-
* @param {
|
|
51
|
+
* @param {AjaxOptions} [options] 配置项
|
|
53
52
|
* @param {string} [options.method="get"] 创建请求时使用的方法。默认 `'get'`。
|
|
54
53
|
* @param {boolean} [options.async=true] 是否异步执行操作。默认 `true`。
|
|
55
54
|
* @param {string|null} [options.user=null] 用户名,用于认证用途。默认 `null`。
|
package/types/bytesToSize.d.ts
CHANGED
package/types/checkFileType.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { UploadFile } from './utils/file.util';
|
|
|
2
2
|
/**
|
|
3
3
|
* 检查文件是否符合 `accept` 类型说明符。
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* 通过 `file.type` `file.name` `file.url` 与 `accept` 进行匹配。
|
|
6
|
+
*
|
|
7
|
+
* @alias module:Browser.checkFileType
|
|
7
8
|
* @since 5.1.0
|
|
8
9
|
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/file#唯一文件类型说明符 | 唯一文件类型说明符}
|
|
9
10
|
* @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml | Media Types}
|
package/types/compressImage.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ interface CompressImage {
|
|
|
35
35
|
* <em style="font-weight: bold;">如果是半透明图片并且导出 `image/png` 格式,建议将背景变成透明 `background=transparent`,避免出现白边。注意正常图片压缩导出 `image/png` 格式后文件可能会比原图大。</em>
|
|
36
36
|
*
|
|
37
37
|
* @function
|
|
38
|
-
* @alias module:
|
|
38
|
+
* @alias module:Browser.compressImage
|
|
39
39
|
* @since 4.20.0
|
|
40
40
|
* @see {@link https://sytpwg.csb.app/ | 在线示例}
|
|
41
41
|
* @param {string | Blob} img 图片地址或 blob 对象
|
package/types/dataURLToBlob.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 将 DataURL 转为 Blob 对象
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
5
|
-
* @alias module:Processor.dataURLToBlob
|
|
4
|
+
* @alias module:Browser.dataURLToBlob
|
|
6
5
|
* @since 4.1.0
|
|
7
6
|
* @see {@link https://developer.mozilla.org/zh-CN/docs/Glossary/Base64 | Base64}
|
|
8
7
|
* @param {string} data data: 协议的URL
|
package/types/divide.d.ts
CHANGED
package/types/download.d.ts
CHANGED
|
@@ -19,8 +19,7 @@ type DownloadOptions = {
|
|
|
19
19
|
*
|
|
20
20
|
* <em>响应头中有 "Content-Disposition" 字段,客户端获取不到?</em> 请参考查阅 [Access-Control-Expose-Headers](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers) 。
|
|
21
21
|
*
|
|
22
|
-
* @
|
|
23
|
-
* @alias module:Other.download
|
|
22
|
+
* @alias module:Browser.download
|
|
24
23
|
* @since 4.16.0
|
|
25
24
|
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Expose-Headers | Access-Control-Expose-Headers}
|
|
26
25
|
* @see {@link https://zh.wikipedia.org/wiki/多用途互聯網郵件擴展 | MIME}
|
package/types/fileReader.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ interface FileReader {
|
|
|
15
15
|
* <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
|
|
16
16
|
*
|
|
17
17
|
* @function
|
|
18
|
-
* @alias module:
|
|
18
|
+
* @alias module:Browser.fileReader
|
|
19
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 对象
|
package/types/filterTree.d.ts
CHANGED
package/types/findTreeNode.d.ts
CHANGED
package/types/findTreeNodes.d.ts
CHANGED
package/types/formatMobile.d.ts
CHANGED
package/types/formatMoney.d.ts
CHANGED
package/types/gcd.d.ts
CHANGED
package/types/getFileBlob.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import ajax from './ajax';
|
|
|
2
2
|
/**
|
|
3
3
|
* 获取文件 Blob 。
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
* @alias module:Other.getFileBlob
|
|
5
|
+
* @alias module:Browser.getFileBlob
|
|
7
6
|
* @since 4.21.0
|
|
8
7
|
* @param {string | Blob} file 文件地址或对象。
|
|
9
8
|
* @param {AjaxOptions} [ajaxOptions] ajax 请求配置项,当传入的图片为字符串时才会触发请求。
|
package/types/getFileType.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { UploadFile } from './utils/file.util';
|
|
2
2
|
/**
|
|
3
3
|
* @summary 获取文件类型。
|
|
4
|
-
*
|
|
5
|
-
* @static
|
|
6
|
-
* @alias module:Other.getFileType
|
|
4
|
+
* @alias module:Browser.getFileType
|
|
7
5
|
* @since 5.1.0
|
|
8
6
|
* @requires Other.checkFileType
|
|
9
7
|
* @param {File} file 文件对象。支持 antd `UploadFile` 对象。
|
package/types/getImageInfo.d.ts
CHANGED
|
@@ -15,8 +15,7 @@ import loadImageWithBlob from './loadImageWithBlob';
|
|
|
15
15
|
*
|
|
16
16
|
* <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
|
|
17
17
|
*
|
|
18
|
-
* @
|
|
19
|
-
* @alias module:Other.getImageInfo
|
|
18
|
+
* @alias module:Browser.getImageInfo
|
|
20
19
|
* @since 4.20.0
|
|
21
20
|
* @param {string | Blob} img 图片地址或 blob 对象。
|
|
22
21
|
* @param {AjaxOptions} [ajaxOptions] ajax 请求配置项,当传入的图片为字符串时才会触发请求。
|
package/types/getMimeType.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @summary 获取常用的 MIME 类型。通过文件名后缀查找对应的 MIME 类型。
|
|
3
3
|
*
|
|
4
|
-
* @alias module:
|
|
4
|
+
* @alias module:Browser.getMimeType
|
|
5
5
|
* @since 5.2.0
|
|
6
6
|
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/MIME_types | MIME 类型(IANA 媒体类型)}
|
|
7
7
|
* @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml | Media Types}
|
package/types/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* 数据验证
|
|
3
3
|
*
|
|
4
4
|
* @module Validator
|
|
5
|
-
* @since 1.1.0
|
|
6
5
|
*/
|
|
7
6
|
export { default as isMobile } from './isMobile';
|
|
8
7
|
export { default as isTelephone } from './isTelephone';
|
|
@@ -30,7 +29,6 @@ export { default as isValidNumber } from './isValidNumber';
|
|
|
30
29
|
* 数据处理
|
|
31
30
|
*
|
|
32
31
|
* @module Processor
|
|
33
|
-
* @since 1.1.0
|
|
34
32
|
*/
|
|
35
33
|
export { default as formatMoney } from './formatMoney';
|
|
36
34
|
export { default as formatBankCard } from './formatBankCard';
|
|
@@ -38,8 +36,6 @@ export { default as replaceChar } from './replaceChar';
|
|
|
38
36
|
export { default as numberToChinese } from './numberToChinese';
|
|
39
37
|
export { default as bytesToSize } from './bytesToSize';
|
|
40
38
|
export { default as parseIdCard } from './parseIdCard';
|
|
41
|
-
export { default as fileReader } from './fileReader';
|
|
42
|
-
export { default as dataURLToBlob } from './dataURLToBlob';
|
|
43
39
|
export { default as setDataURLPrefix } from './setDataURLPrefix';
|
|
44
40
|
export { default as safeDate } from './safeDate';
|
|
45
41
|
export { default as formatMobile } from './formatMobile';
|
|
@@ -49,7 +45,6 @@ export { default as transformObjectValue } from './transformObjectValue';
|
|
|
49
45
|
* 数学计算,修正浮点数计算问题
|
|
50
46
|
*
|
|
51
47
|
* @module Math
|
|
52
|
-
* @since 3.1.0
|
|
53
48
|
* @see {@link https://github.com/camsong/blog/issues/9 | JavaScript 浮点数陷阱及解法}
|
|
54
49
|
* @see {@link https://2zbuy.csb.app/ | JS浮点数计算测试}
|
|
55
50
|
* @example
|
|
@@ -92,16 +87,18 @@ export { default as round } from './round';
|
|
|
92
87
|
export { default as gcd } from './gcd';
|
|
93
88
|
export { default as lcm } from './lcm';
|
|
94
89
|
/**
|
|
95
|
-
*
|
|
90
|
+
* 浏览器
|
|
96
91
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
92
|
+
* <em style="font-weight: bold;">下列方法仅适用于浏览器端。</em>
|
|
93
|
+
*
|
|
94
|
+
* @module Browser
|
|
99
95
|
*/
|
|
100
96
|
export { default as ajax } from './ajax';
|
|
101
|
-
export { default as calculateCursorPosition } from './calculateCursorPosition';
|
|
102
97
|
export { default as checkFileType } from './checkFileType';
|
|
103
98
|
export { default as compressImage } from './compressImage';
|
|
99
|
+
export { default as dataURLToBlob } from './dataURLToBlob';
|
|
104
100
|
export { default as download } from './download';
|
|
101
|
+
export { default as fileReader } from './fileReader';
|
|
105
102
|
export { default as getFileBlob } from './getFileBlob';
|
|
106
103
|
export { default as getFileType } from './getFileType';
|
|
107
104
|
export { default as getImageInfo } from './getImageInfo';
|
|
@@ -109,13 +106,18 @@ export { default as getMimeType } from './getMimeType';
|
|
|
109
106
|
export { default as loadImage } from './loadImage';
|
|
110
107
|
export { default as loadImageWithBlob } from './loadImageWithBlob';
|
|
111
108
|
export { default as loadScript } from './loadScript';
|
|
109
|
+
/**
|
|
110
|
+
* 其他
|
|
111
|
+
*
|
|
112
|
+
* @module Other
|
|
113
|
+
*/
|
|
114
|
+
export { default as calculateCursorPosition } from './calculateCursorPosition';
|
|
112
115
|
export { default as randomString } from './randomString';
|
|
113
116
|
export { default as strlen } from './strlen';
|
|
114
117
|
/**
|
|
115
118
|
* 树结构数据查询、过滤、转换等处理方法
|
|
116
119
|
*
|
|
117
120
|
* @module Tree
|
|
118
|
-
* @since 4.14.0
|
|
119
121
|
*/
|
|
120
122
|
export { default as transformFieldNames } from './transformFieldNames';
|
|
121
123
|
export { default as listToTree } from './listToTree';
|
package/types/isBankCard.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ type Options = {
|
|
|
4
4
|
/**
|
|
5
5
|
* 检测值是否为营业执照号,也叫工商注册号。由14位数字本体码和1位数字校验码组成,其中本体码从左至右依次为:6位首次登记机关码、8位顺序码。
|
|
6
6
|
*
|
|
7
|
-
* @static
|
|
8
7
|
* @alias module:Validator.isBusinessLicense
|
|
9
8
|
* @since 3.5.0
|
|
10
9
|
* @see {@link https://wenku.baidu.com/view/19873704cc1755270722087c.html | GS15—2006 工商行政管理市场主体注册号编制规则}
|
package/types/isChinese.d.ts
CHANGED
package/types/isEmail.d.ts
CHANGED
package/types/isHMCard.d.ts
CHANGED
package/types/isIPv4.d.ts
CHANGED
package/types/isIPv6.d.ts
CHANGED
package/types/isIdCard.d.ts
CHANGED
package/types/isMobile.d.ts
CHANGED
package/types/isPassport.d.ts
CHANGED
package/types/isPassword.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import validatePassword from './validatePassword';
|
|
|
4
4
|
* <p><strong>注意:该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度。</strong></p>
|
|
5
5
|
* <p><i>如果需要更细致的验证,请使用 <a href="#.validatePassword">validatePassword</a></i></p>
|
|
6
6
|
*
|
|
7
|
-
* @static
|
|
8
7
|
* @alias module:Validator.isPassword
|
|
9
8
|
* @requires module:Validator.validatePassword
|
|
10
9
|
* @since 1.1.0
|