@dxos/util 0.7.5-labs.e27f9b9 → 0.7.5-main.2567c87

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,15 +33,6 @@ 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
- };
45
36
  var partition = (array, guard) => {
46
37
  return array.reduce(([accepted, rejected], item, index, array2) => guard(item, index, array2) ? [
47
38
  [
@@ -61,21 +52,6 @@ var partition = (array, guard) => {
61
52
  ]);
62
53
  };
63
54
 
64
- // packages/common/util/src/array-to-hex.ts
65
- var byteToHex = [];
66
- for (let n = 0; n <= 255; ++n) {
67
- const hexOctet = n.toString(16).padStart(2, "0");
68
- byteToHex.push(hexOctet);
69
- }
70
- var arrayToHex = (buf) => {
71
- const buff = new Uint8Array(buf);
72
- const hexOctets = [];
73
- for (let i = 0; i < buff.length; ++i) {
74
- hexOctets.push(byteToHex[buff[i]]);
75
- }
76
- return hexOctets.join("");
77
- };
78
-
79
55
  // packages/common/util/src/binder.ts
80
56
  import util from "@dxos/node-std/util";
81
57
  var createBinder = (obj) => ({
@@ -584,6 +560,20 @@ var getDeep = (obj, path) => {
584
560
  return parent;
585
561
  };
586
562
 
563
+ // packages/common/util/src/disposition.ts
564
+ var byDisposition = (a, b) => {
565
+ const aDisposition = a.disposition ?? "static";
566
+ const bDisposition = b.disposition ?? "static";
567
+ if (aDisposition === bDisposition) {
568
+ return 0;
569
+ } else if (aDisposition === "hoist" || bDisposition === "fallback") {
570
+ return -1;
571
+ } else if (bDisposition === "hoist" || aDisposition === "fallback") {
572
+ return 1;
573
+ }
574
+ return 0;
575
+ };
576
+
587
577
  // packages/common/util/src/entry.ts
588
578
  var entry = (map, key) => new MapEntry(map, key);
589
579
  var MapEntry = class {
@@ -989,7 +979,7 @@ var getDebugName = (instance) => {
989
979
  return "null";
990
980
  }
991
981
  const prototype = Object.getPrototypeOf(instance);
992
- return `${prototype.constructor?.name ?? "Object"}#${getPrototypeSpecificInstanceId(instance)}`;
982
+ return `${prototype.constructor.name}#${getPrototypeSpecificInstanceId(instance)}`;
993
983
  };
994
984
 
995
985
  // packages/common/util/src/join-tables.ts
@@ -1245,22 +1235,6 @@ var inferRecordOrder = (objectMap, order = []) => {
1245
1235
  }, {}), objectMap);
1246
1236
  };
1247
1237
 
1248
- // packages/common/util/src/order-keys.ts
1249
- var orderKeys = (obj, order) => {
1250
- const ordered = {};
1251
- for (const key of order) {
1252
- if (key in obj) {
1253
- ordered[key] = obj[key];
1254
- }
1255
- }
1256
- for (const key in obj) {
1257
- if (!(key in ordered)) {
1258
- ordered[key] = obj[key];
1259
- }
1260
- }
1261
- return ordered;
1262
- };
1263
-
1264
1238
  // packages/common/util/src/pick.ts
1265
1239
  var pick = (obj, keys) => {
1266
1240
  return keys.reduce((result, key) => {
@@ -1330,20 +1304,6 @@ var getHostPlatform = () => {
1330
1304
  }
1331
1305
  };
1332
1306
 
1333
- // packages/common/util/src/position.ts
1334
- var byPosition = (a, b) => {
1335
- const aPosition = a.position ?? "static";
1336
- const bPosition = b.position ?? "static";
1337
- if (aPosition === bPosition) {
1338
- return 0;
1339
- } else if (aPosition === "hoist" || bPosition === "fallback") {
1340
- return -1;
1341
- } else if (bPosition === "hoist" || aPosition === "fallback") {
1342
- return 1;
1343
- }
1344
- return 0;
1345
- };
1346
-
1347
1307
  // packages/common/util/src/random.ts
1348
1308
  var randomInt = (max, min = 0) => {
1349
1309
  min = Math.ceil(min);
@@ -1493,7 +1453,7 @@ var safeParseFloat = (str, defaultValue) => {
1493
1453
  }
1494
1454
  };
1495
1455
  var safeParseJson = (data, defaultValue) => {
1496
- if (data && data.length > 0) {
1456
+ if (data) {
1497
1457
  try {
1498
1458
  return JSON.parse(data);
1499
1459
  } catch (err) {
@@ -1878,6 +1838,7 @@ var stringifyTree = (node, ancestors = [], rows = []) => {
1878
1838
  var isNotFalsy = (value) => !!value;
1879
1839
  var nonNullable = (value) => value !== null && value !== void 0;
1880
1840
  var isNotNullOrUndefined = (value) => value != null;
1841
+ var boolGuard = (value) => Boolean(value);
1881
1842
  var doAsync = async (fn) => fn();
1882
1843
  var getProviderValue = (provider, arg) => {
1883
1844
  return typeof provider === "function" ? provider(arg) : provider;
@@ -2002,12 +1963,19 @@ var WeakDictionary = class {
2002
1963
  }
2003
1964
  };
2004
1965
 
2005
- // packages/common/util/src/string.ts
2006
- var capitalize = (str) => {
2007
- if (str.length === 0) {
2008
- return "";
1966
+ // packages/common/util/src/array-to-hex.ts
1967
+ var byteToHex = [];
1968
+ for (let n = 0; n <= 255; ++n) {
1969
+ const hexOctet = n.toString(16).padStart(2, "0");
1970
+ byteToHex.push(hexOctet);
1971
+ }
1972
+ var arrayToHex = (buf) => {
1973
+ const buff = new Uint8Array(buf);
1974
+ const hexOctets = [];
1975
+ for (let i = 0; i < buff.length; ++i) {
1976
+ hexOctets.push(byteToHex[buff[i]]);
2009
1977
  }
2010
- return str.charAt(0).toUpperCase() + str.slice(1);
1978
+ return hexOctets.join("");
2011
1979
  };
2012
1980
 
2013
1981
  // packages/common/util/src/remove-undefined-keys.ts
@@ -2022,6 +1990,22 @@ var removeUndefinedProperties = (object) => {
2022
1990
  }
2023
1991
  return object;
2024
1992
  };
1993
+
1994
+ // packages/common/util/src/order-keys.ts
1995
+ var orderKeys = (obj, order) => {
1996
+ const ordered = {};
1997
+ for (const key of order) {
1998
+ if (key in obj) {
1999
+ ordered[key] = obj[key];
2000
+ }
2001
+ }
2002
+ for (const key in obj) {
2003
+ if (!(key in ordered)) {
2004
+ ordered[key] = obj[key];
2005
+ }
2006
+ }
2007
+ return ordered;
2008
+ };
2025
2009
  export {
2026
2010
  BitField,
2027
2011
  Callback,
@@ -2040,9 +2024,9 @@ export {
2040
2024
  arrayToHex,
2041
2025
  arrayToString,
2042
2026
  arraysEqual,
2027
+ boolGuard,
2043
2028
  bufferToArray,
2044
- byPosition,
2045
- capitalize,
2029
+ byDisposition,
2046
2030
  chunkArray,
2047
2031
  compareMulti,
2048
2032
  compareObject,
@@ -2112,7 +2096,6 @@ export {
2112
2096
  reduceGroupBy,
2113
2097
  reduceSeries,
2114
2098
  reduceSet,
2115
- removeBy,
2116
2099
  removeUndefinedProperties,
2117
2100
  safariCheck,
2118
2101
  safeAwaitAll,