util-helpers 5.2.0 → 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 +78 -73
- 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/getFileType.js +2 -2
- package/esm/getMimeType.js +2 -2
- package/esm/index.js +3 -3
- package/esm/utils/file.util.js +7 -4
- package/lib/VERSION.js +1 -1
- package/lib/checkFileType.js +6 -4
- package/lib/getFileType.js +2 -2
- package/lib/getMimeType.js +2 -2
- package/lib/index.js +6 -6
- package/lib/utils/file.util.js +6 -2
- package/package.json +1 -1
- package/types/AsyncMemo.d.ts +1 -1
- package/types/VERSION.d.ts +1 -3
- package/types/ajax.d.ts +19 -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 +7 -21
- 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 +13 -4
- package/types/getImageInfo.d.ts +14 -5
- package/types/getMimeType.d.ts +41 -4
- 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 +3 -2
- 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 -1
- package/types/validatePassword.d.ts +0 -1
- package/types/BlobUrl.d.ts +0 -41
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
|
package/types/isPostcode.d.ts
CHANGED
package/types/isQQ.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ type Options = {
|
|
|
4
4
|
/**
|
|
5
5
|
* 检测值是否为统一社会信用代码,也叫三证合一组织代码。由18位数字和大写字母组成,不使用I、O、Z、S、V。
|
|
6
6
|
*
|
|
7
|
-
* @static
|
|
8
7
|
* @alias module:Validator.isSocialCreditCode
|
|
9
8
|
* @since 1.1.0
|
|
10
9
|
* @see {@link https://zh.wikisource.org/zh-hans/GB_32100-2015_法人和其他组织统一社会信用代码编码规则 | GB 32100-2015 法人和其他组织统一社会信用代码编码规则}
|
package/types/isSwiftCode.d.ts
CHANGED
package/types/isTWCard.d.ts
CHANGED
package/types/isTelephone.d.ts
CHANGED
package/types/isUrl.d.ts
CHANGED
package/types/isValidNumber.d.ts
CHANGED
package/types/isVehicle.d.ts
CHANGED
package/types/isWX.d.ts
CHANGED
package/types/lcm.d.ts
CHANGED
package/types/listToTree.d.ts
CHANGED
package/types/loadImage.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import getFileBlob from './getFileBlob';
|
|
|
12
12
|
* <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
|
|
13
13
|
*
|
|
14
14
|
* @method
|
|
15
|
-
* @alias module:
|
|
15
|
+
* @alias module:Browser.loadImageWithBlob
|
|
16
16
|
* @since 4.20.0
|
|
17
17
|
* @param {string | Blob} img 图片地址或 blob 对象
|
|
18
18
|
* @param {AjaxOptions} [ajaxOptions] ajax 请求配置项,当传入的图片为字符串时才会触发请求。
|
|
@@ -20,7 +20,8 @@ import getFileBlob from './getFileBlob';
|
|
|
20
20
|
* @example
|
|
21
21
|
*
|
|
22
22
|
* loadImage(file).then(({image, blob})=>{
|
|
23
|
-
*
|
|
23
|
+
* console.log(image, blob);
|
|
24
|
+
* // HTMLImageElement {} Blob {}
|
|
24
25
|
* });
|
|
25
26
|
*
|
|
26
27
|
* loadImage('https://dummyimage.com/200x300').then(({image, blob})=>{
|
package/types/loadScript.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ type ScriptAttribute = Pick<HTMLScriptElement, 'async' | 'crossOrigin' | 'defer'
|
|
|
7
7
|
*
|
|
8
8
|
* <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
|
|
9
9
|
*
|
|
10
|
-
* @
|
|
11
|
-
* @alias module:Other.loadScript
|
|
10
|
+
* @alias module:Browser.loadScript
|
|
12
11
|
* @since 4.19.0
|
|
13
12
|
* @param {string} src js 地址。
|
|
14
13
|
* @param {Object} [options] script 标签属性。比如 `defer` `onload` `onerror` `id` 等,下面列举部分带有默认值或额外扩展的配置。
|
package/types/minus.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ type Options = {
|
|
|
14
14
|
*
|
|
15
15
|
* 如果数字不在安全数字 -9007199254740991~9007199254740991 范围内,处理会有异常。
|
|
16
16
|
*
|
|
17
|
-
* @static
|
|
18
17
|
* @alias module:Processor.numberToChinese
|
|
19
18
|
* @since 1.2.0
|
|
20
19
|
* @see {@link https://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=F5DAC3377DA99C8D78AE66735B6359C7 | 出版物上数字用法}
|
package/types/padZero.d.ts
CHANGED
package/types/parseIdCard.d.ts
CHANGED
package/types/plus.d.ts
CHANGED
package/types/replaceChar.d.ts
CHANGED
package/types/round.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 如果你需要获取DataURL 的 MIME 类型和数据本身,推荐使用 <a href="https://www.npmjs.com/package/data-urls">data-urls</a>。
|
|
5
5
|
*
|
|
6
|
-
* @static
|
|
7
6
|
* @alias module:Processor.setDataURLPrefix
|
|
8
7
|
* @since 4.1.0
|
|
9
8
|
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/URI/Schemes/data | Data URLs}
|
package/types/strlen.d.ts
CHANGED
package/types/times.d.ts
CHANGED
package/types/treeToList.d.ts
CHANGED
package/types/utils/config.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
export declare function getFileNameExt(name: string): string;
|
|
1
2
|
export declare function testExt(name: string | undefined, ext: string): boolean;
|
|
2
3
|
export type UploadFile = {
|
|
3
|
-
uid: string;
|
|
4
4
|
name: string;
|
|
5
5
|
type?: string;
|
|
6
6
|
url?: string;
|
|
7
|
+
fileName?: string;
|
|
8
|
+
uid?: string;
|
|
9
|
+
originFileObj?: File;
|
|
7
10
|
};
|
|
8
11
|
export declare function isUploadFile(fileObj: UploadFile): boolean;
|
package/types/BlobUrl.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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;
|