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.
Files changed (82) hide show
  1. package/README.md +18 -17
  2. package/dist/util-helpers.js +75 -70
  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/checkFileType.js +6 -4
  8. package/esm/getMimeType.js +2 -2
  9. package/esm/index.js +3 -3
  10. package/esm/utils/file.util.js +6 -3
  11. package/lib/VERSION.js +1 -1
  12. package/lib/checkFileType.js +6 -4
  13. package/lib/getMimeType.js +2 -2
  14. package/lib/index.js +6 -6
  15. package/lib/utils/file.util.js +5 -1
  16. package/package.json +1 -1
  17. package/types/VERSION.d.ts +1 -2
  18. package/types/ajax.d.ts +2 -3
  19. package/types/bytesToSize.d.ts +0 -1
  20. package/types/calculateCursorPosition.d.ts +0 -1
  21. package/types/checkFileType.d.ts +3 -2
  22. package/types/compressImage.d.ts +1 -1
  23. package/types/dataURLToBlob.d.ts +1 -2
  24. package/types/divide.d.ts +0 -1
  25. package/types/download.d.ts +1 -2
  26. package/types/fileReader.d.ts +1 -1
  27. package/types/filterTree.d.ts +0 -1
  28. package/types/findTreeNode.d.ts +0 -1
  29. package/types/findTreeNodes.d.ts +0 -1
  30. package/types/findTreeSelect.d.ts +0 -1
  31. package/types/formatBankCard.d.ts +0 -1
  32. package/types/formatMobile.d.ts +0 -1
  33. package/types/formatMoney.d.ts +0 -1
  34. package/types/gcd.d.ts +0 -1
  35. package/types/getFileBlob.d.ts +1 -2
  36. package/types/getFileType.d.ts +1 -3
  37. package/types/getImageInfo.d.ts +1 -2
  38. package/types/getMimeType.d.ts +1 -1
  39. package/types/index.d.ts +12 -10
  40. package/types/isBankCard.d.ts +0 -1
  41. package/types/isBusinessLicense.d.ts +0 -1
  42. package/types/isChinese.d.ts +0 -1
  43. package/types/isEmail.d.ts +0 -1
  44. package/types/isHMCard.d.ts +0 -1
  45. package/types/isIPv4.d.ts +0 -1
  46. package/types/isIPv6.d.ts +0 -1
  47. package/types/isIdCard.d.ts +0 -1
  48. package/types/isMobile.d.ts +0 -1
  49. package/types/isPassport.d.ts +0 -1
  50. package/types/isPassword.d.ts +0 -1
  51. package/types/isPostcode.d.ts +0 -1
  52. package/types/isQQ.d.ts +0 -1
  53. package/types/isSocialCreditCode.d.ts +0 -1
  54. package/types/isSwiftCode.d.ts +0 -1
  55. package/types/isTWCard.d.ts +0 -1
  56. package/types/isTelephone.d.ts +0 -1
  57. package/types/isUrl.d.ts +0 -1
  58. package/types/isValidNumber.d.ts +0 -1
  59. package/types/isVehicle.d.ts +0 -1
  60. package/types/isWX.d.ts +0 -1
  61. package/types/lcm.d.ts +0 -1
  62. package/types/listToTree.d.ts +0 -1
  63. package/types/loadImage.d.ts +1 -2
  64. package/types/loadImageWithBlob.d.ts +1 -1
  65. package/types/loadScript.d.ts +1 -2
  66. package/types/minus.d.ts +0 -1
  67. package/types/numberToChinese.d.ts +0 -1
  68. package/types/padZero.d.ts +0 -1
  69. package/types/parseIdCard.d.ts +0 -1
  70. package/types/plus.d.ts +0 -1
  71. package/types/replaceChar.d.ts +0 -1
  72. package/types/round.d.ts +0 -1
  73. package/types/setDataURLPrefix.d.ts +0 -1
  74. package/types/strlen.d.ts +0 -1
  75. package/types/times.d.ts +0 -1
  76. package/types/transformFieldNames.d.ts +0 -1
  77. package/types/transformObjectValue.d.ts +0 -1
  78. package/types/treeToList.d.ts +0 -1
  79. package/types/utils/config.d.ts +0 -1
  80. package/types/utils/file.util.d.ts +4 -0
  81. package/types/validatePassword.d.ts +0 -1
  82. package/types/BlobUrl.d.ts +0 -41
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为邮政编码,6位数字
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isPostcode
6
5
  * @since 1.1.0
