@dxos/util 0.7.5-main.e9bb01b → 0.7.5-staging.2ff1350

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.
@@ -33,6 +33,15 @@ var distinctBy = (array, selector) => {
33
33
  return true;
34
34
  });
35
35
  };
36
+ var removeBy = (array, test) => {
37
+ const removed = [];
38
+ for (let i = array.length - 1; i >= 0; i--) {
39
+ if (test(array[i], i)) {
40
+ removed.push(...array.splice(i, 1));
41
+ }
42
+ }
43
+ return removed;
44
+ };
36
45
  var partition = (array, guard) => {
37
46
  return array.reduce(([accepted, rejected], item, index, array2) => guard(item, index, array2) ? [
38
47
  [
@@ -980,7 +989,7 @@ var getDebugName = (instance) => {
980
989
  return "null";
981
990
  }
982
991
  const prototype = Object.getPrototypeOf(instance);
983
- return `${prototype.constructor.name}#${getPrototypeSpecificInstanceId(instance)}`;
992
+ return `${prototype.constructor?.name ?? "Object"}#${getPrototypeSpecificInstanceId(instance)}`;
984
993
  };
985
994
 
986
995
  // packages/common/util/src/join-tables.ts
@@ -1350,6 +1359,9 @@ var range = (n, mapper) => {
1350
1359
  var rangeFromTo = (from, to, mapper) => {
1351
1360
  return mapper == null ? range(to - from, (i) => i + from) : range(to - from, (i) => mapper(i + from));
1352
1361
  };
1362
+ var clamp = (value, min, max) => {
1363
+ return Math.min(Math.max(value, min), max);
1364
+ };
1353
1365
 
1354
1366
  // packages/common/util/src/reducers.ts
1355
1367
  var accessBy = (value, accessor) => typeof accessor === "function" ? accessor(value) : value[accessor];
@@ -1484,7 +1496,7 @@ var safeParseFloat = (str, defaultValue) => {
1484
1496
  }
1485
1497
  };
1486
1498
  var safeParseJson = (data, defaultValue) => {
1487
- if (data) {
1499
+ if (data && data.length > 0) {
1488
1500
  try {
1489
1501
  return JSON.parse(data);
1490
1502
  } catch (err) {
@@ -1867,9 +1879,7 @@ var stringifyTree = (node, ancestors = [], rows = []) => {
1867
1879
 
1868
1880
  // packages/common/util/src/types.ts
1869
1881
  var isNotFalsy = (value) => !!value;
1870
- var nonNullable = (value) => value !== null && value !== void 0;
1871
- var isNotNullOrUndefined = (value) => value != null;
1872
- var boolGuard = (value) => Boolean(value);
1882
+ var isNonNullable = (value) => value != null;
1873
1883
  var doAsync = async (fn) => fn();
1874
1884
  var getProviderValue = (provider, arg) => {
1875
1885
  return typeof provider === "function" ? provider(arg) : provider;
@@ -2032,11 +2042,11 @@ export {
2032
2042
  arrayToHex,
2033
2043
  arrayToString,
2034
2044
  arraysEqual,
2035
- boolGuard,
2036
2045
  bufferToArray,
2037
2046
  byPosition,
2038
2047
  capitalize,
2039
2048
  chunkArray,
2049
+ clamp,
2040
2050
  compareMulti,
2041
2051
  compareObject,
2042
2052
  compareScalar,
@@ -2077,8 +2087,8 @@ export {
2077
2087
  intersection,
2078
2088
  iosCheck,
2079
2089
  isNode,
2090
+ isNonNullable,
2080
2091
  isNotFalsy,
2081
- isNotNullOrUndefined,
2082
2092
  joinTables,
2083
2093
  jsonKeyReplacer,
2084
2094
  jsonReplacer,
@@ -2092,7 +2102,6 @@ export {
2092
2102
  mapValues,
2093
2103
  median,
2094
2104
  mobileAndTabletCheck,
2095
- nonNullable,
2096
2105
  numericalValues,
2097
2106
  omit,
2098
2107
  orderKeys,
@@ -2105,6 +2114,7 @@ export {
2105
2114
  reduceGroupBy,
2106
2115
  reduceSeries,
2107
2116
  reduceSet,
2117
+ removeBy,
2108
2118
  removeUndefinedProperties,
2109
2119
  safariCheck,
2110
2120
  safeAwaitAll,