util-helpers 4.17.2 → 4.17.3

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.
@@ -4,6 +4,6 @@ var config = {
4
4
  function setDisableWarning(bool) {
5
5
  config.disableWarning = !!bool;
6
6
  }
7
- var version = "4.17.2";
7
+ var version = "4.17.3";
8
8
 
9
9
  export { config, setDisableWarning, version };
@@ -6,6 +6,6 @@ exports.config = {
6
6
  function setDisableWarning(bool) {
7
7
  exports.config.disableWarning = !!bool;
8
8
  }
9
- exports.version = "4.17.2";
9
+ exports.version = "4.17.3";
10
10
 
11
11
  exports.setDisableWarning = setDisableWarning;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "4.17.2",
3
+ "version": "4.17.3",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -18,12 +18,11 @@
18
18
  "build": "npm run build:module && npm run build:dist && npm run build:types",
19
19
  "build:module": "rm -rf esm && rm -rf lib && rollup -c rollup.module.config.mjs",
20
20
  "build:dist": "rm -rf dist && rollup -c rollup.umd.config.mjs",
21
- "build:types": "rm -rf types && tsc -d --outDir types --emitDeclarationOnly",
21
+ "build:types": "rm -rf types && tsc -p tsconfig.build.json -d --outDir types --emitDeclarationOnly",
22
22
  "build:doc": "npm run doc",
23
- "doc": "rm -rf docs && rm -rf docs-src && tsc --outDir docs-src && jsdoc -c conf.json && rm -rf docs-src",
23
+ "doc": "rm -rf docs && rm -rf docs-src && tsc -p tsconfig.build.json --outDir docs-src && jsdoc -c conf.json && rm -rf docs-src",
24
24
  "doc:open": "open ./docs/index.html",
25
25
  "prettier": "prettier --write 'src/**/*.ts' && prettier --write 'test/**/*.ts'",
26
- "precommit": "lint-staged",
27
26
  "lint": "eslint src --ext .ts",
28
27
  "lint:fix": "eslint src --ext .ts --fix",
29
28
  "commit": "cz",
@@ -55,42 +54,41 @@
55
54
  },
56
55
  "homepage": "https://doly-dev.github.io/util-helpers/index.html",
57
56
  "devDependencies": {
58
- "@babel/core": "^7.21.4",
59
- "@babel/preset-env": "^7.21.4",
60
- "@babel/preset-typescript": "^7.21.4",
61
- "@commitlint/cli": "^11.0.0",
62
- "@commitlint/config-conventional": "^11.0.0",
57
+ "@babel/core": "^7.21.8",
58
+ "@babel/preset-env": "^7.21.5",
59
+ "@babel/preset-typescript": "^7.21.5",
60
+ "@commitlint/cli": "^17.6.3",
61
+ "@commitlint/config-conventional": "^17.6.3",
63
62
  "@rollup/plugin-commonjs": "^24.1.0",
64
63
  "@rollup/plugin-node-resolve": "^15.0.2",
65
64
  "@rollup/plugin-replace": "^5.0.2",
66
65
  "@rollup/plugin-terser": "^0.4.1",
67
66
  "@rollup/plugin-typescript": "^11.1.0",
68
67
  "@types/jest": "^29.5.1",
69
- "@typescript-eslint/eslint-plugin": "^5.59.1",
70
- "@typescript-eslint/parser": "^5.59.1",
68
+ "@typescript-eslint/eslint-plugin": "^5.59.5",
69
+ "@typescript-eslint/parser": "^5.59.5",
71
70
  "babel-jest": "^29.5.0",
72
71
  "babel-plugin-minify-replace": "^0.5.0",
73
72
  "cross-env": "^7.0.3",
74
73
  "cz-conventional-changelog": "^3.3.0",
75
- "docdash": "^1.2.0",
76
- "eslint": "^8.39.0",
77
- "husky": "^4.3.6",
74
+ "docdash": "^2.0.1",
75
+ "eslint": "^8.40.0",
78
76
  "jest": "^29.5.0",
79
77
  "jest-environment-jsdom": "^29.5.0",
80
- "jsdoc": "^3.6.3",
81
- "lint-staged": "^11.1.2",
78
+ "jsdoc": "^4.0.2",
79
+ "lint-staged": "^13.2.2",
82
80
  "prettier": "^2.8.8",
83
- "rollup": "^3.21.0",
84
- "typescript": "^5.0.4"
81
+ "rollup": "^3.21.6",
82
+ "typescript": "^5.0.4",
83
+ "yorkie": "^2.0.0"
85
84
  },
86
85
  "lint-staged": {
87
86
  "**/*.ts": "eslint",
88
87
  "**/*.{js,ts,md}": "prettier --write"
89
88
  },
90
- "husky": {
91
- "hooks": {
92
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
93
- }
89
+ "gitHooks": {
90
+ "pre-commit": "lint-staged",
91
+ "commit-msg": "npx --no -- commitlint --edit \"$1\""
94
92
  },
95
93
  "config": {
96
94
  "commitizen": {
package/types/ajax.d.ts CHANGED
@@ -40,7 +40,7 @@ type AjaxOptions = {
40
40
  * @property {function} [onLoadEnd] 请求结束时触发,无论请求成功 (load) 还是失败 (abort 或 error)
41
41
  */
42
42
  /**
43
- * 请求<br/><br/>
43
+ * 请求
44
44
  *
45
45
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
46
46
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 将 Blob 或 File 对象转成 data:URL 格式的 Base64 字符串<br/><br/>
2
+ * 将 Blob 或 File 对象转成 data:URL 格式的 Base64 字符串
3
3
  *
4
4
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
5
5
  *
@@ -1,5 +1,5 @@
1
1
  type CalculateCursorPositionOptions = {
2
- placeholderChar?: string;
2
+ placeholderChar?: string | string[];
3
3
  maskReg?: RegExp;
4
4
  type?: 'mobile' | 'bankCard';
5
5
  };
@@ -29,7 +29,7 @@ type DownloadOptions = {
29
29
  * @property {TransformResponse} [options.transformResponse] 请求成功后触发,在传递给 then/catch 前,允许修改响应数据
30
30
  */
31
31
  /**
32
- * 下载<br/><br/>
32
+ * 下载
33
33
  *
34
34
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端,兼容 IE10+ 和现代浏览器。</em>
35
35
  *
@@ -45,8 +45,12 @@ type DownloadOptions = {
45
45
  * // 文本
46
46
  * download('hello world', 'text.txt');
47
47
  *
48
- * // 远程文件
49
- * download('/xxx.jpg', { dataType: 'url' });
48
+ * // 远程文件1
49
+ * // 不带协议的绝对地址,需要通过 dataType 指定为 url 类型
50
+ * download('/xxx.jpg', { dataType: 'url', fileName: 'test.jpg' });
51
+ *
52
+ * // 远程文件2
53
+ * download('https://example.com/xxx.jpg');
50
54
  *
51
55
  * // base64
52
56
  * download('data:image/png;base64,PGEgaWQ9ImEiPjxiIGlkPSJiIj5oZXkhPC9iPjwvYT4=', 'test.png');
@@ -1,6 +1,8 @@
1
1
  type NodeAssign = 'spread' | 'self';
2
2
  /**
3
- * 过滤/筛选树节点。<br/><br/>如果某节点被过滤掉,它的子节点也一并抛弃
3
+ * 过滤/筛选树节点。
4
+ *
5
+ * 如果某节点被过滤掉,它的子节点也一并抛弃。
4
6
  *
5
7
  * @static
6
8
  * @alias module:Tree.filterTree
@@ -3,7 +3,9 @@ type Options = {
3
3
  checkCode?: boolean;
4
4
  };
5
5
  /**
6
- * 检测值是否为18位身份证号码。<br/>宽松模式下,支持15位身份证号码
6
+ * 检测值是否为18位身份证号码。
7
+ *
8
+ * 宽松模式下,支持15位身份证号码。
7
9
  *
8
10
  * @static
9
11
  * @alias module:Validator.isIdCard
@@ -10,7 +10,7 @@ type Options = {
10
10
  };
11
11
  };
12
12
  /**
13
- * 数字转中文数字<br/><br/>
13
+ * 数字转中文数字
14
14
  *
15
15
  * 如果数字不在安全数字 -9007199254740991~9007199254740991 范围内,处理会有异常。
16
16
  *
@@ -1,5 +1,6 @@
1
1
  /**
2
- * 设置 DataURL 前缀、MIME 类型、base64 标识。<br/>
2
+ * 设置 DataURL 前缀、MIME 类型、base64 标识。
3
+ *
3
4
  * 如果你需要获取DataURL 的 MIME 类型和数据本身,推荐使用 <a href="https://www.npmjs.com/package/data-urls">data-urls</a>。
4
5
  *
5
6
  * @static
@@ -4,12 +4,9 @@
4
4
  * @static
5
5
  * @alias module:Tree.treeToList
6
6
  * @since 4.14.0
7
- * @template {Record<string,any>} T
8
- * @template {keyof T} K
9
- * @template {Omit<T, K>} R
10
- * @param {T[]} tree 列表数据
11
- * @param {K} childrenField 子级字段名称
12
- * @returns {R[]} 列表数据
7
+ * @param {object[]} tree 树结构数据
8
+ * @param {string} childrenField 子级字段名称
9
+ * @returns {object[]} 列表数据
13
10
  * @example
14
11
  * const menus = [{ "id": "1", "name": "首页", "code": "trade", "pid": null }, { "id": "2", "name": "交易管理", "code": "trade", "pid": null, "children": [{ "id": "3", "name": "交易查询", "code": "trade-1", "pid": "2", "children": [{ "id": "4", "name": "交易查询-查询操作", "code": "trade-1-1", "pid": "3" }] }] }, { "id": "5", "name": "权限管理", "code": "authorization", "pid": null, "children": [{ "id": "6", "name": "角色管理", "code": "authorization-1", "pid": "5" }, { "id": "7", "name": "用户管理", "code": "authorization-2", "pid": "5" }] }];
15
12
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 检查值是否为Blob对象<br/><br/>
2
+ * 检查值是否为Blob对象
3
3
  *
4
4
  * <em style="font-weight: bold;">注意:该方法仅适用于浏览器端。</em>
5
5
  *
@@ -1,11 +1,11 @@
1
1
  /**
2
- * 检查值是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError|DOMException
2
+ * 检查值是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError | DOMException
3
3
  *
4
4
  * @static
5
5
  * @alias module:Type.isError
6
6
  * @since 1.1.0
7
7
  * @param {*} value 检查值
8
- * @returns {boolean} 是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError|DOMException
8
+ * @returns {boolean} 是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError | DOMException
9
9
  * @example
10
10
  *
11
11
  * isError(new Error)
@@ -2,7 +2,7 @@
2
2
  * 检查值是否为 undefined 或 null
3
3
  *
4
4
  * @static
5
- * @alias module:Type.isNaN
5
+ * @alias module:Type.isNil
6
6
  * @since 4.3.0
7
7
  * @param {*} value 检查值
8
8
  * @returns {boolean} 是否为 undefined 或 null