@dxos/util 0.8.2-main.12df754 → 0.8.2-main.36232bc
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.
- package/dist/lib/browser/index.mjs +23 -0
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +24 -0
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +23 -0
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/array.d.ts +8 -0
- package/dist/types/src/array.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/array.ts +34 -0
|
@@ -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 = [];
|
|
@@ -2118,6 +2140,7 @@ export {
|
|
|
2118
2140
|
idHue,
|
|
2119
2141
|
inferObjectOrder,
|
|
2120
2142
|
inferRecordOrder,
|
|
2143
|
+
intersectBy,
|
|
2121
2144
|
intersection,
|
|
2122
2145
|
iosCheck,
|
|
2123
2146
|
isNode,
|