@dxos/util 0.8.4-main.67995b8 → 0.8.4-main.70d3990

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.
Files changed (49) hide show
  1. package/dist/lib/browser/index.mjs +285 -104
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +285 -104
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/di-key.d.ts +3 -3
  8. package/dist/types/src/di-key.d.ts.map +1 -1
  9. package/dist/types/src/error-format.d.ts +5 -0
  10. package/dist/types/src/error-format.d.ts.map +1 -0
  11. package/dist/types/src/index.d.ts +3 -1
  12. package/dist/types/src/index.d.ts.map +1 -1
  13. package/dist/types/src/safe-parse.d.ts.map +1 -1
  14. package/dist/types/src/safe-stringify.d.ts +13 -0
  15. package/dist/types/src/safe-stringify.d.ts.map +1 -0
  16. package/dist/types/src/string.d.ts +5 -1
  17. package/dist/types/src/string.d.ts.map +1 -1
  18. package/dist/types/src/to-fallback.d.ts.map +1 -1
  19. package/dist/types/src/types.d.ts +5 -1
  20. package/dist/types/src/types.d.ts.map +1 -1
  21. package/dist/types/src/unit.d.ts +14 -0
  22. package/dist/types/src/unit.d.ts.map +1 -0
  23. package/dist/types/src/unit.test.d.ts +2 -0
  24. package/dist/types/src/unit.test.d.ts.map +1 -0
  25. package/dist/types/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +9 -9
  27. package/src/array.test.ts +1 -1
  28. package/src/binder.ts +2 -2
  29. package/src/circular-buffer.test.ts +1 -1
  30. package/src/complex.test.ts +1 -1
  31. package/src/error-format.ts +22 -0
  32. package/src/human-hash.test.ts +1 -1
  33. package/src/index.ts +3 -1
  34. package/src/position.test.ts +2 -2
  35. package/src/safe-parse.ts +4 -3
  36. package/src/safe-stringify.ts +104 -0
  37. package/src/sort.test.ts +1 -1
  38. package/src/string.test.ts +1 -1
  39. package/src/string.ts +32 -6
  40. package/src/to-fallback.ts +5 -4
  41. package/src/tree.test.ts +1 -1
  42. package/src/types.ts +9 -1
  43. package/src/uint8array.test.ts +1 -1
  44. package/src/unit.test.ts +25 -0
  45. package/src/unit.ts +83 -0
  46. package/src/weak.test.ts +1 -1
  47. package/dist/types/src/first-two-chars.d.ts +0 -9
  48. package/dist/types/src/first-two-chars.d.ts.map +0 -1
  49. package/src/first-two-chars.ts +0 -44
@@ -103,10 +103,10 @@ function assumeType(value) {
103
103
  }
104
104
 
105
105
  // src/binder.ts
106
- import util from "@dxos/node-std/util";
106
+ import { promisify } from "@dxos/node-std/util";
107
107
  var createBinder = (obj) => ({
108
108
  fn: (fn) => fn.bind(obj),
109
- async: (fn) => util.promisify(fn.bind(obj))
109
+ async: (fn) => promisify(fn.bind(obj))
110
110
  });
111
111
 
112
112
  // src/bitfield.ts