7
6
  * @param {*} value 要检测的值
package/types/isQQ.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为QQ号,非0开头,5至11位数字
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isQQ
6
5
  * @since 1.1.0
7
6
  * @param {*} value 要检测的值
@@ -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 法人和其他组织统一社会信用代码编码规则}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为 Swift Code。8位或11位,前6位为大写字母,7-8位为大写字母或数字,9-11位为可选的大写字母或数字。
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isSwiftCode
6
5
  * @since 4.9.0
7
6
  * @see {@link https://zh.wikipedia.org/wiki/ISO_9362 | ISO 9362}
@@ -4,7 +4,6 @@ type Options = {
4
4
  /**
5
5
  * 检测值是否为台湾居民来往大陆通行证,俗称台胞证。
6
6
  *
7
- * @static
8
7
  * @alias module:Validator.isTWCard
9
8
  * @since 4.0.0
10
9
  * @see {@link https://zh.wikipedia.org/wiki/台湾居民来往大陆通行证 | 台湾居民来往大陆通行证}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为固定电话
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isTelephone
6
5
  * @since 1.1.0
7
6
  * @param {*} value 要检测的值
package/types/isUrl.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为url
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isUrl
6
5
  * @since 3.4.0
7
6
  * @see {@link https://zh.wikipedia.org/wiki/统一资源定位符 | 统一资源定位符}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为有效数值,支持隐式转换。如果返回 true ,表示可以通过 Number() 转为数字。
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isValidNumber
6
5
  * @since 4.17.2
7
6
  * @param {*} value 待检测的值
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为车牌号,支持新能源和非新能源车牌
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isVehicle
6
5
  * @since 1.1.0
7
6
  * @see {@link https://baike.baidu.com/item/车牌号 | 车牌号}
package/types/isWX.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为微信号
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isWX
6
5
  * @since 1.1.0
7
6
  * @param {*} value 要检测的值
package/types/lcm.d.ts CHANGED
@@ -11,7 +11,6 @@
11
11
  * 6. 如果参数为负数,将转为绝对值的正数。
12
12
  * 7. 如果参数包含小数点,将转为四舍五入的整数。
13
13
  *
14
- * @static
15
14
  * @alias module:Math.lcm
16
15
  * @since 4.20.0
17
16
  * @see {@link https://baike.baidu.com/item/最小公倍数 | 最小公倍数}
@@ -9,7 +9,6 @@ type Options = {
9
9
  /**
10
10
  * 列表数据转树结构
11
11
  *
12
- * @static
13
12
  * @alias module:Tree.listToTree
14
13
  * @since 4.14.0
15
14
  * @param {Object[]} list 列表数据
@@ -3,8 +3,7 @@
3
3
  *
4
4
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
5
5
  *
6
- * @static
7
- * @alias module:Other.loadImage
6
+ * @alias module:Browser.loadImage
8
7
  * @since 4.20.0
9
8
  * @param {string | Blob} img 图片地址或 blob 对象
10
9
  * @returns {Promise<HTMLImageElement>} HTML图片元素
@@ -12,7 +12,7 @@ import getFileBlob from './getFileBlob';
12
12
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
13
13
  *
14
14
  * @method
15
- * @alias module:Other.loadImageWithBlob
15
+ * @alias module:Browser.loadImageWithBlob
16
16
  * @since 4.20.0
17
17
  * @param {string | Blob} img 图片地址或 blob 对象
18
18
  * @param {AjaxOptions} [ajaxOptions] ajax 请求配置项,当传入的图片为字符串时才会触发请求。
@@ -7,8 +7,7 @@ type ScriptAttribute = Pick<HTMLScriptElement, 'async' | 'crossOrigin' | 'defer'
7
7
  *
8
8
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
9
9
  *
10
- * @static
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
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 精确减法,支持多个数相减,减数默认为 0 。
3
3
  *
4
- * @static
5
4
  * @alias module:Math.minus
6
5
  * @since 3.1.0
7
6
  * @param {...(number|string)} nums 相减的数
@@ -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 | 出版物上数字用法}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 前置补零
3
3
  *
4
- * @static
5
4
  * @alias module:Processor.padZero
6
5
  * @since 4.7.0
7
6
  * @param {string|number} value 要处理的值
@@ -33,7 +33,6 @@ type IdCardInfo = {
33
33
  /**
34
34
  * 解析身份证号码,支持15、18位身份证号码
35
35
  *
36
- * @static
37
36
  * @alias module:Processor.parseIdCard
38
37
  * @since 4.0.0
39
38
  * @see {@link https://baike.baidu.com/item/居民身份证号码 | 居民身份证号码}
package/types/plus.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 精确加法,支持多个数相加,加数默认为 0 。
3
3
  *
4
- * @static
5
4
  * @alias module:Math.plus
6
5
  * @since 3.1.0
7
6
  * @param {...(number|string)} nums 相加的数
@@ -8,7 +8,6 @@ type Options = {
8
8
  /**
9
9
  * 替换字符,应用场景如:脱敏
10
10
  *
11
- * @static
12
11
  * @alias module:Processor.replaceChar
13
12
  * @since 1.1.0
14
13
  * @param {string} str 要处理的字符串
package/types/round.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 四舍五入,支持设置精度
3
3
  *
4
- * @static
5
4
  * @alias module:Math.round
6
5
  * @since 3.1.0
7
6
  * @param {number|string} num 要四舍五入的数字
@@ -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
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 获取字符长度。中文汉字占2个字符,英文占1个字符,特殊如emoji占4个字符。
3
3
  *
4
- * @static
5
4
  * @alias module:Other.strlen
6
5
  * @since 4.10.0
7
6
  * @param {string} str 字符串
package/types/times.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 精确乘法,支持多个数相乘,乘数默认为 1 。
3
3
  *
4
- * @static
5
4
  * @alias module:Math.times
6
5
  * @since 3.1.0
7
6
  * @param {...(number|string)} nums 相乘的数
@@ -6,7 +6,6 @@ type TransformFieldNames<D extends any, F extends Record<string, any>, C extends
6
6
  /**
7
7
  * 转换字段名,返回一个转换字段后的值,不改变原值。
8
8
  *
9
- * @static
10
9
  * @alias module:Tree.transformFieldNames
11
10
  * @since 4.14.0
12
11
  * @param {Object[]} data 对象数组。如果是树结构数据,需要指定第三个参数 childrenField
@@ -10,7 +10,6 @@ interface TransformObjectValue {
10
10
  *
11
11
  * 例如 antd Form 中的设置表单值时,如果值为空字符串可能需要转为 `undefined` ,才不影响表单的初始值。
12
12
  *
13
- * @static
14
13
  * @alias module:Processor.transformObjectValue
15
14
  * @since 4.23.0
16
15
  * @param {Array | Object} data 要转换值的普通对象或数组
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 树结构转列表数据
3
3
  *
4
- * @static
5
4
  * @alias module:Tree.treeToList
6
5
  * @since 4.14.0
7
6
  * @param {Object[]} tree 树结构数据
@@ -3,7 +3,6 @@ declare const config: {
3
3
  };
4
4
  /**
5
5
  * 设置禁止warning提示
6
- * @static
7
6
  * @alias module:Debug.formatBankCard
8
7
  * @since 3.6.1
9
8
  * @param {boolean} bool 是否禁止warning提示
@@ -1,7 +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
4
  name: string;
4
5
  type?: string;
5
6
  url?: string;
7
+ fileName?: string;
8
+ uid?: string;
9
+ originFileObj?: File;
6
10
  };
7
11
  export declare function isUploadFile(fileObj: UploadFile): boolean;
@@ -20,7 +20,6 @@ type Options = {
20
20
  /**
21
21
  * 验证密码(数字、大小写字母、特殊字符、非法字符)
22
22
  *
23
- * @static
24
23
  * @alias module:Validator.validatePassword
25
24
  * @since 3.7.0
26
25
  * @see {@link https://baike.baidu.com/item/ASCII#3 | ASCII}
@@ -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;