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
package/esm/VERSION.js CHANGED
@@ -1,4 +1,4 @@
1
- var VERSION = "5.2.1";
1
+ var VERSION = "5.2.2";
2
2
  var VERSION$1 = VERSION;
3
3
 
4
4
  export { VERSION$1 as default };
@@ -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
- if (!isFile(file) && !isUploadFile(file)) {
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;
@@ -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 = isString(fileName) && fileName.indexOf('.') > 0 ? nth(fileName.split('.'), -1) : '';
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';
@@ -1,7 +1,10 @@
1
- import { isObjectLike, isString } from 'ut2';
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.slice(-ext.length) === ext;
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
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var VERSION = "5.2.1";
3
+ var VERSION = "5.2.2";
4
4
  var VERSION$1 = VERSION;
5
5
 
6
6
  module.exports = VERSION$1;
@@ -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
- if (!ut2.isFile(file) && !file_util.isUploadFile(file)) {
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;
@@ -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 = ut2.isString(fileName) && fileName.indexOf('.') > 0 ? ut2.nth(fileName.split('.'), -1) : '';
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;
@@ -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.slice(-ext.length) === ext;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -1,6 +1,5 @@
1
1
  /**
2
- * @summary 版本号
3
- * @static
2
+ * @summary util-helpers 版本号。
4
3
  * @since 4.18.0
5
4
  */
6
5
  declare const VERSION: string;
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
- * @static
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 {Object} [options] 配置项
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`。
@@ -5,7 +5,6 @@ type BytesToSizeOptions = {
5
5
  /**
6
6
  * 字节转换存储单位
7
7
  *
8
- * @static
9
8
  * @alias module:Processor.bytesToSize
10
9
  * @since 3.8.0
11
10
  * @param {number} bytes 字节大小
@@ -6,7 +6,6 @@ type CalculateCursorPositionOptions = {
6
6
  /**
7
7
  * 计算输入框的值格式化后光标位置
8
8
  *
9
- * @static
10
9
  * @alias module:Other.calculateCursorPosition
11
10
  * @since 4.6.0
12
11
  * @see {@link https://2950v9.csb.app/ | h5示例}
@@ -2,8 +2,9 @@ import { UploadFile } from './utils/file.util';
2
2
  /**
3
3
  * 检查文件是否符合 `accept` 类型说明符。
4
4
  *
5
- * @static
6
- * @alias module:Other.checkFileType
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}
@@ -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:Other.compressImage
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 对象
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * 将 DataURL 转为 Blob 对象
3
3
  *
4
- * @static
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
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 精确除法,支持多个数相除,除数默认为 1 。
3
3
  *
4
- * @static
5
4
  * @alias module:Math.divide
6
5
  * @since 3.1.0
7
6
  * @param {...(number|string)} nums 被除数和除数
@@ -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
- * @static
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}
@@ -15,7 +15,7 @@ interface FileReader {
15
15
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
16
16
  *
17
17
  * @function
18
- * @alias module:Processor.fileReader
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 对象
@@ -4,7 +4,6 @@ type NodeAssign = 'spread' | 'self';
4
4
  *
5
5
  * 如果某节点被过滤掉,它的子节点也一并抛弃。
6
6
  *
7
- * @static
8
7
  * @alias module:Tree.filterTree
9
8
  * @since 4.15.0
10
9
  * @param {Object[]} tree 树结构数据
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 查找树结构数据节点
3
3
  *
4
- * @static
5
4
  * @alias module:Tree.findTreeNode
6
5
  * @since 4.14.0
7
6
  * @param {Object[]} tree 树结构数据
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 查找树结构数据多个节点
3
3
  *
4
- * @static
5
4
  * @alias module:Tree.findTreeNodes
6
5
  * @since 4.15.0
7
6
  * @param {Object[]} tree 树结构数据
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 查找包含当前节点的所有父级节点
3
3
  *
4
- * @static
5
4
  * @alias module:Tree.findTreeSelect
6
5
  * @since 4.14.0
7
6
  * @param {Object[]} tree 树结构数据
@@ -5,7 +5,6 @@ type Options = {
5
5
  /**
6
6
  * 格式化银行卡号
7
7
  *
8
- * @static
9
8
  * @alias module:Processor.formatBankCard
10
9
  * @since 1.1.0
11
10
  * @param {string} bankCardNo 要处理的字符串
@@ -4,7 +4,6 @@ type Options = {
4
4
  /**
5
5
  * 格式化手机号码
6
6
  *
7
- * @static
8
7
  * @alias module:Processor.formatMobile
9
8
  * @since 4.5.0
10
9
  * @param {string} mobileNo 手机号码
@@ -8,7 +8,6 @@ type Options = {
8
8
  /**
9
9
  * 格式化金额
10
10
  *
11
- * @static
12
11
  * @alias module:Processor.formatMoney
13
12
  * @since 1.1.0
14
13
  * @param {string | number} num 需转换金额 (最大:9007199254740991 最小: -9007199254740991)
package/types/gcd.d.ts CHANGED
@@ -9,7 +9,6 @@
9
9
  * 4. 如果参数为负数,将转为绝对值的正数。
10
10
  * 5. 如果参数包含小数点,将转为四舍五入的整数。
11
11
  *
12
- * @static
13
12
  * @alias module:Math.gcd
14
13
  * @since 4.20.0
15
14
  * @see {@link https://baike.baidu.com/item/最大公约数 | 最大公约数}
@@ -2,8 +2,7 @@ import ajax from './ajax';
2
2
  /**
3
3
  * 获取文件 Blob 。
4
4
  *
5
- * @static
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 请求配置项,当传入的图片为字符串时才会触发请求。
@@ -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` 对象。
@@ -15,8 +15,7 @@ import loadImageWithBlob from './loadImageWithBlob';
15
15
  *
16
16
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
17
17
  *
18
- * @static
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 请求配置项,当传入的图片为字符串时才会触发请求。
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @summary 获取常用的 MIME 类型。通过文件名后缀查找对应的 MIME 类型。
3
3
  *
4
- * @alias module:Other.getMimeType
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
- * @module Other
98
- * @since 4.2.0
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';
@@ -5,7 +5,6 @@ type Options = {
5
5
  /**
6
6
  * 检测值是否为银行卡号。正常模式(非0开头,10-21位数字)宽松模式(8-30位数字)
7
7
  *
8
- * @static
9
8
  * @alias module:Validator.isBankCard
10
9
  * @since 1.1.0
11
10
  * @see {@link https://kf.qq.com/faq/170112ABnm6b170112FvquAn.html | 常用银行账号位数参考}
@@ -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 工商行政管理市场主体注册号编制规则}
@@ -5,7 +5,6 @@ type Options = {
5
5
  /**
6
6
  * 检测值是否为中文
7
7
  *
8
- * @static
9
8
  * @alias module:Validator.isChinese
10
9
  * @since 1.1.0
11
10
  * @see {@link http://www.unicode.org/reports/tr38/#BlockListing | 4.4 Listing of Characters Covered by the Unihan Database}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为Email
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isEmail
6
5
  * @since 1.1.0
7
6
  * @param {*} value 要检测的值
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为港澳居民来往内地通行证,俗称回乡证或回乡卡。
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isHMCard
6
5
  * @since 4.0.0
7
6
  * @see {@link https://zh.wikipedia.org/wiki/港澳居民来往内地通行证 | 港澳居民来往内地通行证}
package/types/isIPv4.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为ipv4
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isIPv4
6
5
  * @since 1.1.0
7
6
  * @param {*} value 要检测的值
package/types/isIPv6.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为ipv6
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isIPv6
6
5
  * @since 1.1.0
7
6
  * @param {*} value 要检测的值
@@ -7,7 +7,6 @@ type Options = {
7
7
  *
8
8
  * 宽松模式下,支持15位身份证号码。
9
9
  *
10
- * @static
11
10
  * @alias module:Validator.isIdCard
12
11
  * @since 1.1.0
13
12
  * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码 | 中华人民共和国公民身份号码}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * 检测值是否为手机号码
3
3
  *
4
- * @static
5
4
  * @alias module:Validator.isMobile
6
5
  * @since 1.1.0
7
6
  * @param {*} value 要检测的值
@@ -2,7 +2,6 @@
2
2
  * 检测值是否为护照号
3
3
  * 支持普通护照(E*)、外交护照(DE)、公务护照(SE)、公务普通护照(PE)、香港特区护照(K/KJ/H*)、澳门特区护照(MA/MB/M*),注意不区分大小写
4
4
  *
5
- * @static
6
5
  * @alias module:Validator.isPassport
7
6
  * @since 1.1.0
8
7
  * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国护照#个人资料页 | 中华人民共和国护照#个人资料页}
@@ -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