qmwts 1.1.69 → 1.1.71

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.
@@ -2,5 +2,6 @@ declare const _default: {
2
2
  optionalChaining(o: any | undefined, chain: string, substitute?: any): any;
3
3
  setValue(o?: any, value?: any, exclusions?: any): void;
4
4
  merge(...objects: any[]): object;
5
+ contains(a?: Record<string, any>, b?: Record<string, any>): boolean;
5
6
  };
6
7
  export default _default;
@@ -38,5 +38,18 @@ exports.default = {
38
38
  }
39
39
  }
40
40
  return data;
41
+ },
42
+ // a是否包含b的全部属性
43
+ contains(a = {}, b = {}) {
44
+ return Object.entries(b).every(([key, valueB]) => {
45
+ const valueA = a[key];
46
+ // 都是对象或数组 → 递归比较
47
+ if (prototype_utils_1.default.isObject(valueA) && prototype_utils_1.default.isObject(valueB))
48
+ return this.contains(valueA, valueB);
49
+ if (prototype_utils_1.default.isArray(valueA) && prototype_utils_1.default.isArray(valueB))
50
+ return this.contains(valueA, valueB);
51
+ // 其他情况直接比较(包括 null、数字、字符串、布尔值等)
52
+ return valueA === valueB;
53
+ });
41
54
  }
42
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qmwts",
3
- "version": "1.1.69",
3
+ "version": "1.1.71",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",