@dxos/util 0.8.1 → 0.8.2-main.2f9c567

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.
@@ -60,6 +60,28 @@ var partition = (array, guard) => {
60
60
  []
61
61
  ]);
62
62
  };
63
+ var intersectBy = (arrays, selector) => {
64
+ if (arrays.length === 0) {
65
+ return [];
66
+ }
67
+ if (arrays.length === 1) {
68
+ return [
69
+ ...arrays[0]
70
+ ];
71
+ }
72
+ const [first, ...rest] = arrays;
73
+ const lookups = rest.map((array) => {
74
+ const map = /* @__PURE__ */ new Map();
75
+ for (const item of array) {
76
+ map.set(selector(item), item);
77
+ }
78
+ return map;
79
+ });
80
+ return first.filter((item) => {
81
+ const key = selector(item);
82
+ return lookups.every((lookup) => lookup.has(key));
83
+ });
84
+ };
63
85
 
64
86
  // packages/common/util/src/array-to-hex.ts
65
87
  var byteToHex = [];
@@ -2057,6 +2079,19 @@ var removeUndefinedProperties = (object) => {
2057
2079
  }
2058
2080
  return object;
2059
2081
  };
2082
+
2083
+ // packages/common/util/src/clear-undefined.ts
2084
+ var clearUndefined = (obj) => {
2085
+ for (const key of [
2086
+ ...Object.getOwnPropertyNames(obj),
2087
+ ...Object.getOwnPropertySymbols(obj)
2088
+ ]) {
2089
+ if (obj[key] === void 0) {
2090
+ delete obj[key];
2091
+ }
2092
+ }
2093
+ return obj;
2094
+ };
2060
2095
  export {
2061
2096
  BitField,
2062
2097
  Callback,
@@ -2080,6 +2115,7 @@ export {
2080
2115
  capitalize,
2081
2116
  chunkArray,
2082
2117
  clamp,
2118
+ clearUndefined,
2083
2119
  compareMulti,
2084
2120
  compareObject,
2085
2121
  compareScalar,
@@ -2118,6 +2154,7 @@ export {
2118
2154
  idHue,
2119
2155
  inferObjectOrder,
2120
2156
  inferRecordOrder,
2157
+ intersectBy,
2121
2158
  intersection,
2122
2159
  iosCheck,
2123
2160
  isNode,