@whitesev/utils 2.9.7 → 2.9.9

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.
@@ -1425,11 +1425,15 @@ declare class Utils {
1425
1425
  */
1426
1426
  watchObject(target: any, propertyName: string, getCallBack: (value: any) => void, setCallBack: (value: any) => void): void;
1427
1427
  /**
1428
- * 深度获取对象属性
1428
+ * 深度获取对象的某个属性
1429
1429
  * @param target 待获取的对象
1430
1430
  * @param handler 获取属性的回调
1431
1431
  */
1432
- queryProperty<T = any>(target: any, handler: (target: T) => {
1432
+ queryProperty<T = any>(target: any, handler: (
1433
+ /**
1434
+ * 该值为返回的data值
1435
+ */
1436
+ target: T) => {
1433
1437
  /**
1434
1438
  * 是否是需要的属性
1435
1439
  * + `true` 将目标值赋值给data
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@whitesev/utils",
4
- "version": "2.9.7",
4
+ "version": "2.9.9",
5
5
  "type": "module",
6
6
  "description": "一个常用的工具库",
7
7
  "main": "dist/index.cjs.js",
@@ -39,24 +39,24 @@
39
39
  "worker-timers": "^8.0.25"
40
40
  },
41
41
  "devDependencies": {
42
- "@eslint/js": "^9.38.0",
43
- "@rollup/plugin-commonjs": "^28.0.9",
42
+ "@eslint/js": "^9.39.1",
43
+ "@rollup/plugin-commonjs": "^29.0.0",
44
44
  "@rollup/plugin-json": "^6.1.0",
45
45
  "@rollup/plugin-node-resolve": "^16.0.3",
46
46
  "@rollup/plugin-terser": "^0.4.4",
47
47
  "@rollup/plugin-typescript": "^12.3.0",
48
- "browserslist": "^4.27.0",
49
- "caniuse-lite": "^1.0.30001751",
50
- "eslint": "^9.38.0",
48
+ "browserslist": "^4.28.0",
49
+ "caniuse-lite": "^1.0.30001756",
50
+ "eslint": "^9.39.1",
51
51
  "eslint-config-prettier": "^10.1.8",
52
52
  "eslint-plugin-compat": "^6.0.2",
53
53
  "eslint-plugin-prettier": "^5.5.4",
54
- "globals": "^16.4.0",
55
- "rollup": "^4.52.5",
54
+ "globals": "^16.5.0",
55
+ "rollup": "^4.53.3",
56
56
  "rollup-plugin-clear": "^2.0.7",
57
57
  "tslib": "^2.8.1",
58
58
  "typescript": "^5.9.3",
59
- "typescript-eslint": "^8.46.2"
59
+ "typescript-eslint": "^8.47.0"
60
60
  },
61
61
  "scripts": {
62
62
  "lint": "eslint .",
package/src/CommonUtil.ts CHANGED
@@ -235,6 +235,9 @@ class CommonUtil {
235
235
  toJSON<T = any>(data: string | null, errorCallBack?: (error: Error) => void): T;
236
236
  toJSON<T = any>(data: string | null, errorCallBack?: (error: Error) => void): T {
237
237
  let result: any = {};
238
+ if (data == null) {
239
+ return result as T;
240
+ }
238
241
  if (typeof data === "object") {
239
242
  return data as T;
240
243
  }
package/src/Dictionary.ts CHANGED
@@ -114,13 +114,23 @@ export class UtilsDictionary<K, V> {
114
114
  * 获取字典所有的键
115
115
  */
116
116
  keys(): K[] {
117
- return Array.from(this.items.keys());
117
+ const keys = this.items.keys();
118
+ if (typeof keys.toArray === "function") {
119
+ return keys.toArray();
120
+ } else {
121
+ return [...keys];
122
+ }
118
123
  }
119
124
  /**
120
125
  * 返回字典中的所有值
121
126
  */
122
127
  values(): V[] {
123
- return Array.from(this.items.values());
128
+ const values = this.items.values();
129
+ if (typeof values.toArray === "function") {
130
+ return values.toArray();
131
+ } else {
132
+ return [...values];
133
+ }
124
134
  }
125
135
  /**
126
136
  * 清空字典
package/src/Utils.ts CHANGED
@@ -3563,13 +3563,18 @@ class Utils {
3563
3563
  }
3564
3564
  }
3565
3565
  /**
3566
- * 深度获取对象属性
3566
+ * 深度获取对象的某个属性
3567
3567
  * @param target 待获取的对象
3568
3568
  * @param handler 获取属性的回调
3569
3569
  */
3570
3570
  queryProperty<T = any>(
3571
3571
  target: any,
3572
- handler: (target: T) => {
3572
+ handler: (
3573
+ /**
3574
+ * 该值为返回的data值
3575
+ */
3576
+ target: T
3577
+ ) => {
3573
3578
  /**
3574
3579
  * 是否是需要的属性
3575
3580
  * + `true` 将目标值赋值给data