@@ -207,6 +207,7 @@ var CallbackCollection = class {
207
207
  import { invariant as invariant2 } from "@dxos/invariant";
208
208
  var __dxlog_file2 = "/__w/dxos/dxos/packages/common/util/src/callback.ts";
209
209
  var Callback = class {
210
+ _callback;
210
211
  call(...args) {
211
212
  invariant2(this._callback, "Callback not set", {
212
213
  F: __dxlog_file2,
@@ -301,9 +302,10 @@ var chunkArray = (array, size) => {
301
302
  import { invariant as invariant3 } from "@dxos/invariant";
302
303
  var __dxlog_file3 = "/__w/dxos/dxos/packages/common/util/src/circular-buffer.ts";
303
304
  var CircularBuffer = class {
305
+ _buffer;
306
+ _nextIndex = 0;
307
+ _elementCount = 0;
304
308
  constructor(size) {
305
- this._nextIndex = 0;
306
- this._elementCount = 0;
307
309
  invariant3(size >= 1, void 0, {
308
310
  F: __dxlog_file3,
309
311
  L: 13,
@@ -374,10 +376,11 @@ import { inspect } from "@dxos/node-std/util";
374
376
  import { inspectObject, raise } from "@dxos/debug";
375
377
  var MAX_SERIALIZATION_LENGTH = 10;
376
378
  var ComplexSet = class {
379
+ _projection;
380
+ _values = /* @__PURE__ */ new Map();
377
381
  // prettier-ignore
378
382
  constructor(_projection, values) {
379
383
  this._projection = _projection;
380
- this._values = /* @__PURE__ */ new Map();
381
384
  if (values) {
382
385
  for (const value of values) {
383
386
  this.add(value);
@@ -467,11 +470,12 @@ var makeSet = (projection) => {
467
470
  };
468
471
  };
469
472
  var ComplexMap = class _ComplexMap {
473
+ _keyProjection;
474
+ _keys = /* @__PURE__ */ new Map();
475
+ _values = /* @__PURE__ */ new Map();
470
476
  // prettier-ignore
471
477
  constructor(_keyProjection, entries2) {
472
478
  this._keyProjection = _keyProjection;
473
- this._keys = /* @__PURE__ */ new Map();
474
- this._values = /* @__PURE__ */ new Map();
475
479
  if (entries2) {
476
480
  for (const [key, value] of entries2) {
477
481
  this.set(key, value);
@@ -592,13 +596,10 @@ var getDeep = (obj, path) => {
592
596
  // src/defer-function.ts
593
597
  var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
594
598
 
595
- // src/explicit-resource-management-polyfill.ts
596
- Symbol.dispose ??= Symbol("Symbol.dispose");
597
- Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
598
-
599
599
  // src/defer.ts
600
600
  var defer = (fn) => new DeferGuard(fn);
601
601
  var DeferGuard = class {
602
+ _fn;
602
603
  /**
603
604
  * @internal
604
605
  */
@@ -614,6 +615,7 @@ var DeferGuard = class {
614
615
  };
615
616
  var deferAsync = (fn) => new DeferAsyncGuard(fn);
616
617
  var DeferAsyncGuard = class {
618
+ _fn;
617
619
  /**
618
620
  * @internal
619
621
  */
@@ -628,6 +630,8 @@ var DeferAsyncGuard = class {
628
630
  // src/entry.ts
629
631
  var entry = (map, key) => new MapEntry(map, key);
630
632
  var MapEntry = class {
633
+ _map;
634
+ _key;
631
635
  /**
632
636
  * @internal
633
637
  */
@@ -653,33 +657,6 @@ var MapEntry = class {
653
657
  }
654
658
  };
655
659
 
656
- // src/first-two-chars.ts
657
- var renderableCharRegex = /^(?![\p{Control}\p{Mark}\p{Separator}\p{Surrogate}\p{Unassigned}\p{P}])[\p{L}\p{N}\p{S}\p{Emoji}]$/u;
658
- var getFirstTwoRenderableChars = (label) => {
659
- const characters = Array.from(label);
660
- const result = [
661
- "",
662
- ""
663
- ];
664
- let foundFirst = false;
665
- for (let i = 0; i < characters.length; i++) {
666
- const char = characters[i];
667
- if (renderableCharRegex.test(char)) {
668
- if (!foundFirst) {
669
- result[0] = char;
670
- foundFirst = true;
671
- } else {
672
- const textBetween = characters.slice(result[0].length, i).join("");
673
- if (/[^\p{L}\p{N}_]/u.test(textBetween)) {
674
- result[1] = char;
675
- break;
676
- }
677
- }
678
- }
679
- }
680
- return result;
681
- };
682
-
683
660
  // src/for-each-async.ts
684
661
  var forEachAsync = (items, fn) => Promise.all(items.map(fn));
685
662
 
@@ -944,6 +921,7 @@ var DEFAULT_WORDLIST = [
944
921
  "zulu"
945
922
  ];
946
923
  var HumanHasher = class {
924
+ wordlist;
947
925
  /**
948
926
  * Transforms hex digests to human-readable strings.
949
927
  *
@@ -1209,31 +1187,10 @@ var deepMapValues = (value, fn) => {
1209
1187
  return new DeepMapper(fn).map(value);
1210
1188
  };
1211
1189
  var DeepMapper = class {
1190
+ _fn;
1191
+ _cyclic = /* @__PURE__ */ new Map();
1212
1192
  constructor(_fn) {
1213
1193
  this._fn = _fn;
1214
- this._cyclic = /* @__PURE__ */ new Map();
1215
- this._recurse = (value) => {
1216
- if (this._cyclic.has(value)) {
1217
- return this._cyclic.get(value);
1218
- }
1219
- if (Array.isArray(value)) {
1220
- const res = new Array(value.length);
1221
- this._cyclic.set(value, res);
1222
- for (let i = 0; i < value.length; i++) {
1223
- res[i] = this._map(value[i], i);
1224
- }
1225
- return res;
1226
- } else if (value !== null && typeof value === "object") {
1227
- const res = {};
1228
- this._cyclic.set(value, res);
1229
- for (const key in value) {
1230
- res[key] = this._map(value[key], key);
1231
- }
1232
- return res;
1233
- } else {
1234
- return value;
1235
- }
1236
- };
1237
1194
  }
1238
1195
  map(value) {
1239
1196
  return this._map(value, void 0);
@@ -1244,36 +1201,37 @@ var DeepMapper = class {
1244
1201
  }
1245
1202
  return this._fn(value, this._recurse, key);
1246
1203
  }
1204
+ _recurse = (value) => {
1205
+ if (this._cyclic.has(value)) {
1206
+ return this._cyclic.get(value);
1207
+ }
1208
+ if (Array.isArray(value)) {
1209
+ const res = new Array(value.length);
1210
+ this._cyclic.set(value, res);
1211
+ for (let i = 0; i < value.length; i++) {
1212
+ res[i] = this._map(value[i], i);
1213
+ }
1214
+ return res;
1215
+ } else if (value !== null && typeof value === "object") {
1216
+ const res = {};
1217
+ this._cyclic.set(value, res);
1218
+ for (const key in value) {
1219
+ res[key] = this._map(value[key], key);
1220
+ }
1221
+ return res;
1222
+ } else {
1223
+ return value;
1224
+ }
1225
+ };
1247
1226
  };
1248
1227
  var deepMapValuesAsync = (value, fn) => {
1249
1228
  return new DeepMapperAsync(fn).map(value);
1250
1229
  };
1251
1230
  var DeepMapperAsync = class {
1231
+ _fn;
1232
+ _cyclic = /* @__PURE__ */ new Map();
1252
1233
  constructor(_fn) {
1253
1234
  this._fn = _fn;
1254
- this._cyclic = /* @__PURE__ */ new Map();
1255
- this._recurse = async (value) => {
1256
- if (this._cyclic.has(value)) {
1257
- return this._cyclic.get(value);
1258
- }
1259
- if (Array.isArray(value)) {
1260
- const res = new Array(value.length);
1261
- this._cyclic.set(value, res);
1262
- for (let i = 0; i < value.length; i++) {
1263
- res[i] = await this._map(value[i], i);
1264
- }
1265
- return res;
1266
- } else if (value !== null && typeof value === "object") {
1267
- const res = {};
1268
- this._cyclic.set(value, res);
1269
- for (const key in value) {
1270
- res[key] = await this._map(value[key], key);
1271
- }
1272
- return res;
1273
- } else {
1274
- return value;
1275
- }
1276
- };
1277
1235
  }
1278
1236
  map(value) {
1279
1237
  return this._map(value, void 0);
@@ -1284,6 +1242,28 @@ var DeepMapperAsync = class {
1284
1242
  }
1285
1243
  return this._fn(value, this._recurse, key);
1286
1244
  }
1245
+ _recurse = async (value) => {
1246
+ if (this._cyclic.has(value)) {
1247
+ return this._cyclic.get(value);
1248
+ }
1249
+ if (Array.isArray(value)) {
1250
+ const res = new Array(value.length);
1251
+ this._cyclic.set(value, res);
1252
+ for (let i = 0; i < value.length; i++) {
1253
+ res[i] = await this._map(value[i], i);
1254
+ }
1255
+ return res;
1256
+ } else if (value !== null && typeof value === "object") {
1257
+ const res = {};
1258
+ this._cyclic.set(value, res);
1259
+ for (const key in value) {
1260
+ res[key] = await this._map(value[key], key);
1261
+ }
1262
+ return res;
1263
+ } else {
1264
+ return value;
1265
+ }
1266
+ };
1287
1267
  };
1288
1268
  var visitValues = (object, visitor) => {
1289
1269
  if (Array.isArray(object)) {
@@ -1605,7 +1585,7 @@ var safeParseInt = (value, defaultValue) => {
1605
1585
  try {
1606
1586
  const n = parseInt(value ?? "");
1607
1587
  return isNaN(n) ? defaultValue : n;
1608
- } catch (err) {
1588
+ } catch {
1609
1589
  return defaultValue;
1610
1590
  }
1611
1591
  };
@@ -1620,18 +1600,87 @@ var safeParseJson = (data, defaultValue) => {
1620
1600
  if (data && data.length > 0) {
1621
1601
  try {
1622
1602
  return JSON.parse(data);
1623
- } catch (err) {
1603
+ } catch {
1624
1604
  }
1625
1605
  }
1626
1606
  return defaultValue;
1627
1607
  };
1628
1608
 
1609
+ // src/safe-stringify.ts
1610
+ var SKIP = Object.freeze({});
1611
+ function safeStringify(obj, filter = defaultFilter, indent = 2) {
1612
+ const seen = /* @__PURE__ */ new WeakSet();
1613
+ function replacer(key, value) {
1614
+ if (typeof value === "object" && value !== null) {
1615
+ if (seen.has(value)) {
1616
+ return "[Circular]";
1617
+ }
1618
+ seen.add(value);
1619
+ }
1620
+ if (filter) {
1621
+ const v2 = filter?.(key, value);
1622
+ if (v2 !== void 0) {
1623
+ return v2 === SKIP ? void 0 : v2;
1624
+ }
1625
+ }
1626
+ return value;
1627
+ }
1628
+ let result = "";
1629
+ try {
1630
+ result = JSON.stringify(obj, replacer, indent);
1631
+ } catch (error) {
1632
+ result = `Error: ${error.message}`;
1633
+ }
1634
+ return result;
1635
+ }
1636
+ var createReplacer = ({ omit: omit2, parse, maxDepth, maxArrayLen, maxStringLen } = {}) => {
1637
+ let currentDepth = 0;
1638
+ const depthMap = /* @__PURE__ */ new WeakMap();
1639
+ return function(key, value) {
1640
+ if (key === "") {
1641
+ currentDepth = 0;
1642
+ } else if (this && typeof this === "object") {
1643
+ const parentDepth = depthMap.get(this) ?? 0;
1644
+ currentDepth = parentDepth + 1;
1645
+ }
1646
+ if (typeof value === "function") {
1647
+ return void 0;
1648
+ }
1649
+ if (value && typeof value === "object") {
1650
+ depthMap.set(value, currentDepth);
1651
+ if (maxDepth != null && currentDepth >= maxDepth) {
1652
+ return Array.isArray(value) ? `[{ length: ${value.length} }]` : `{ keys: ${Object.keys(value).length} }`;
1653
+ }
1654
+ }
1655
+ if (omit2?.includes(key)) {
1656
+ return void 0;
1657
+ }
1658
+ if (parse?.includes(key) && typeof value === "string") {
1659
+ try {
1660
+ return JSON.parse(value);
1661
+ } catch {
1662
+ return value;
1663
+ }
1664
+ }
1665
+ if (maxArrayLen != null && Array.isArray(value) && value.length > maxArrayLen) {
1666
+ return `[length: ${value.length}]`;
1667
+ }
1668
+ if (maxStringLen != null && typeof value === "string" && value.length > maxStringLen) {
1669
+ return value.slice(0, maxStringLen) + "...";
1670
+ }
1671
+ return value;
1672
+ };
1673
+ };
1674
+ var defaultFilter = createReplacer();
1675
+
1629
1676
  // src/sliding-window-summary.ts
1630
1677
  import { invariant as invariant5 } from "@dxos/invariant";
1631
1678
  var __dxlog_file5 = "/__w/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
1632
1679
  var SlidingWindowSummary = class {
1680
+ _buffer;
1681
+ _sum = 0;
1682
+ _precision;
1633
1683
  constructor(options) {
1634
- this._sum = 0;
1635
1684
  this._buffer = new CircularBuffer(options.dataPoints);
1636
1685
  if (options.precision != null) {
1637
1686
  invariant5(options.precision >= 0, void 0, {
@@ -1711,12 +1760,24 @@ var capitalize = (str) => {
1711
1760
  }
1712
1761
  return str.charAt(0).toUpperCase() + str.slice(1);
1713
1762
  };
1714
- var trim = (strings, ...values) => {
1715
- const full = String.raw(strings, ...values);
1716
- const lines = full.replace(/^\n/, "").split("\n");
1717
- const indent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^ */)[0].length));
1718
- return lines.map((l) => l.slice(indent)).join("\n");
1719
- };
1763
+ function trim(strings, ...values) {
1764
+ const raw = strings.reduce((out, str, i) => {
1765
+ out += str;
1766
+ if (i < values.length) {
1767
+ const match = str.match(/(^|\n)([ \t]*)$/);
1768
+ const baseIndent = match ? match[2] : "";
1769
+ const val = String(values[i]).replace(/\r?\n/g, "\n" + baseIndent);
1770
+ out += val;
1771
+ }
1772
+ return out;
1773
+ }, "");
1774
+ const lines = raw.split("\n");
1775
+ while (lines.length && !lines[0].trim()) lines.shift();
1776
+ while (lines.length && !lines[lines.length - 1].trim()) lines.pop();
1777
+ const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
1778
+ return lines.map((l) => l.slice(minIndent)).join("\n");
1779
+ }
1780
+ var kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
1720
1781
 
1721
1782
  // src/sum.ts
1722
1783
  var sum = (values) => values.reduce((a, b) => a + b, 0);
@@ -1915,10 +1976,8 @@ var toFallback = (hash) => {
1915
1976
 
1916
1977
  // src/tracer.ts
1917
1978
  var Tracer = class {
1918
- constructor() {
1919
- this._events = /* @__PURE__ */ new Map();
1920
- this._recording = false;
1921
- }
1979
+ _events = /* @__PURE__ */ new Map();
1980
+ _recording = false;
1922
1981
  // TODO(burdon): Start/stop methods for recording data? By id?
1923
1982
  // Alternatively, enable subscriptions to track/compute series.
1924
1983
  // TODO(burdon): Hierarchical traces?
@@ -2019,7 +2078,7 @@ var stringifyTree = (node, ancestors = [], rows = []) => {
2019
2078
  };
2020
2079
 
2021
2080
  // src/types.ts
2022
- var isNotFalsy = (value) => !!value;
2081
+ var isTruthy = (value) => !!value;
2023
2082
  var isNonNullable = (value) => value != null;
2024
2083
  var doAsync = async (fn) => fn();
2025
2084
  var getProviderValue = (provider, arg) => {
@@ -2050,6 +2109,107 @@ var arrayMove = (array, from, to) => {
2050
2109
  return array;
2051
2110
  };
2052
2111
 
2112
+ // src/unit.ts
2113
+ var createFormat = (unit) => {
2114
+ return (n, precision = unit.precision ?? 0) => {
2115
+ const value = n / unit.quotient;
2116
+ return {
2117
+ unit,
2118
+ value,
2119
+ formattedValue: value.toFixed(precision),
2120
+ toString: () => `${value.toFixed(precision)}${unit.symbol}`
2121
+ };
2122
+ };
2123
+ };
2124
+ var MS_SECONDS = 1e3;
2125
+ var MS_MINUTES = 60 * MS_SECONDS;
2126
+ var MS_HOURS = 60 * MS_MINUTES;
2127
+ var Unit = {
2128
+ // General.
2129
+ Percent: createFormat({
2130
+ symbol: "%",
2131
+ quotient: 1 / 100,
2132
+ precision: 2
2133
+ }),
2134
+ Thousand: createFormat({
2135
+ symbol: "k",
2136
+ quotient: 1e3,
2137
+ precision: 2
2138
+ }),
2139
+ // Bytes (note KB vs KiB).
2140
+ Gigabyte: createFormat({
2141
+ symbol: "GB",
2142
+ quotient: 1e3 * 1e3 * 1e3,
2143
+ precision: 2
2144
+ }),
2145
+ Megabyte: createFormat({
2146
+ symbol: "MB",
2147
+ quotient: 1e3 * 1e3,
2148
+ precision: 2
2149
+ }),
2150
+ Kilobyte: createFormat({
2151
+ symbol: "KB",
2152
+ quotient: 1e3,
2153
+ precision: 2
2154
+ }),
2155
+ Byte: createFormat({
2156
+ symbol: "B",
2157
+ quotient: 1
2158
+ }),
2159
+ // Time.
2160
+ Hour: createFormat({
2161
+ symbol: "h",
2162
+ quotient: MS_HOURS
2163
+ }),
2164
+ Minute: createFormat({
2165
+ symbol: "m",
2166
+ quotient: MS_MINUTES
2167
+ }),
2168
+ Second: createFormat({
2169
+ symbol: "s",
2170
+ quotient: MS_SECONDS,
2171
+ precision: 1
2172
+ }),
2173
+ Millisecond: createFormat({
2174
+ symbol: "ms",
2175
+ quotient: 1
2176
+ }),
2177
+ Duration: (n) => {
2178
+ const hours = Math.floor(n / MS_HOURS);
2179
+ const minutes = Math.floor(n % MS_HOURS / MS_MINUTES);
2180
+ if (hours) {
2181
+ const formattedValue = minutes ? `${hours}h ${minutes}m` : `${hours}h`;
2182
+ return {
2183
+ unit: {
2184
+ symbol: "h",
2185
+ quotient: MS_HOURS
2186
+ },
2187
+ value: hours,
2188
+ formattedValue,
2189
+ toString: () => formattedValue
2190
+ };
2191
+ }
2192
+ if (minutes) {
2193
+ const seconds2 = (n - MS_MINUTES * minutes) / MS_SECONDS;
2194
+ const formattedValue = seconds2 ? `${minutes}m ${seconds2}s` : `${minutes}m`;
2195
+ return {
2196
+ unit: {
2197
+ symbol: "m",
2198
+ quotient: MS_MINUTES
2199
+ },
2200
+ value: minutes,
2201
+ formattedValue,
2202
+ toString: () => formattedValue
2203
+ };
2204
+ }
2205
+ const seconds = n >= MS_SECONDS;
2206
+ if (seconds) {
2207
+ return Unit.Second(n);
2208
+ }
2209
+ return Unit.Millisecond(n);
2210
+ }
2211
+ };
2212
+
2053
2213
  // src/url.ts
2054
2214
  var createUrl = (url, search) => {
2055
2215
  const base = typeof url === "string" ? new URL(url) : url;
@@ -2061,11 +2221,11 @@ var createUrl = (url, search) => {
2061
2221
 
2062
2222
  // src/weak.ts
2063
2223
  var WeakDictionary = class {
2224
+ _internal = /* @__PURE__ */ new Map();
2225
+ _finalization = new FinalizationRegistry((cleanUpCallback) => {
2226
+ cleanUpCallback();
2227
+ });
2064
2228
  constructor(entries2) {
2065
- this._internal = /* @__PURE__ */ new Map();
2066
- this._finalization = new FinalizationRegistry((cleanUpCallback) => {
2067
- cleanUpCallback();
2068
- });
2069
2229
  this._internal = new Map(entries2?.map(([key, value]) => [
2070
2230
  key,
2071
2231
  new WeakRef(value)
@@ -2153,6 +2313,21 @@ var WeakDictionary = class {
2153
2313
  this._finalization.unregister(value);
2154
2314
  }
2155
2315
  };
2316
+
2317
+ // src/error-format.ts
2318
+ var formatErrorWithCauses = (error) => {
2319
+ const lines = [];
2320
+ let current = error;
2321
+ let level = 0;
2322
+ while (current) {
2323
+ const prefix = level === 0 ? "" : `Caused by: `;
2324
+ lines.push(prefix + (current.stack ?? String(current)));
2325
+ if (!(current.cause instanceof Error)) break;
2326
+ current = current.cause;
2327
+ level += 1;
2328
+ }
2329
+ return lines.join("\n\n");
2330
+ };
2156
2331
  export {
2157
2332
  BitField,
2158
2333
  Callback,
@@ -2162,8 +2337,10 @@ export {
2162
2337
  ComplexSet,
2163
2338
  HumanHasher,
2164
2339
  MapEntry,
2340
+ SKIP,
2165
2341
  SlidingWindowSummary,
2166
2342
  Tracer,
2343
+ Unit,
2167
2344
  WeakDictionary,
2168
2345
  accessBy,
2169
2346
  arrayMove,
@@ -2185,11 +2362,13 @@ export {
2185
2362
  createBinder,
2186
2363
  createBucketReducer,
2187
2364
  createGroupReducer,
2365
+ createReplacer,
2188
2366
  createSetDispatch,
2189
2367
  createUrl,
2190
2368
  decamelize,
2191
2369
  deepMapValues,
2192
2370
  deepMapValuesAsync,
2371
+ defaultFilter,
2193
2372
  defaultMap,
2194
2373
  defer,
2195
2374
  deferAsync,
@@ -2201,12 +2380,12 @@ export {
2201
2380
  entry,
2202
2381
  exponentialBackoffInterval,
2203
2382
  forEachAsync,
2383
+ formatErrorWithCauses,
2204
2384
  get,
2205
2385
  getAsyncProviderValue,
2206
2386
  getDate,
2207
2387
  getDebugName,
2208
2388
  getDeep,
2209
- getFirstTwoRenderableChars,
2210
2389
  getHostPlatform,
2211
2390
  getPrototypeSpecificInstanceId,
2212
2391
  getProviderValue,
@@ -2224,12 +2403,13 @@ export {
2224
2403
  iosCheck,
2225
2404
  isNode,
2226
2405
  isNonNullable,
2227
- isNotFalsy,
2406
+ isTruthy,
2228
2407
  joinTables,
2229
2408
  jsonKeyReplacer,
2230
2409
  jsonReplacer,
2231
2410
  jsonify,
2232
2411
  jsonlogify,
2412
+ kebabize,
2233
2413
  keyToEmoji,
2234
2414
  keyToFallback,
2235
2415
  keyToHue,
@@ -2260,6 +2440,7 @@ export {
2260
2440
  safeParseFloat,
2261
2441
  safeParseInt,
2262
2442
  safeParseJson,
2443
+ safeStringify,
2263
2444
  set,
2264
2445
  setDeep,
2265
2446
  sortKeys,