@dxos/util 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731

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.
@@ -1164,6 +1164,26 @@ var bufferToArray = (buffer) => {
1164
1164
  };
1165
1165
  var stringToArray = (string) => bufferToArray(Buffer.from(string, "hex"));
1166
1166
  var arrayToString = (array) => arrayToBuffer(array).toString("hex");
1167
+ var toUnpaddedBase64 = (bytes) => arrayToBuffer(bytes).toString("base64").replace(/=+$/, "");
1168
+ var encodeUint8ArrayToJson = (bytes) => ({
1169
+ "/": {
1170
+ bytes: toUnpaddedBase64(bytes)
1171
+ }
1172
+ });
1173
+ var isEncodedUint8Array = (value) => {
1174
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
1175
+ return false;
1176
+ }
1177
+ if (Object.keys(value).length !== 1) {
1178
+ return false;
1179
+ }
1180
+ const inner = value["/"];
1181
+ if (typeof inner !== "object" || inner === null || Array.isArray(inner)) {
1182
+ return false;
1183
+ }
1184
+ return Object.keys(inner).length === 1 && typeof inner.bytes === "string";
1185
+ };
1186
+ var decodeUint8ArrayFromJson = (encoded) => bufferToArray(Buffer.from(encoded["/"].bytes, "base64"));
1167
1187
 
1168
1188
  // src/json.ts
1169
1189
  var MAX_DEPTH = 5;
@@ -1293,6 +1313,8 @@ var DeepMapper = class {
1293
1313
  res[i] = this._map(value[i], i);
1294
1314
  }
1295
1315
  return res;
1316
+ } else if (ArrayBuffer.isView(value)) {
1317
+ return value;
1296
1318
  } else if (value !== null && typeof value === "object") {
1297
1319
  const res = {};
1298
1320
  this._cyclic.set(value, res);
@@ -1334,6 +1356,8 @@ var DeepMapperAsync = class {
1334
1356
  res[i] = await this._map(value[i], i);
1335
1357
  }
1336
1358
  return res;
1359
+ } else if (ArrayBuffer.isView(value)) {
1360
+ return value;
1337
1361
  } else if (value !== null && typeof value === "object") {
1338
1362
  const res = {};
1339
1363
  this._cyclic.set(value, res);
@@ -1911,6 +1935,10 @@ var capitalize = (str) => {
1911
1935
  }
1912
1936
  return str.charAt(0).toUpperCase() + str.slice(1);
1913
1937
  };
1938
+ function inline(strings, ...values) {
1939
+ const raw = strings.reduce((out, str, i) => out + str + (i < values.length ? String(values[i]) : ""), "");
1940
+ return raw.replace(/\s+/g, " ").trim();
1941
+ }
1914
1942
  function trim(strings, ...values) {
1915
1943
  const raw = strings.reduce((out, str, i) => {
1916
1944
  out += str;
@@ -2328,6 +2356,7 @@ var Unit = {
2328
2356
  symbol: "ms",
2329
2357
  quotient: 1
2330
2358
  }),
2359
+ // TODO(burdon): Inconsistent formattedValue.
2331
2360
  Duration: (n) => {
2332
2361
  const hours = Math.floor(n / MS_HOURS);
2333
2362
  const minutes = Math.floor(n % MS_HOURS / MS_MINUTES);
@@ -2345,7 +2374,7 @@ var Unit = {
2345
2374
  }
2346
2375
  if (minutes) {
2347
2376
  const seconds2 = (n - MS_MINUTES * minutes) / MS_SECONDS;
2348
- const formattedValue = seconds2 ? `${minutes}m ${seconds2}s` : `${minutes}m`;
2377
+ const formattedValue = seconds2 ? `${minutes}m ${Math.round(seconds2)}s` : `${minutes}m`;
2349
2378
  return {
2350
2379
  unit: {
2351
2380
  symbol: "m",
@@ -2553,6 +2582,7 @@ export {
2553
2582
  createSetDispatch,
2554
2583
  createUrl,
2555
2584
  decamelize,
2585
+ decodeUint8ArrayFromJson,
2556
2586
  deepMapValues,
2557
2587
  deepMapValuesAsync,
2558
2588
  defaultFilter,
@@ -2563,6 +2593,7 @@ export {
2563
2593
  diff,
2564
2594
  distinctBy,
2565
2595
  doAsync,
2596
+ encodeUint8ArrayToJson,
2566
2597
  entries,
2567
2598
  entry,
2568
2599
  exponentialBackoffInterval,
@@ -2585,10 +2616,12 @@ export {
2585
2616
  idHue,
2586
2617
  inferObjectOrder,
2587
2618
  inferRecordOrder,
2619
+ inline,
2588
2620
  intersectBy,
2589
2621
  intersection,
2590
2622
  iosCheck,
2591
2623
  isBun,
2624
+ isEncodedUint8Array,
2592
2625
  isMobile,
2593
2626
  isMobileOrTablet,
2594
2627
  isNode,