@dxos/util 0.7.5-main.9d2a38b → 0.7.5-main.ff8607b

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.
@@ -52,6 +52,21 @@ var partition = (array, guard) => {
52
52
  ]);
53
53
  };
54
54
 
55
+ // packages/common/util/src/array-to-hex.ts
56
+ var byteToHex = [];
57
+ for (let n = 0; n <= 255; ++n) {
58
+ const hexOctet = n.toString(16).padStart(2, "0");
59
+ byteToHex.push(hexOctet);
60
+ }
61
+ var arrayToHex = (buf) => {
62
+ const buff = new Uint8Array(buf);
63
+ const hexOctets = [];
64
+ for (let i = 0; i < buff.length; ++i) {
65
+ hexOctets.push(byteToHex[buff[i]]);
66
+ }
67
+ return hexOctets.join("");
68
+ };
69
+
55
70
  // packages/common/util/src/binder.ts
56
71
  import util from "@dxos/node-std/util";
57
72
  var createBinder = (obj) => ({
@@ -560,20 +575,6 @@ var getDeep = (obj, path) => {
560
575
  return parent;
561
576
  };
562
577
 
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
-
577
578
  // packages/common/util/src/entry.ts
578
579
  var entry = (map, key) => new MapEntry(map, key);
579
580
  var MapEntry = class {
@@ -1235,6 +1236,22 @@ var inferRecordOrder = (objectMap, order = []) => {
1235
1236
  }, {}), objectMap);
1236
1237
  };
1237
1238
 
1239
+ // packages/common/util/src/order-keys.ts
1240
+ var orderKeys = (obj, order) => {
1241
+ const ordered = {};
1242
+ for (const key of order) {
1243
+ if (key in obj) {
1244
+ ordered[key] = obj[key];
1245
+ }
1246
+ }
1247
+ for (const key in obj) {
1248
+ if (!(key in ordered)) {
1249
+ ordered[key] = obj[key];
1250
+ }
1251
+ }
1252
+ return ordered;
1253
+ };
1254
+
1238
1255
  // packages/common/util/src/pick.ts
1239
1256
  var pick = (obj, keys) => {
1240
1257
  return keys.reduce((result, key) => {
@@ -1304,6 +1321,20 @@ var getHostPlatform = () => {
1304
1321
  }
1305
1322
  };
1306
1323
 
1324
+ // packages/common/util/src/position.ts
1325
+ var byPosition = (a, b) => {
1326
+ const aPosition = a.position ?? "static";
1327
+ const bPosition = b.position ?? "static";
1328
+ if (aPosition === bPosition) {
1329
+ return 0;
1330
+ } else if (aPosition === "hoist" || bPosition === "fallback") {
1331
+ return -1;
1332
+ } else if (bPosition === "hoist" || aPosition === "fallback") {
1333
+ return 1;
1334
+ }
1335
+ return 0;
1336
+ };
1337
+
1307
1338
  // packages/common/util/src/random.ts
1308
1339
  var randomInt = (max, min = 0) => {
1309
1340
  min = Math.ceil(min);
@@ -1963,19 +1994,12 @@ var WeakDictionary = class {
1963
1994
  }
1964
1995
  };
1965
1996
 
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]]);
1997
+ // packages/common/util/src/string.ts
1998
+ var capitalize = (str) => {
1999
+ if (str.length === 0) {
2000
+ return "";
1977
2001
  }
1978
- return hexOctets.join("");
2002
+ return str.charAt(0).toUpperCase() + str.slice(1);
1979
2003
  };
1980
2004
 
1981
2005
  // packages/common/util/src/remove-undefined-keys.ts
@@ -1990,22 +2014,6 @@ var removeUndefinedProperties = (object) => {
1990
2014
  }
1991
2015
  return object;
1992
2016
  };
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
- };
2009
2017
  export {
2010
2018
  BitField,
2011
2019
  Callback,
@@ -2026,7 +2034,8 @@ export {
2026
2034
  arraysEqual,
2027
2035
  boolGuard,
2028
2036
  bufferToArray,
2029
- byDisposition,
2037
+ byPosition,
2038
+ capitalize,
2030
2039
  chunkArray,
2031
2040
  compareMulti,
2032
2041
  compareObject,