@dxos/util 0.7.5-feature-compute.4d9d99a → 0.7.5-labs.071a3e2

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.
@@ -61,6 +61,21 @@ var partition = (array, guard) => {
61
61
  ]);
62
62
  };
63
63
 
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
+
64
79
  // packages/common/util/src/binder.ts
65
80
  import util from "@dxos/node-std/util";
66
81
  var createBinder = (obj) => ({
@@ -569,20 +584,6 @@ var getDeep = (obj, path) => {
569
584
  return parent;
570
585
  };
571
586
 
572
- // packages/common/util/src/disposition.ts
573
- var byDisposition = (a, b) => {
574
- const aDisposition = a.disposition ?? "static";
575
- const bDisposition = b.disposition ?? "static";
576
- if (aDisposition === bDisposition) {
577
- return 0;
578
- } else if (aDisposition === "hoist" || bDisposition === "fallback") {
579
- return -1;
580
- } else if (bDisposition === "hoist" || aDisposition === "fallback") {
581
- return 1;
582
- }
583
- return 0;
584
- };
585
-
586
587
  // packages/common/util/src/entry.ts
587
588
  var entry = (map, key) => new MapEntry(map, key);
588
589
  var MapEntry = class {
@@ -1244,6 +1245,22 @@ var inferRecordOrder = (objectMap, order = []) => {
1244
1245
  }, {}), objectMap);
1245
1246
  };
1246
1247
 
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
+
1247
1264
  // packages/common/util/src/pick.ts
1248
1265
  var pick = (obj, keys) => {
1249
1266
  return keys.reduce((result, key) => {
@@ -1313,6 +1330,20 @@ var getHostPlatform = () => {
1313
1330
  }
1314
1331
  };
1315
1332
 
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
+
1316
1347
  // packages/common/util/src/random.ts
1317
1348
  var randomInt = (max, min = 0) => {
1318
1349
  min = Math.ceil(min);
@@ -1462,7 +1493,7 @@ var safeParseFloat = (str, defaultValue) => {
1462
1493
  }
1463
1494
  };
1464
1495
  var safeParseJson = (data, defaultValue) => {
1465
- if (data) {
1496
+ if (data && data.length > 0) {
1466
1497
  try {
1467
1498
  return JSON.parse(data);
1468
1499
  } catch (err) {
@@ -1971,19 +2002,12 @@ var WeakDictionary = class {
1971
2002
  }
1972
2003
  };
1973
2004
 
1974
- // packages/common/util/src/array-to-hex.ts
1975
- var byteToHex = [];
1976
- for (let n = 0; n <= 255; ++n) {
1977
- const hexOctet = n.toString(16).padStart(2, "0");
1978
- byteToHex.push(hexOctet);
1979
- }
1980
- var arrayToHex = (buf) => {
1981
- const buff = new Uint8Array(buf);
1982
- const hexOctets = [];
1983
- for (let i = 0; i < buff.length; ++i) {
1984
- hexOctets.push(byteToHex[buff[i]]);
2005
+ // packages/common/util/src/string.ts
2006
+ var capitalize = (str) => {
2007
+ if (str.length === 0) {
2008
+ return "";
1985
2009
  }
1986
- return hexOctets.join("");
2010
+ return str.charAt(0).toUpperCase() + str.slice(1);
1987
2011
  };
1988
2012
 
1989
2013
  // packages/common/util/src/remove-undefined-keys.ts
@@ -1998,22 +2022,6 @@ var removeUndefinedProperties = (object) => {
1998
2022
  }
1999
2023
  return object;
2000
2024
  };
2001
-
2002
- // packages/common/util/src/order-keys.ts
2003
- var orderKeys = (obj, order) => {
2004
- const ordered = {};
2005
- for (const key of order) {
2006
- if (key in obj) {
2007
- ordered[key] = obj[key];
2008
- }
2009
- }
2010
- for (const key in obj) {
2011
- if (!(key in ordered)) {
2012
- ordered[key] = obj[key];
2013
- }
2014
- }
2015
- return ordered;
2016
- };
2017
2025
  export {
2018
2026
  BitField,
2019
2027
  Callback,
@@ -2033,7 +2041,8 @@ export {
2033
2041
  arrayToString,
2034
2042
  arraysEqual,
2035
2043
  bufferToArray,
2036
- byDisposition,
2044
+ byPosition,
2045
+ capitalize,
2037
2046
  chunkArray,
2038
2047
  compareMulti,
2039
2048
  compareObject,