@dxos/util 0.8.2 → 0.8.3-main.672df60

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.
@@ -1537,6 +1537,34 @@ var removeUndefinedProperties = (object) => {
1537
1537
  }
1538
1538
  return object;
1539
1539
  };
1540
+ var removeProperties = (root, condition) => {
1541
+ if (!root || typeof root !== "object") {
1542
+ return root;
1543
+ }
1544
+ if (Array.isArray(root)) {
1545
+ return root.map((item) => removeProperties(item, condition));
1546
+ }
1547
+ const result = {
1548
+ ...root
1549
+ };
1550
+ if (typeof condition === "function") {
1551
+ for (const [key, value] of Object.entries(result)) {
1552
+ if (condition(key, value)) {
1553
+ delete result[key];
1554
+ }
1555
+ }
1556
+ } else {
1557
+ for (const key of condition) {
1558
+ delete result[key];
1559
+ }
1560
+ }
1561
+ for (const [key, value] of Object.entries(result)) {
1562
+ if (typeof value === "object") {
1563
+ result[key] = removeProperties(value, condition);
1564
+ }
1565
+ }
1566
+ return result;
1567
+ };
1540
1568
 
1541
1569
  // packages/common/util/src/safe-await.ts
1542
1570
  var safeAwaitAll = async (source, taskFactory, onError) => {
@@ -2106,6 +2134,10 @@ var WeakDictionary = class {
2106
2134
  this._finalization.unregister(value);
2107
2135
  }
2108
2136
  };
2137
+
2138
+ // packages/common/util/src/assume.ts
2139
+ function assumeType(value) {
2140
+ }
2109
2141
  export {
2110
2142
  BitField,
2111
2143
  Callback,
@@ -2124,6 +2156,7 @@ export {
2124
2156
  arrayToHex,
2125
2157
  arrayToString,
2126
2158
  arraysEqual,
2159
+ assumeType,
2127
2160
  bufferToArray,
2128
2161
  byPosition,
2129
2162
  capitalize,
@@ -2203,6 +2236,7 @@ export {
2203
2236
  reduceSeries,
2204
2237
  reduceSet,
2205
2238
  removeBy,
2239
+ removeProperties,
2206
2240
  removeUndefinedProperties,
2207
2241
  safariCheck,
2208
2242
  safeAwaitAll,