@dxos/util 0.8.4-main.e098934 → 0.8.4-main.e8ec1fe
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.
- package/dist/lib/browser/index.mjs +325 -447
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +325 -447
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/di-key.d.ts +3 -3
- package/dist/types/src/di-key.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/safe-stringify.d.ts +13 -0
- package/dist/types/src/safe-stringify.d.ts.map +1 -0
- package/dist/types/src/string.d.ts +4 -0
- package/dist/types/src/string.d.ts.map +1 -1
- package/dist/types/src/to-fallback.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +1 -2
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/unit.d.ts +12 -13
- package/dist/types/src/unit.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/binder.ts +2 -2
- package/src/index.ts +1 -1
- package/src/safe-stringify.ts +104 -0
- package/src/string.ts +7 -0
- package/src/to-fallback.ts +5 -4
- package/src/types.ts +1 -2
- package/src/unit.test.ts +1 -1
- package/src/unit.ts +58 -28
- package/dist/types/src/first-two-chars.d.ts +0 -9
- package/dist/types/src/first-two-chars.d.ts.map +0 -1
- 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
|
|
106
|
+
import { promisify } from "@dxos/node-std/util";
|
|
107
107
|
var createBinder = (obj) => ({
|
|
108
108
|
fn: (fn) => fn.bind(obj),
|
|
109
|
-
async: (fn) =>
|
|
109
|
+
async: (fn) => promisify(fn.bind(obj))
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
// src/bitfield.ts
|
|
@@ -180,92 +180,34 @@ var BitField = class _BitField {
|
|
|
180
180
|
};
|
|
181
181
|
|
|
182
182
|
// src/callback-collection.ts
|
|
183
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
184
|
-
if (privateCollection.has(obj)) {
|
|
185
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function _class_apply_descriptor_get(receiver, descriptor) {
|
|
189
|
-
if (descriptor.get) {
|
|
190
|
-
return descriptor.get.call(receiver);
|
|
191
|
-
}
|
|
192
|
-
return descriptor.value;
|
|
193
|
-
}
|
|
194
|
-
function _class_apply_descriptor_set(receiver, descriptor, value) {
|
|
195
|
-
if (descriptor.set) {
|
|
196
|
-
descriptor.set.call(receiver, value);
|
|
197
|
-
} else {
|
|
198
|
-
if (!descriptor.writable) {
|
|
199
|
-
throw new TypeError("attempted to set read only private field");
|
|
200
|
-
}
|
|
201
|
-
descriptor.value = value;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function _class_extract_field_descriptor(receiver, privateMap, action) {
|
|
205
|
-
if (!privateMap.has(receiver)) {
|
|
206
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
207
|
-
}
|
|
208
|
-
return privateMap.get(receiver);
|
|
209
|
-
}
|
|
210
|
-
function _class_private_field_get(receiver, privateMap) {
|
|
211
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
|
|
212
|
-
return _class_apply_descriptor_get(receiver, descriptor);
|
|
213
|
-
}
|
|
214
|
-
function _class_private_field_init(obj, privateMap, value) {
|
|
215
|
-
_check_private_redeclaration(obj, privateMap);
|
|
216
|
-
privateMap.set(obj, value);
|
|
217
|
-
}
|
|
218
|
-
function _class_private_field_set(receiver, privateMap, value) {
|
|
219
|
-
var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
|
|
220
|
-
_class_apply_descriptor_set(receiver, descriptor, value);
|
|
221
|
-
return value;
|
|
222
|
-
}
|
|
223
|
-
var _callbacks = /* @__PURE__ */ new WeakMap();
|
|
224
183
|
var CallbackCollection = class {
|
|
184
|
+
#callbacks = [];
|
|
225
185
|
append(callback) {
|
|
226
|
-
|
|
186
|
+
this.#callbacks.push(callback);
|
|
227
187
|
}
|
|
228
188
|
prepend(callback) {
|
|
229
|
-
|
|
189
|
+
this.#callbacks.unshift(callback);
|
|
230
190
|
}
|
|
231
191
|
remove(callback) {
|
|
232
|
-
|
|
192
|
+
this.#callbacks = this.#callbacks.filter((c) => c !== callback);
|
|
233
193
|
}
|
|
234
194
|
callParallel(...args) {
|
|
235
|
-
return Promise.all(
|
|
195
|
+
return Promise.all(this.#callbacks.map((callback) => callback(...args)));
|
|
236
196
|
}
|
|
237
197
|
async callSerial(...args) {
|
|
238
198
|
const results = [];
|
|
239
|
-
for (const callback of
|
|
199
|
+
for (const callback of this.#callbacks) {
|
|
240
200
|
results.push(await callback(...args));
|
|
241
201
|
}
|
|
242
202
|
return results;
|
|
243
203
|
}
|
|
244
|
-
constructor() {
|
|
245
|
-
_class_private_field_init(this, _callbacks, {
|
|
246
|
-
writable: true,
|
|
247
|
-
value: []
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
204
|
};
|
|
251
205
|
|
|
252
206
|
// src/callback.ts
|
|
253
207
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
254
|
-
function _define_property(obj, key, value) {
|
|
255
|
-
if (key in obj) {
|
|
256
|
-
Object.defineProperty(obj, key, {
|
|
257
|
-
value,
|
|
258
|
-
enumerable: true,
|
|
259
|
-
configurable: true,
|
|
260
|
-
writable: true
|
|
261
|
-
});
|
|
262
|
-
} else {
|
|
263
|
-
obj[key] = value;
|
|
264
|
-
}
|
|
265
|
-
return obj;
|
|
266
|
-
}
|
|
267
208
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/util/src/callback.ts";
|
|
268
209
|
var Callback = class {
|
|
210
|
+
_callback;
|
|
269
211
|
call(...args) {
|
|
270
212
|
invariant2(this._callback, "Callback not set", {
|
|
271
213
|
F: __dxlog_file2,
|
|
@@ -296,9 +238,6 @@ var Callback = class {
|
|
|
296
238
|
isSet() {
|
|
297
239
|
return !!this._callback;
|
|
298
240
|
}
|
|
299
|
-
constructor() {
|
|
300
|
-
_define_property(this, "_callback", void 0);
|
|
301
|
-
}
|
|
302
241
|
};
|
|
303
242
|
var createSetDispatch = ({ handlers }) => {
|
|
304
243
|
return new Proxy({
|
|
@@ -361,21 +300,23 @@ var chunkArray = (array, size) => {
|
|
|
361
300
|
|
|
362
301
|
// src/circular-buffer.ts
|
|
363
302
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
364
|
-
function _define_property2(obj, key, value) {
|
|
365
|
-
if (key in obj) {
|
|
366
|
-
Object.defineProperty(obj, key, {
|
|
367
|
-
value,
|
|
368
|
-
enumerable: true,
|
|
369
|
-
configurable: true,
|
|
370
|
-
writable: true
|
|
371
|
-
});
|
|
372
|
-
} else {
|
|
373
|
-
obj[key] = value;
|
|
374
|
-
}
|
|
375
|
-
return obj;
|
|
376
|
-
}
|
|
377
303
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/util/src/circular-buffer.ts";
|
|
378
304
|
var CircularBuffer = class {
|
|
305
|
+
_buffer;
|
|
306
|
+
_nextIndex = 0;
|
|
307
|
+
_elementCount = 0;
|
|
308
|
+
constructor(size) {
|
|
309
|
+
invariant3(size >= 1, void 0, {
|
|
310
|
+
F: __dxlog_file3,
|
|
311
|
+
L: 13,
|
|
312
|
+
S: this,
|
|
313
|
+
A: [
|
|
314
|
+
"size >= 1",
|
|
315
|
+
""
|
|
316
|
+
]
|
|
317
|
+
});
|
|
318
|
+
this._buffer = new Array(size);
|
|
319
|
+
}
|
|
379
320
|
push(element) {
|
|
380
321
|
const evicted = this._elementCount === this._buffer.length ? this._buffer[this._nextIndex] : void 0;
|
|
381
322
|
this._buffer[this._nextIndex] = element;
|
|
@@ -415,21 +356,6 @@ var CircularBuffer = class {
|
|
|
415
356
|
yield this._buffer[i];
|
|
416
357
|
}
|
|
417
358
|
}
|
|
418
|
-
constructor(size) {
|
|
419
|
-
_define_property2(this, "_buffer", void 0);
|
|
420
|
-
_define_property2(this, "_nextIndex", 0);
|
|
421
|
-
_define_property2(this, "_elementCount", 0);
|
|
422
|
-
invariant3(size >= 1, void 0, {
|
|
423
|
-
F: __dxlog_file3,
|
|
424
|
-
L: 13,
|
|
425
|
-
S: this,
|
|
426
|
-
A: [
|
|
427
|
-
"size >= 1",
|
|
428
|
-
""
|
|
429
|
-
]
|
|
430
|
-
});
|
|
431
|
-
this._buffer = new Array(size);
|
|
432
|
-
}
|
|
433
359
|
};
|
|
434
360
|
|
|
435
361
|
// src/clear-undefined.ts
|
|
@@ -448,22 +374,19 @@ var clearUndefined = (obj) => {
|
|
|
448
374
|
// src/complex.ts
|
|
449
375
|
import { inspect } from "@dxos/node-std/util";
|
|
450
376
|
import { inspectObject, raise } from "@dxos/debug";
|
|
451
|
-
function _define_property3(obj, key, value) {
|
|
452
|
-
if (key in obj) {
|
|
453
|
-
Object.defineProperty(obj, key, {
|
|
454
|
-
value,
|
|
455
|
-
enumerable: true,
|
|
456
|
-
configurable: true,
|
|
457
|
-
writable: true
|
|
458
|
-
});
|
|
459
|
-
} else {
|
|
460
|
-
obj[key] = value;
|
|
461
|
-
}
|
|
462
|
-
return obj;
|
|
463
|
-
}
|
|
464
377
|
var MAX_SERIALIZATION_LENGTH = 10;
|
|
465
|
-
var _inspect_custom = inspect.custom;
|
|
466
378
|
var ComplexSet = class {
|
|
379
|
+
_projection;
|
|
380
|
+
_values = /* @__PURE__ */ new Map();
|
|
381
|
+
// prettier-ignore
|
|
382
|
+
constructor(_projection, values) {
|
|
383
|
+
this._projection = _projection;
|
|
384
|
+
if (values) {
|
|
385
|
+
for (const value of values) {
|
|
386
|
+
this.add(value);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
467
390
|
toString() {
|
|
468
391
|
return inspectObject(this);
|
|
469
392
|
}
|
|
@@ -472,7 +395,7 @@ var ComplexSet = class {
|
|
|
472
395
|
size: this._values.size
|
|
473
396
|
} : Array.from(this._values.values());
|
|
474
397
|
}
|
|
475
|
-
[
|
|
398
|
+
[inspect.custom]() {
|
|
476
399
|
return inspectObject(this);
|
|
477
400
|
}
|
|
478
401
|
add(value) {
|
|
@@ -538,18 +461,6 @@ var ComplexSet = class {
|
|
|
538
461
|
isDisjointFrom(other) {
|
|
539
462
|
throw new Error("Method not implemented.");
|
|
540
463
|
}
|
|
541
|
-
// prettier-ignore
|
|
542
|
-
constructor(_projection, values) {
|
|
543
|
-
_define_property3(this, "_projection", void 0);
|
|
544
|
-
_define_property3(this, "_values", void 0);
|
|
545
|
-
this._projection = _projection;
|
|
546
|
-
this._values = /* @__PURE__ */ new Map();
|
|
547
|
-
if (values) {
|
|
548
|
-
for (const value of values) {
|
|
549
|
-
this.add(value);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
464
|
};
|
|
554
465
|
var makeSet = (projection) => {
|
|
555
466
|
return class BoundComplexSet extends ComplexSet {
|
|
@@ -558,8 +469,19 @@ var makeSet = (projection) => {
|
|
|
558
469
|
}
|
|
559
470
|
};
|
|
560
471
|
};
|
|
561
|
-
var _inspect_custom1 = inspect.custom;
|
|
562
472
|
var ComplexMap = class _ComplexMap {
|
|
473
|
+
_keyProjection;
|
|
474
|
+
_keys = /* @__PURE__ */ new Map();
|
|
475
|
+
_values = /* @__PURE__ */ new Map();
|
|
476
|
+
// prettier-ignore
|
|
477
|
+
constructor(_keyProjection, entries2) {
|
|
478
|
+
this._keyProjection = _keyProjection;
|
|
479
|
+
if (entries2) {
|
|
480
|
+
for (const [key, value] of entries2) {
|
|
481
|
+
this.set(key, value);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
563
485
|
toString() {
|
|
564
486
|
return inspectObject(this);
|
|
565
487
|
}
|
|
@@ -568,7 +490,7 @@ var ComplexMap = class _ComplexMap {
|
|
|
568
490
|
size: this._values.size
|
|
569
491
|
} : Array.from(this._values.values());
|
|
570
492
|
}
|
|
571
|
-
[
|
|
493
|
+
[inspect.custom]() {
|
|
572
494
|
return inspectObject(this);
|
|
573
495
|
}
|
|
574
496
|
clear() {
|
|
@@ -630,28 +552,11 @@ var ComplexMap = class _ComplexMap {
|
|
|
630
552
|
get [Symbol.toStringTag]() {
|
|
631
553
|
return "ComplexMap";
|
|
632
554
|
}
|
|
633
|
-
// prettier-ignore
|
|
634
|
-
constructor(_keyProjection, entries2) {
|
|
635
|
-
_define_property3(this, "_keyProjection", void 0);
|
|
636
|
-
_define_property3(this, "_keys", void 0);
|
|
637
|
-
_define_property3(this, "_values", void 0);
|
|
638
|
-
this._keyProjection = _keyProjection;
|
|
639
|
-
this._keys = /* @__PURE__ */ new Map();
|
|
640
|
-
this._values = /* @__PURE__ */ new Map();
|
|
641
|
-
if (entries2) {
|
|
642
|
-
for (const [key, value] of entries2) {
|
|
643
|
-
this.set(key, value);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
555
|
};
|
|
648
|
-
var makeMap = (keyProjection) => {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
super(keyProjection, entries2);
|
|
652
|
-
}
|
|
556
|
+
var makeMap = (keyProjection) => class BoundComplexMap extends ComplexMap {
|
|
557
|
+
constructor(entries2) {
|
|
558
|
+
super(keyProjection, entries2);
|
|
653
559
|
}
|
|
654
|
-
return BoundComplexMap;
|
|
655
560
|
};
|
|
656
561
|
|
|
657
562
|
// src/deep.ts
|
|
@@ -691,72 +596,50 @@ var getDeep = (obj, path) => {
|
|
|
691
596
|
// src/defer-function.ts
|
|
692
597
|
var deferFunction = (fnProvider) => (...args) => fnProvider()(...args);
|
|
693
598
|
|
|
694
|
-
// src/explicit-resource-management-polyfill.ts
|
|
695
|
-
var _Symbol;
|
|
696
|
-
var _Symbol1;
|
|
697
|
-
(_Symbol = Symbol).dispose ?? (_Symbol.dispose = Symbol("Symbol.dispose"));
|
|
698
|
-
(_Symbol1 = Symbol).asyncDispose ?? (_Symbol1.asyncDispose = Symbol("Symbol.asyncDispose"));
|
|
699
|
-
|
|
700
599
|
// src/defer.ts
|
|
701
|
-
function _define_property4(obj, key, value) {
|
|
702
|
-
if (key in obj) {
|
|
703
|
-
Object.defineProperty(obj, key, {
|
|
704
|
-
value,
|
|
705
|
-
enumerable: true,
|
|
706
|
-
configurable: true,
|
|
707
|
-
writable: true
|
|
708
|
-
});
|
|
709
|
-
} else {
|
|
710
|
-
obj[key] = value;
|
|
711
|
-
}
|
|
712
|
-
return obj;
|
|
713
|
-
}
|
|
714
600
|
var defer = (fn) => new DeferGuard(fn);
|
|
715
601
|
var DeferGuard = class {
|
|
716
|
-
|
|
717
|
-
const result = this._fn();
|
|
718
|
-
if (result instanceof Promise) {
|
|
719
|
-
throw new Error("Async functions in defer are not supported. Use deferAsync instead.");
|
|
720
|
-
}
|
|
721
|
-
}
|
|
602
|
+
_fn;
|
|
722
603
|
/**
|
|
723
604
|
* @internal
|
|
724
605
|
*/
|
|
725
606
|
constructor(_fn) {
|
|
726
|
-
_define_property4(this, "_fn", void 0);
|
|
727
607
|
this._fn = _fn;
|
|
728
608
|
}
|
|
609
|
+
[Symbol.dispose]() {
|
|
610
|
+
const result = this._fn();
|
|
611
|
+
if (result instanceof Promise) {
|
|
612
|
+
throw new Error("Async functions in defer are not supported. Use deferAsync instead.");
|
|
613
|
+
}
|
|
614
|
+
}
|
|
729
615
|
};
|
|
730
616
|
var deferAsync = (fn) => new DeferAsyncGuard(fn);
|
|
731
617
|
var DeferAsyncGuard = class {
|
|
732
|
-
|
|
733
|
-
await this._fn();
|
|
734
|
-
}
|
|
618
|
+
_fn;
|
|
735
619
|
/**
|
|
736
620
|
* @internal
|
|
737
621
|
*/
|
|
738
622
|
constructor(_fn) {
|
|
739
|
-
_define_property4(this, "_fn", void 0);
|
|
740
623
|
this._fn = _fn;
|
|
741
624
|
}
|
|
625
|
+
async [Symbol.asyncDispose]() {
|
|
626
|
+
await this._fn();
|
|
627
|
+
}
|
|
742
628
|
};
|
|
743
629
|
|
|
744
630
|
// src/entry.ts
|
|
745
|
-
function _define_property5(obj, key, value) {
|
|
746
|
-
if (key in obj) {
|
|
747
|
-
Object.defineProperty(obj, key, {
|
|
748
|
-
value,
|
|
749
|
-
enumerable: true,
|
|
750
|
-
configurable: true,
|
|
751
|
-
writable: true
|
|
752
|
-
});
|
|
753
|
-
} else {
|
|
754
|
-
obj[key] = value;
|
|
755
|
-
}
|
|
756
|
-
return obj;
|
|
757
|
-
}
|
|
758
631
|
var entry = (map, key) => new MapEntry(map, key);
|
|
759
632
|
var MapEntry = class {
|
|
633
|
+
_map;
|
|
634
|
+
_key;
|
|
635
|
+
/**
|
|
636
|
+
* @internal
|
|
637
|
+
*/
|
|
638
|
+
// prettier-ignore
|
|
639
|
+
constructor(_map, _key) {
|
|
640
|
+
this._map = _map;
|
|
641
|
+
this._key = _key;
|
|
642
|
+
}
|
|
760
643
|
get key() {
|
|
761
644
|
return this._key;
|
|
762
645
|
}
|
|
@@ -772,43 +655,6 @@ var MapEntry = class {
|
|
|
772
655
|
deep(key) {
|
|
773
656
|
return entry(this.value, key);
|
|
774
657
|
}
|
|
775
|
-
/**
|
|
776
|
-
* @internal
|
|
777
|
-
*/
|
|
778
|
-
// prettier-ignore
|
|
779
|
-
constructor(_map, _key) {
|
|
780
|
-
_define_property5(this, "_map", void 0);
|
|
781
|
-
_define_property5(this, "_key", void 0);
|
|
782
|
-
this._map = _map;
|
|
783
|
-
this._key = _key;
|
|
784
|
-
}
|
|
785
|
-
};
|
|
786
|
-
|
|
787
|
-
// src/first-two-chars.ts
|
|
788
|
-
var renderableCharRegex = /^(?![\p{Control}\p{Mark}\p{Separator}\p{Surrogate}\p{Unassigned}\p{P}])[\p{L}\p{N}\p{S}\p{Emoji}]$/u;
|
|
789
|
-
var getFirstTwoRenderableChars = (label) => {
|
|
790
|
-
const characters = Array.from(label);
|
|
791
|
-
const result = [
|
|
792
|
-
"",
|
|
793
|
-
""
|
|
794
|
-
];
|
|
795
|
-
let foundFirst = false;
|
|
796
|
-
for (let i = 0; i < characters.length; i++) {
|
|
797
|
-
const char = characters[i];
|
|
798
|
-
if (renderableCharRegex.test(char)) {
|
|
799
|
-
if (!foundFirst) {
|
|
800
|
-
result[0] = char;
|
|
801
|
-
foundFirst = true;
|
|
802
|
-
} else {
|
|
803
|
-
const textBetween = characters.slice(result[0].length, i).join("");
|
|
804
|
-
if (/[^\p{L}\p{N}_]/u.test(textBetween)) {
|
|
805
|
-
result[1] = char;
|
|
806
|
-
break;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
return result;
|
|
812
658
|
};
|
|
813
659
|
|
|
814
660
|
// src/for-each-async.ts
|
|
@@ -816,19 +662,6 @@ var forEachAsync = (items, fn) => Promise.all(items.map(fn));
|
|
|
816
662
|
|
|
817
663
|
// src/human-hash.ts
|
|
818
664
|
import { PublicKey } from "@dxos/keys";
|
|
819
|
-
function _define_property6(obj, key, value) {
|
|
820
|
-
if (key in obj) {
|
|
821
|
-
Object.defineProperty(obj, key, {
|
|
822
|
-
value,
|
|
823
|
-
enumerable: true,
|
|
824
|
-
configurable: true,
|
|
825
|
-
writable: true
|
|
826
|
-
});
|
|
827
|
-
} else {
|
|
828
|
-
obj[key] = value;
|
|
829
|
-
}
|
|
830
|
-
return obj;
|
|
831
|
-
}
|
|
832
665
|
var DEFAULT_WORDLIST = [
|
|
833
666
|
"ack",
|
|
834
667
|
"alabama",
|
|
@@ -1088,6 +921,27 @@ var DEFAULT_WORDLIST = [
|
|
|
1088
921
|
"zulu"
|
|
1089
922
|
];
|
|
1090
923
|
var HumanHasher = class {
|
|
924
|
+
wordlist;
|
|
925
|
+
/**
|
|
926
|
+
* Transforms hex digests to human-readable strings.
|
|
927
|
+
*
|
|
928
|
+
* The format of these strings will look something like:
|
|
929
|
+
* `victor-bacon-zulu-lima`. The output is obtained by compressing the input
|
|
930
|
+
* digest to a fixed number of bytes, then mapping those bytes to one of 256
|
|
931
|
+
* words. A default wordlist is provided, but you can override this if you
|
|
932
|
+
* prefer.
|
|
933
|
+
* As long as you use the same wordlist, the output will be consistent (i.e.
|
|
934
|
+
* the same digest will always render the same representation).
|
|
935
|
+
*
|
|
936
|
+
* @param wordlist A list of exactly 256 words to choose from
|
|
937
|
+
*/
|
|
938
|
+
constructor(wordlist = DEFAULT_WORDLIST) {
|
|
939
|
+
this.wordlist = wordlist;
|
|
940
|
+
if (wordlist.length !== 256) {
|
|
941
|
+
throw new Error("Wordlist must have exactly 256 items");
|
|
942
|
+
}
|
|
943
|
+
this.wordlist = wordlist;
|
|
944
|
+
}
|
|
1091
945
|
/**
|
|
1092
946
|
* Humanize a given hexadecimal digest.
|
|
1093
947
|
*
|
|
@@ -1127,27 +981,6 @@ var HumanHasher = class {
|
|
|
1127
981
|
const checksums = segments.map((x) => x.reduce((acc, curr) => acc ^ curr));
|
|
1128
982
|
return checksums;
|
|
1129
983
|
}
|
|
1130
|
-
/**
|
|
1131
|
-
* Transforms hex digests to human-readable strings.
|
|
1132
|
-
*
|
|
1133
|
-
* The format of these strings will look something like:
|
|
1134
|
-
* `victor-bacon-zulu-lima`. The output is obtained by compressing the input
|
|
1135
|
-
* digest to a fixed number of bytes, then mapping those bytes to one of 256
|
|
1136
|
-
* words. A default wordlist is provided, but you can override this if you
|
|
1137
|
-
* prefer.
|
|
1138
|
-
* As long as you use the same wordlist, the output will be consistent (i.e.
|
|
1139
|
-
* the same digest will always render the same representation).
|
|
1140
|
-
*
|
|
1141
|
-
* @param wordlist A list of exactly 256 words to choose from
|
|
1142
|
-
*/
|
|
1143
|
-
constructor(wordlist = DEFAULT_WORDLIST) {
|
|
1144
|
-
_define_property6(this, "wordlist", void 0);
|
|
1145
|
-
this.wordlist = wordlist;
|
|
1146
|
-
if (wordlist.length !== 256) {
|
|
1147
|
-
throw new Error("Wordlist must have exactly 256 items");
|
|
1148
|
-
}
|
|
1149
|
-
this.wordlist = wordlist;
|
|
1150
|
-
}
|
|
1151
984
|
};
|
|
1152
985
|
var hasher = new HumanHasher();
|
|
1153
986
|
var humanize = (value) => {
|
|
@@ -1170,10 +1003,8 @@ var defaultMap = (map, key, def) => {
|
|
|
1170
1003
|
};
|
|
1171
1004
|
|
|
1172
1005
|
// src/instance-id.ts
|
|
1173
|
-
var _globalThis;
|
|
1174
|
-
var _symbol;
|
|
1175
1006
|
var symbol = Symbol.for("dxos.instance-contexts");
|
|
1176
|
-
var instanceContexts =
|
|
1007
|
+
var instanceContexts = globalThis[symbol] ??= /* @__PURE__ */ new WeakMap();
|
|
1177
1008
|
var getPrototypeSpecificInstanceId = (instance) => {
|
|
1178
1009
|
const prototype = Object.getPrototypeOf(instance);
|
|
1179
1010
|
const instanceCtx = defaultMap(instanceContexts, prototype, () => ({
|
|
@@ -1345,19 +1176,6 @@ var jsonKeyReplacer = (options = {}) => (key, value) => {
|
|
|
1345
1176
|
};
|
|
1346
1177
|
|
|
1347
1178
|
// src/map-values.ts
|
|
1348
|
-
function _define_property7(obj, key, value) {
|
|
1349
|
-
if (key in obj) {
|
|
1350
|
-
Object.defineProperty(obj, key, {
|
|
1351
|
-
value,
|
|
1352
|
-
enumerable: true,
|
|
1353
|
-
configurable: true,
|
|
1354
|
-
writable: true
|
|
1355
|
-
});
|
|
1356
|
-
} else {
|
|
1357
|
-
obj[key] = value;
|
|
1358
|
-
}
|
|
1359
|
-
return obj;
|
|
1360
|
-
}
|
|
1361
1179
|
var mapValues = (obj, fn) => {
|
|
1362
1180
|
const result = {};
|
|
1363
1181
|
Object.keys(obj).forEach((key) => {
|
|
@@ -1369,6 +1187,11 @@ var deepMapValues = (value, fn) => {
|
|
|
1369
1187
|
return new DeepMapper(fn).map(value);
|
|
1370
1188
|
};
|
|
1371
1189
|
var DeepMapper = class {
|
|
1190
|
+
_fn;
|
|
1191
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1192
|
+
constructor(_fn) {
|
|
1193
|
+
this._fn = _fn;
|
|
1194
|
+
}
|
|
1372
1195
|
map(value) {
|
|
1373
1196
|
return this._map(value, void 0);
|
|
1374
1197
|
}
|
|
@@ -1378,40 +1201,38 @@ var DeepMapper = class {
|
|
|
1378
1201
|
}
|
|
1379
1202
|
return this._fn(value, this._recurse, key);
|
|
1380
1203
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
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);
|
|
1390
1213
|
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
return res;
|
|
1398
|
-
} else if (value !== null && typeof value === "object") {
|
|
1399
|
-
const res = {};
|
|
1400
|
-
this._cyclic.set(value, res);
|
|
1401
|
-
for (const key in value) {
|
|
1402
|
-
res[key] = this._map(value[key], key);
|
|
1403
|
-
}
|
|
1404
|
-
return res;
|
|
1405
|
-
} else {
|
|
1406
|
-
return value;
|
|
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);
|
|
1407
1220
|
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1221
|
+
return res;
|
|
1222
|
+
} else {
|
|
1223
|
+
return value;
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1410
1226
|
};
|
|
1411
1227
|
var deepMapValuesAsync = (value, fn) => {
|
|
1412
1228
|
return new DeepMapperAsync(fn).map(value);
|
|
1413
1229
|
};
|
|
1414
1230
|
var DeepMapperAsync = class {
|
|
1231
|
+
_fn;
|
|
1232
|
+
_cyclic = /* @__PURE__ */ new Map();
|
|
1233
|
+
constructor(_fn) {
|
|
1234
|
+
this._fn = _fn;
|
|
1235
|
+
}
|
|
1415
1236
|
map(value) {
|
|
1416
1237
|
return this._map(value, void 0);
|
|
1417
1238
|
}
|
|
@@ -1421,35 +1242,28 @@ var DeepMapperAsync = class {
|
|
|
1421
1242
|
}
|
|
1422
1243
|
return this._fn(value, this._recurse, key);
|
|
1423
1244
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
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);
|
|
1433
1254
|
}
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
return res;
|
|
1441
|
-
} else if (value !== null && typeof value === "object") {
|
|
1442
|
-
const res = {};
|
|
1443
|
-
this._cyclic.set(value, res);
|
|
1444
|
-
for (const key in value) {
|
|
1445
|
-
res[key] = await this._map(value[key], key);
|
|
1446
|
-
}
|
|
1447
|
-
return res;
|
|
1448
|
-
} else {
|
|
1449
|
-
return value;
|
|
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);
|
|
1450
1261
|
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1262
|
+
return res;
|
|
1263
|
+
} else {
|
|
1264
|
+
return value;
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1453
1267
|
};
|
|
1454
1268
|
var visitValues = (object, visitor) => {
|
|
1455
1269
|
if (Array.isArray(object)) {
|
|
@@ -1792,23 +1606,95 @@ var safeParseJson = (data, defaultValue) => {
|
|
|
1792
1606
|
return defaultValue;
|
|
1793
1607
|
};
|
|
1794
1608
|
|
|
1795
|
-
// src/
|
|
1796
|
-
|
|
1797
|
-
function
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
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;
|
|
1807
1627
|
}
|
|
1808
|
-
|
|
1628
|
+
let result = "";
|
|
1629
|
+
try {
|
|
1630
|
+
result = JSON.stringify(obj, replacer, indent);
|
|
1631
|
+
} catch (error) {
|
|
1632
|
+
result = `Error: ${error.message}`;
|
|
1633
|
+
}
|
|
1634
|
+
return result;
|
|
1809
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
|
+
|
|
1676
|
+
// src/sliding-window-summary.ts
|
|
1677
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1810
1678
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/common/util/src/sliding-window-summary.ts";
|
|
1811
1679
|
var SlidingWindowSummary = class {
|
|
1680
|
+
_buffer;
|
|
1681
|
+
_sum = 0;
|
|
1682
|
+
_precision;
|
|
1683
|
+
constructor(options) {
|
|
1684
|
+
this._buffer = new CircularBuffer(options.dataPoints);
|
|
1685
|
+
if (options.precision != null) {
|
|
1686
|
+
invariant5(options.precision >= 0, void 0, {
|
|
1687
|
+
F: __dxlog_file5,
|
|
1688
|
+
L: 26,
|
|
1689
|
+
S: this,
|
|
1690
|
+
A: [
|
|
1691
|
+
"options.precision >= 0",
|
|
1692
|
+
""
|
|
1693
|
+
]
|
|
1694
|
+
});
|
|
1695
|
+
this._precision = Math.pow(10, options.precision);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1812
1698
|
record(value) {
|
|
1813
1699
|
const evicted = this._buffer.push(value);
|
|
1814
1700
|
this._sum += value - (evicted ?? 0);
|
|
@@ -1843,24 +1729,6 @@ var SlidingWindowSummary = class {
|
|
|
1843
1729
|
}
|
|
1844
1730
|
return Math.round(value * this._precision) / this._precision;
|
|
1845
1731
|
}
|
|
1846
|
-
constructor(options) {
|
|
1847
|
-
_define_property8(this, "_buffer", void 0);
|
|
1848
|
-
_define_property8(this, "_sum", 0);
|
|
1849
|
-
_define_property8(this, "_precision", void 0);
|
|
1850
|
-
this._buffer = new CircularBuffer(options.dataPoints);
|
|
1851
|
-
if (options.precision != null) {
|
|
1852
|
-
invariant5(options.precision >= 0, void 0, {
|
|
1853
|
-
F: __dxlog_file5,
|
|
1854
|
-
L: 26,
|
|
1855
|
-
S: this,
|
|
1856
|
-
A: [
|
|
1857
|
-
"options.precision >= 0",
|
|
1858
|
-
""
|
|
1859
|
-
]
|
|
1860
|
-
});
|
|
1861
|
-
this._precision = Math.pow(10, options.precision);
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
1732
|
};
|
|
1865
1733
|
|
|
1866
1734
|
// src/sort.ts
|
|
@@ -1909,6 +1777,7 @@ function trim(strings, ...values) {
|
|
|
1909
1777
|
const minIndent = Math.min(...lines.filter((l) => l.trim()).map((l) => l.match(/^[ \t]*/)?.[0].length ?? 0));
|
|
1910
1778
|
return lines.map((l) => l.slice(minIndent)).join("\n");
|
|
1911
1779
|
}
|
|
1780
|
+
var kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
|
|
1912
1781
|
|
|
1913
1782
|
// src/sum.ts
|
|
1914
1783
|
var sum = (values) => values.reduce((a, b) => a + b, 0);
|
|
@@ -2106,20 +1975,9 @@ var toFallback = (hash) => {
|
|
|
2106
1975
|
};
|
|
2107
1976
|
|
|
2108
1977
|
// src/tracer.ts
|
|
2109
|
-
function _define_property9(obj, key, value) {
|
|
2110
|
-
if (key in obj) {
|
|
2111
|
-
Object.defineProperty(obj, key, {
|
|
2112
|
-
value,
|
|
2113
|
-
enumerable: true,
|
|
2114
|
-
configurable: true,
|
|
2115
|
-
writable: true
|
|
2116
|
-
});
|
|
2117
|
-
} else {
|
|
2118
|
-
obj[key] = value;
|
|
2119
|
-
}
|
|
2120
|
-
return obj;
|
|
2121
|
-
}
|
|
2122
1978
|
var Tracer = class {
|
|
1979
|
+
_events = /* @__PURE__ */ new Map();
|
|
1980
|
+
_recording = false;
|
|
2123
1981
|
// TODO(burdon): Start/stop methods for recording data? By id?
|
|
2124
1982
|
// Alternatively, enable subscriptions to track/compute series.
|
|
2125
1983
|
// TODO(burdon): Hierarchical traces?
|
|
@@ -2176,10 +2034,6 @@ var Tracer = class {
|
|
|
2176
2034
|
defaultMap(this._events, event.id, []).push(event);
|
|
2177
2035
|
}
|
|
2178
2036
|
}
|
|
2179
|
-
constructor() {
|
|
2180
|
-
_define_property9(this, "_events", /* @__PURE__ */ new Map());
|
|
2181
|
-
_define_property9(this, "_recording", false);
|
|
2182
|
-
}
|
|
2183
2037
|
};
|
|
2184
2038
|
var tracer = new Tracer();
|
|
2185
2039
|
|
|
@@ -2224,7 +2078,7 @@ var stringifyTree = (node, ancestors = [], rows = []) => {
|
|
|
2224
2078
|
};
|
|
2225
2079
|
|
|
2226
2080
|
// src/types.ts
|
|
2227
|
-
var
|
|
2081
|
+
var isTruthy = (value) => !!value;
|
|
2228
2082
|
var isNonNullable = (value) => value != null;
|
|
2229
2083
|
var doAsync = async (fn) => fn();
|
|
2230
2084
|
var getProviderValue = (provider, arg) => {
|
|
@@ -2256,67 +2110,100 @@ var arrayMove = (array, from, to) => {
|
|
|
2256
2110
|
};
|
|
2257
2111
|
|
|
2258
2112
|
// src/unit.ts
|
|
2259
|
-
var
|
|
2260
|
-
return (n, precision =
|
|
2113
|
+
var createFormat = (unit) => {
|
|
2114
|
+
return (n, precision = unit.precision ?? 0) => {
|
|
2261
2115
|
const value = n / unit.quotient;
|
|
2262
|
-
return
|
|
2116
|
+
return {
|
|
2117
|
+
unit,
|
|
2118
|
+
value,
|
|
2119
|
+
formattedValue: value.toFixed(precision),
|
|
2120
|
+
toString: () => `${value.toFixed(precision)}${unit.symbol}`
|
|
2121
|
+
};
|
|
2263
2122
|
};
|
|
2264
2123
|
};
|
|
2124
|
+
var MS_SECONDS = 1e3;
|
|
2125
|
+
var MS_MINUTES = 60 * MS_SECONDS;
|
|
2126
|
+
var MS_HOURS = 60 * MS_MINUTES;
|
|
2265
2127
|
var Unit = {
|
|
2266
|
-
//
|
|
2267
|
-
|
|
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
|
+
// Time.
|
|
2156
|
+
Hour: createFormat({
|
|
2268
2157
|
symbol: "h",
|
|
2269
|
-
quotient:
|
|
2158
|
+
quotient: MS_HOURS
|
|
2270
2159
|
}),
|
|
2271
|
-
Minute:
|
|
2160
|
+
Minute: createFormat({
|
|
2272
2161
|
symbol: "m",
|
|
2273
|
-
quotient:
|
|
2162
|
+
quotient: MS_MINUTES
|
|
2274
2163
|
}),
|
|
2275
|
-
Second:
|
|
2164
|
+
Second: createFormat({
|
|
2276
2165
|
symbol: "s",
|
|
2277
|
-
quotient:
|
|
2166
|
+
quotient: MS_SECONDS,
|
|
2167
|
+
precision: 1
|
|
2278
2168
|
}),
|
|
2279
|
-
Millisecond:
|
|
2169
|
+
Millisecond: createFormat({
|
|
2280
2170
|
symbol: "ms",
|
|
2281
2171
|
quotient: 1
|
|
2282
2172
|
}),
|
|
2283
2173
|
Duration: (n) => {
|
|
2284
|
-
const hours = Math.floor(n /
|
|
2285
|
-
const minutes = Math.floor(n %
|
|
2174
|
+
const hours = Math.floor(n / MS_HOURS);
|
|
2175
|
+
const minutes = Math.floor(n % MS_HOURS / MS_MINUTES);
|
|
2286
2176
|
if (hours) {
|
|
2287
|
-
|
|
2177
|
+
const formattedValue = minutes ? `${hours}h ${minutes}m` : `${hours}h`;
|
|
2178
|
+
return {
|
|
2179
|
+
unit: {
|
|
2180
|
+
symbol: "h",
|
|
2181
|
+
quotient: MS_HOURS
|
|
2182
|
+
},
|
|
2183
|
+
value: hours,
|
|
2184
|
+
formattedValue,
|
|
2185
|
+
toString: () => formattedValue
|
|
2186
|
+
};
|
|
2288
2187
|
}
|
|
2289
|
-
const seconds = Math.floor(n % (60 * 1e3) / 1e3);
|
|
2290
2188
|
if (minutes) {
|
|
2291
|
-
|
|
2189
|
+
const seconds2 = (n - MS_MINUTES * minutes) / MS_SECONDS;
|
|
2190
|
+
const formattedValue = seconds2 ? `${minutes}m ${seconds2}s` : `${minutes}m`;
|
|
2191
|
+
return {
|
|
2192
|
+
unit: {
|
|
2193
|
+
symbol: "m",
|
|
2194
|
+
quotient: MS_MINUTES
|
|
2195
|
+
},
|
|
2196
|
+
value: minutes,
|
|
2197
|
+
formattedValue,
|
|
2198
|
+
toString: () => formattedValue
|
|
2199
|
+
};
|
|
2292
2200
|
}
|
|
2201
|
+
const seconds = n >= MS_SECONDS;
|
|
2293
2202
|
if (seconds) {
|
|
2294
|
-
return
|
|
2203
|
+
return Unit.Second(n);
|
|
2295
2204
|
}
|
|
2296
|
-
return
|
|
2297
|
-
}
|
|
2298
|
-
// bytes (note KB via KiB).
|
|
2299
|
-
Gigabyte: Formatter({
|
|
2300
|
-
symbol: "GB",
|
|
2301
|
-
quotient: 1e3 * 1e3 * 1e3
|
|
2302
|
-
}),
|
|
2303
|
-
Megabyte: Formatter({
|
|
2304
|
-
symbol: "MB",
|
|
2305
|
-
quotient: 1e3 * 1e3
|
|
2306
|
-
}),
|
|
2307
|
-
Kilobyte: Formatter({
|
|
2308
|
-
symbol: "KB",
|
|
2309
|
-
quotient: 1e3
|
|
2310
|
-
}),
|
|
2311
|
-
// general.
|
|
2312
|
-
Thousand: Formatter({
|
|
2313
|
-
symbol: "k",
|
|
2314
|
-
quotient: 1e3
|
|
2315
|
-
}),
|
|
2316
|
-
Percent: Formatter({
|
|
2317
|
-
symbol: "%",
|
|
2318
|
-
quotient: 1 / 100
|
|
2319
|
-
})
|
|
2205
|
+
return Unit.Millisecond(n);
|
|
2206
|
+
}
|
|
2320
2207
|
};
|
|
2321
2208
|
|
|
2322
2209
|
// src/url.ts
|
|
@@ -2329,20 +2216,18 @@ var createUrl = (url, search) => {
|
|
|
2329
2216
|
};
|
|
2330
2217
|
|
|
2331
2218
|
// src/weak.ts
|
|
2332
|
-
function _define_property10(obj, key, value) {
|
|
2333
|
-
if (key in obj) {
|
|
2334
|
-
Object.defineProperty(obj, key, {
|
|
2335
|
-
value,
|
|
2336
|
-
enumerable: true,
|
|
2337
|
-
configurable: true,
|
|
2338
|
-
writable: true
|
|
2339
|
-
});
|
|
2340
|
-
} else {
|
|
2341
|
-
obj[key] = value;
|
|
2342
|
-
}
|
|
2343
|
-
return obj;
|
|
2344
|
-
}
|
|
2345
2219
|
var WeakDictionary = class {
|
|
2220
|
+
_internal = /* @__PURE__ */ new Map();
|
|
2221
|
+
_finalization = new FinalizationRegistry((cleanUpCallback) => {
|
|
2222
|
+
cleanUpCallback();
|
|
2223
|
+
});
|
|
2224
|
+
constructor(entries2) {
|
|
2225
|
+
this._internal = new Map(entries2?.map(([key, value]) => [
|
|
2226
|
+
key,
|
|
2227
|
+
new WeakRef(value)
|
|
2228
|
+
]));
|
|
2229
|
+
entries2?.forEach(([key, value]) => this._register(key, value));
|
|
2230
|
+
}
|
|
2346
2231
|
*entries() {
|
|
2347
2232
|
for (const [key, value] of this._internal) {
|
|
2348
2233
|
yield [
|
|
@@ -2423,17 +2308,6 @@ var WeakDictionary = class {
|
|
|
2423
2308
|
_unregister(value) {
|
|
2424
2309
|
this._finalization.unregister(value);
|
|
2425
2310
|
}
|
|
2426
|
-
constructor(entries2) {
|
|
2427
|
-
_define_property10(this, "_internal", /* @__PURE__ */ new Map());
|
|
2428
|
-
_define_property10(this, "_finalization", new FinalizationRegistry((cleanUpCallback) => {
|
|
2429
|
-
cleanUpCallback();
|
|
2430
|
-
}));
|
|
2431
|
-
this._internal = new Map(entries2?.map(([key, value]) => [
|
|
2432
|
-
key,
|
|
2433
|
-
new WeakRef(value)
|
|
2434
|
-
]));
|
|
2435
|
-
entries2?.forEach(([key, value]) => this._register(key, value));
|
|
2436
|
-
}
|
|
2437
2311
|
};
|
|
2438
2312
|
export {
|
|
2439
2313
|
BitField,
|
|
@@ -2444,6 +2318,7 @@ export {
|
|
|
2444
2318
|
ComplexSet,
|
|
2445
2319
|
HumanHasher,
|
|
2446
2320
|
MapEntry,
|
|
2321
|
+
SKIP,
|
|
2447
2322
|
SlidingWindowSummary,
|
|
2448
2323
|
Tracer,
|
|
2449
2324
|
Unit,
|
|
@@ -2468,11 +2343,13 @@ export {
|
|
|
2468
2343
|
createBinder,
|
|
2469
2344
|
createBucketReducer,
|
|
2470
2345
|
createGroupReducer,
|
|
2346
|
+
createReplacer,
|
|
2471
2347
|
createSetDispatch,
|
|
2472
2348
|
createUrl,
|
|
2473
2349
|
decamelize,
|
|
2474
2350
|
deepMapValues,
|
|
2475
2351
|
deepMapValuesAsync,
|
|
2352
|
+
defaultFilter,
|
|
2476
2353
|
defaultMap,
|
|
2477
2354
|
defer,
|
|
2478
2355
|
deferAsync,
|
|
@@ -2489,7 +2366,6 @@ export {
|
|
|
2489
2366
|
getDate,
|
|
2490
2367
|
getDebugName,
|
|
2491
2368
|
getDeep,
|
|
2492
|
-
getFirstTwoRenderableChars,
|
|
2493
2369
|
getHostPlatform,
|
|
2494
2370
|
getPrototypeSpecificInstanceId,
|
|
2495
2371
|
getProviderValue,
|
|
@@ -2507,12 +2383,13 @@ export {
|
|
|
2507
2383
|
iosCheck,
|
|
2508
2384
|
isNode,
|
|
2509
2385
|
isNonNullable,
|
|
2510
|
-
|
|
2386
|
+
isTruthy,
|
|
2511
2387
|
joinTables,
|
|
2512
2388
|
jsonKeyReplacer,
|
|
2513
2389
|
jsonReplacer,
|
|
2514
2390
|
jsonify,
|
|
2515
2391
|
jsonlogify,
|
|
2392
|
+
kebabize,
|
|
2516
2393
|
keyToEmoji,
|
|
2517
2394
|
keyToFallback,
|
|
2518
2395
|
keyToHue,
|
|
@@ -2543,6 +2420,7 @@ export {
|
|
|
2543
2420
|
safeParseFloat,
|
|
2544
2421
|
safeParseInt,
|
|
2545
2422
|
safeParseJson,
|
|
2423
|
+
safeStringify,
|
|
2546
2424
|
set,
|
|
2547
2425
|
setDeep,
|
|
2548
2426
|
sortKeys,
|