@dereekb/util 13.10.9 → 13.11.0
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/fetch/package.json +2 -2
- package/index.cjs.js +2578 -51
- package/index.esm.js +2568 -52
- package/package.json +1 -1
- package/src/lib/array/array.d.ts +79 -0
- package/src/lib/array/array.factory.d.ts +12 -0
- package/src/lib/array/array.find.d.ts +11 -0
- package/src/lib/array/array.limit.d.ts +5 -0
- package/src/lib/array/array.random.d.ts +16 -0
- package/src/lib/array/array.set.d.ts +20 -0
- package/src/lib/array/array.unique.d.ts +38 -0
- package/src/lib/array/array.value.d.ts +10 -0
- package/src/lib/auth/index.d.ts +2 -0
- package/src/lib/auth/oauth.d.ts +12 -0
- package/src/lib/auth/pkce.d.ts +13 -0
- package/src/lib/boolean.d.ts +36 -0
- package/src/lib/cache/cache.d.ts +48 -0
- package/src/lib/cache/cache.memoize.d.ts +59 -0
- package/src/lib/cache/cache.memory.d.ts +39 -0
- package/src/lib/cache/cache.merge.d.ts +48 -0
- package/src/lib/cache/index.d.ts +4 -0
- package/src/lib/contact/domain.d.ts +15 -0
- package/src/lib/contact/email.d.ts +15 -0
- package/src/lib/date/date.unix.d.ts +20 -0
- package/src/lib/date/expires.d.ts +85 -16
- package/src/lib/function/function.d.ts +5 -0
- package/src/lib/getter/getter.d.ts +21 -0
- package/src/lib/grouping.d.ts +30 -0
- package/src/lib/hash.d.ts +10 -0
- package/src/lib/index.d.ts +1 -0
- package/src/lib/iterable/iterable.d.ts +20 -0
- package/src/lib/iterate.d.ts +5 -0
- package/src/lib/number/bound.d.ts +23 -0
- package/src/lib/number/number.d.ts +47 -0
- package/src/lib/number/random.d.ts +11 -0
- package/src/lib/number/round.d.ts +16 -0
- package/src/lib/object/object.d.ts +24 -0
- package/src/lib/object/object.empty.d.ts +5 -0
- package/src/lib/object/object.equal.d.ts +5 -0
- package/src/lib/object/object.filter.pojo.d.ts +31 -1
- package/src/lib/object/object.flatten.d.ts +4 -0
- package/src/lib/path/path.d.ts +191 -0
- package/src/lib/promise/is.d.ts +10 -0
- package/src/lib/promise/poll.d.ts +5 -0
- package/src/lib/promise/promise.d.ts +20 -0
- package/src/lib/promise/promise.type.d.ts +4 -0
- package/src/lib/promise/wait.d.ts +5 -0
- package/src/lib/set/set.d.ts +15 -0
- package/src/lib/sort.d.ts +16 -0
- package/src/lib/string/case.d.ts +10 -0
- package/src/lib/string/string.d.ts +54 -0
- package/src/lib/tree/tree.array.d.ts +6 -0
- package/src/lib/tree/tree.expand.d.ts +5 -0
- package/src/lib/tree/tree.explore.d.ts +24 -0
- package/src/lib/tree/tree.flatten.d.ts +16 -0
- package/src/lib/type.d.ts +20 -0
- package/src/lib/value/build.d.ts +4 -0
- package/src/lib/value/comparator.d.ts +11 -0
- package/src/lib/value/decision.d.ts +17 -0
- package/src/lib/value/equal.d.ts +17 -0
- package/src/lib/value/map.d.ts +23 -0
- package/src/lib/value/maybe.d.ts +49 -0
- package/src/lib/value/modifier.d.ts +5 -0
- package/test/package.json +2 -2
package/index.cjs.js
CHANGED
|
@@ -55,6 +55,11 @@ function _unsupported_iterable_to_array$B(o, minLen) {
|
|
|
55
55
|
*
|
|
56
56
|
* By default treats strings as a non-iterable value, using the string as a single value.
|
|
57
57
|
*
|
|
58
|
+
* @dbxUtil
|
|
59
|
+
* @dbxUtilCategory iterable
|
|
60
|
+
* @dbxUtilTags iterable, array, convert, normalize, ensure
|
|
61
|
+
* @dbxUtilRelated iterable-to-set, iterable-to-map, as-iterable
|
|
62
|
+
*
|
|
58
63
|
* @param values - The value or iterable to convert
|
|
59
64
|
* @param treatStringAsIterable - Whether to treat strings as iterable (defaults to false)
|
|
60
65
|
* @returns An array containing the value(s)
|
|
@@ -78,6 +83,11 @@ function _unsupported_iterable_to_array$B(o, minLen) {
|
|
|
78
83
|
*
|
|
79
84
|
* By default treats strings as a non-iterable value, using the string as a single value.
|
|
80
85
|
*
|
|
86
|
+
* @dbxUtil
|
|
87
|
+
* @dbxUtilCategory iterable
|
|
88
|
+
* @dbxUtilTags iterable, set, convert, normalize, unique, dedupe
|
|
89
|
+
* @dbxUtilRelated iterable-to-array, iterable-to-map
|
|
90
|
+
*
|
|
81
91
|
* @param values - The value or iterable to convert
|
|
82
92
|
* @param treatStringAsIterable - Whether to treat strings as iterable (defaults to false)
|
|
83
93
|
* @returns A Set containing the value(s)
|
|
@@ -103,6 +113,11 @@ function _unsupported_iterable_to_array$B(o, minLen) {
|
|
|
103
113
|
* Type guard that returns true if the input is an Iterable.
|
|
104
114
|
* By default, strings are not treated as iterable.
|
|
105
115
|
*
|
|
116
|
+
* @dbxUtil
|
|
117
|
+
* @dbxUtilCategory iterable
|
|
118
|
+
* @dbxUtilTags iterable, type-guard, check, symbol-iterator
|
|
119
|
+
* @dbxUtilRelated is-empty-iterable, as-iterable
|
|
120
|
+
*
|
|
106
121
|
* @param values - The value to check
|
|
107
122
|
* @param treatStringAsIterable - Whether to treat strings as iterable (defaults to false)
|
|
108
123
|
* @returns True if the value is iterable
|
|
@@ -119,6 +134,11 @@ function _unsupported_iterable_to_array$B(o, minLen) {
|
|
|
119
134
|
/**
|
|
120
135
|
* Returns true if the iterable has no values.
|
|
121
136
|
*
|
|
137
|
+
* @dbxUtil
|
|
138
|
+
* @dbxUtilCategory iterable
|
|
139
|
+
* @dbxUtilTags iterable, empty, check, length
|
|
140
|
+
* @dbxUtilRelated is-iterable, first-value-from-iterable
|
|
141
|
+
*
|
|
122
142
|
* @param values - The iterable to check
|
|
123
143
|
* @returns True if the iterable is empty
|
|
124
144
|
*/ function isEmptyIterable(values) {
|
|
@@ -412,6 +432,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
412
432
|
/**
|
|
413
433
|
* Converts the input value to an array containing itself, or returns itself if it is a non-empty array. Returns undefined if the input is nullish or results in an empty array.
|
|
414
434
|
*
|
|
435
|
+
* @dbxUtil
|
|
436
|
+
* @dbxUtilCategory array
|
|
437
|
+
* @dbxUtilTags array, non-empty, convert, ensure, normalize
|
|
438
|
+
* @dbxUtilRelated convert-maybe-to-array, convert-to-array
|
|
439
|
+
*
|
|
415
440
|
* @param arrayOrValue - single value or array to convert
|
|
416
441
|
* @returns an array with at least one element, or undefined if the result would be empty
|
|
417
442
|
*/ function convertMaybeToNonEmptyArray(arrayOrValue) {
|
|
@@ -427,6 +452,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
427
452
|
/**
|
|
428
453
|
* Converts the input value to an array containing itself, or returns itself if it is an array. Returns an empty array if the input is nullish.
|
|
429
454
|
*
|
|
455
|
+
* @dbxUtil
|
|
456
|
+
* @dbxUtilCategory array
|
|
457
|
+
* @dbxUtilTags array, convert, ensure, normalize, maybe, nullish
|
|
458
|
+
* @dbxUtilRelated convert-maybe-to-non-empty-array, convert-to-array, as-array
|
|
459
|
+
*
|
|
430
460
|
* @param arrayOrValue - single value, array, or nullish value to convert
|
|
431
461
|
* @returns the input wrapped in an array, the input array itself, or an empty array if nullish
|
|
432
462
|
*/ function convertMaybeToArray(arrayOrValue) {
|
|
@@ -441,6 +471,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
441
471
|
/**
|
|
442
472
|
* Converts the input value to an array containing itself, or returns itself if it is already an array.
|
|
443
473
|
*
|
|
474
|
+
* @dbxUtil
|
|
475
|
+
* @dbxUtilCategory array
|
|
476
|
+
* @dbxUtilTags array, convert, ensure, wrap, normalize
|
|
477
|
+
* @dbxUtilRelated convert-maybe-to-array, convert-maybe-to-non-empty-array
|
|
478
|
+
*
|
|
444
479
|
* @param arrayOrValue - single value or array to convert
|
|
445
480
|
* @returns the input array unchanged, or a new single-element array wrapping the input value
|
|
446
481
|
*/ function convertToArray(arrayOrValue) {
|
|
@@ -451,6 +486,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
451
486
|
/**
|
|
452
487
|
* Returns the first value from the array, or the value itself if not an array.
|
|
453
488
|
*
|
|
489
|
+
* @dbxUtil
|
|
490
|
+
* @dbxUtilCategory array
|
|
491
|
+
* @dbxUtilTags array, first, head, get, value
|
|
492
|
+
* @dbxUtilRelated last-value, value-at-index, first-and-last-value
|
|
493
|
+
*
|
|
454
494
|
* @param input - single value or array to retrieve from
|
|
455
495
|
* @returns the first element of the array, or the input value itself
|
|
456
496
|
*/ function firstValue(input) {
|
|
@@ -459,6 +499,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
459
499
|
/**
|
|
460
500
|
* Returns the last value from the array, or the value itself if not an array.
|
|
461
501
|
*
|
|
502
|
+
* @dbxUtil
|
|
503
|
+
* @dbxUtilCategory array
|
|
504
|
+
* @dbxUtilTags array, last, tail, get, value
|
|
505
|
+
* @dbxUtilRelated first-value, value-at-index, first-and-last-value
|
|
506
|
+
*
|
|
462
507
|
* @param input - single value or array to retrieve from
|
|
463
508
|
* @returns the last element of the array, or the input value itself
|
|
464
509
|
*/ function lastValue(input) {
|
|
@@ -469,6 +514,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
469
514
|
*
|
|
470
515
|
* If the input is not an array, returns that value as both the first and last value.
|
|
471
516
|
*
|
|
517
|
+
* @dbxUtil
|
|
518
|
+
* @dbxUtilCategory array
|
|
519
|
+
* @dbxUtilTags array, first, last, head, tail, tuple, endpoints
|
|
520
|
+
* @dbxUtilRelated first-value, last-value, value-at-index
|
|
521
|
+
*
|
|
472
522
|
* @param input - single value or array to retrieve from
|
|
473
523
|
* @returns a two-element tuple of the first and last values
|
|
474
524
|
*/ function firstAndLastValue(input) {
|
|
@@ -482,6 +532,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
482
532
|
/**
|
|
483
533
|
* Returns the value at the given index from an array, or the value itself if not an array.
|
|
484
534
|
*
|
|
535
|
+
* @dbxUtil
|
|
536
|
+
* @dbxUtilCategory array
|
|
537
|
+
* @dbxUtilTags array, index, get, value, at
|
|
538
|
+
* @dbxUtilRelated first-value, last-value, first-and-last-value
|
|
539
|
+
*
|
|
485
540
|
* @param input - single value or array to retrieve from
|
|
486
541
|
* @param index - zero-based index of the element to retrieve
|
|
487
542
|
* @returns the element at the specified index, or the input value itself if not an array
|
|
@@ -491,6 +546,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
491
546
|
/**
|
|
492
547
|
* Concatenates the input arrays into a single array, filtering out nullish entries.
|
|
493
548
|
*
|
|
549
|
+
* @dbxUtil
|
|
550
|
+
* @dbxUtilCategory array
|
|
551
|
+
* @dbxUtilTags array, concat, concatenate, combine, flatten, merge
|
|
552
|
+
* @dbxUtilRelated flatten-array, merge-arrays
|
|
553
|
+
*
|
|
494
554
|
* @param arrays - arrays to concatenate; nullish entries are ignored
|
|
495
555
|
* @returns a single flattened array containing all elements from the non-nullish input arrays
|
|
496
556
|
*/ function concatArrays() {
|
|
@@ -502,6 +562,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
502
562
|
/**
|
|
503
563
|
* Flattens a two-dimensional array into a single-dimensional array. Any null/undefined entries in the outer dimension are filtered out.
|
|
504
564
|
*
|
|
565
|
+
* @dbxUtil
|
|
566
|
+
* @dbxUtilCategory array
|
|
567
|
+
* @dbxUtilTags array, flatten, flat, nested, two-dimensional, concat
|
|
568
|
+
* @dbxUtilRelated concat-arrays, flatten-array-or-value-array, merge-arrays
|
|
569
|
+
*
|
|
505
570
|
* @param array - two-dimensional array to flatten, may contain nullish entries
|
|
506
571
|
* @returns a single-dimensional array with all elements from the non-nullish inner arrays
|
|
507
572
|
*/ function flattenArray(array) {
|
|
@@ -521,6 +586,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
521
586
|
/**
|
|
522
587
|
* Creates a shallow copy of the input array. Returns an empty array if the input is nullish.
|
|
523
588
|
*
|
|
589
|
+
* @dbxUtil
|
|
590
|
+
* @dbxUtilCategory array
|
|
591
|
+
* @dbxUtilTags array, copy, clone, shallow, duplicate
|
|
592
|
+
* @dbxUtilRelated convert-maybe-to-array
|
|
593
|
+
*
|
|
524
594
|
* @param input - array to copy, or nullish
|
|
525
595
|
* @returns a new array with the same elements, or an empty array if input is nullish
|
|
526
596
|
*/ function copyArray(input) {
|
|
@@ -542,6 +612,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
542
612
|
/**
|
|
543
613
|
* Merges all input arrays into a single new array. Nullish entries are ignored.
|
|
544
614
|
*
|
|
615
|
+
* @dbxUtil
|
|
616
|
+
* @dbxUtilCategory array
|
|
617
|
+
* @dbxUtilTags array, merge, concat, flatten, combine
|
|
618
|
+
* @dbxUtilRelated merge-arrays-into-array
|
|
619
|
+
*
|
|
545
620
|
* @param arrays - arrays to merge; nullish entries are skipped
|
|
546
621
|
* @returns a new array containing all elements from the provided arrays
|
|
547
622
|
*/ function mergeArrays(arrays) {
|
|
@@ -595,6 +670,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
595
670
|
/**
|
|
596
671
|
* Copies/takes the elements from the front of the array up to the specified maximum.
|
|
597
672
|
*
|
|
673
|
+
* @dbxUtil
|
|
674
|
+
* @dbxUtilCategory array
|
|
675
|
+
* @dbxUtilTags array, take, front, head, slice, limit
|
|
676
|
+
* @dbxUtilRelated take-last, split-front
|
|
677
|
+
*
|
|
598
678
|
* @param values - source array to take from
|
|
599
679
|
* @param maxToTake - maximum number of elements to take from the front
|
|
600
680
|
* @returns a new array containing at most maxToTake elements from the front
|
|
@@ -604,6 +684,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
604
684
|
/**
|
|
605
685
|
* Splits the array into two arrays, the first being the front of the array up to the maxToTake, and the second being the remaining values.
|
|
606
686
|
*
|
|
687
|
+
* @dbxUtil
|
|
688
|
+
* @dbxUtilCategory array
|
|
689
|
+
* @dbxUtilTags array, split, partition, front, slice
|
|
690
|
+
* @dbxUtilRelated take-front, take-last
|
|
691
|
+
*
|
|
607
692
|
* @param values The array to split.
|
|
608
693
|
* @param maxToTake The maximum number of values to take from the front of the array.
|
|
609
694
|
* @returns The front and remaining values.
|
|
@@ -617,6 +702,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
617
702
|
/**
|
|
618
703
|
* Copies/takes as many elements as possible from the end.
|
|
619
704
|
*
|
|
705
|
+
* @dbxUtil
|
|
706
|
+
* @dbxUtilCategory array
|
|
707
|
+
* @dbxUtilTags array, take, last, tail, end, slice, limit
|
|
708
|
+
* @dbxUtilRelated take-front, split-front
|
|
709
|
+
*
|
|
620
710
|
* @param values Values to take from.
|
|
621
711
|
* @param maxToTake Max number of values to take from the end of the input array.
|
|
622
712
|
* @param keepFromFront Number of values to retain in the front of the array. These are not taken.
|
|
@@ -654,6 +744,11 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
654
744
|
/**
|
|
655
745
|
* Counts the total number of elements across all inner arrays of a nested array.
|
|
656
746
|
*
|
|
747
|
+
* @dbxUtil
|
|
748
|
+
* @dbxUtilCategory array
|
|
749
|
+
* @dbxUtilTags array, count, nested, total, length, two-dimensional
|
|
750
|
+
* @dbxUtilRelated flatten-array
|
|
751
|
+
*
|
|
657
752
|
* @param array - two-dimensional array whose elements are counted
|
|
658
753
|
* @returns the total number of elements across all inner arrays
|
|
659
754
|
*/ function countAllInNestedArray(array) {
|
|
@@ -664,6 +759,10 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
664
759
|
/**
|
|
665
760
|
* Creates a copy of the array with the items at the specified indexes removed.
|
|
666
761
|
*
|
|
762
|
+
* @dbxUtil
|
|
763
|
+
* @dbxUtilCategory array
|
|
764
|
+
* @dbxUtilTags array, remove, exclude, indexes, filter, copy
|
|
765
|
+
*
|
|
667
766
|
* @param array - source array to copy from
|
|
668
767
|
* @param removeIndexes - indexes of elements to exclude from the copy
|
|
669
768
|
* @returns a new array without the elements at the specified indexes
|
|
@@ -788,6 +887,11 @@ function _unsupported_iterable_to_array$z(o, minLen) {
|
|
|
788
887
|
/**
|
|
789
888
|
* Converts an {@link IterableOrValue} into a Set. Strings are treated as single values rather than character iterables.
|
|
790
889
|
*
|
|
890
|
+
* @dbxUtil
|
|
891
|
+
* @dbxUtilCategory set
|
|
892
|
+
* @dbxUtilTags set, convert, normalize, ensure, unique, dedupe
|
|
893
|
+
* @dbxUtilRelated add-to-set, iterable-to-set
|
|
894
|
+
*
|
|
791
895
|
* @param values - The value or iterable to convert.
|
|
792
896
|
* @returns A new Set containing all values.
|
|
793
897
|
*/ function asSet(values) {
|
|
@@ -827,6 +931,11 @@ function _unsupported_iterable_to_array$z(o, minLen) {
|
|
|
827
931
|
/**
|
|
828
932
|
* Adds one or more values to the given set in place.
|
|
829
933
|
*
|
|
934
|
+
* @dbxUtil
|
|
935
|
+
* @dbxUtilCategory set
|
|
936
|
+
* @dbxUtilTags set, add, mutate, insert, in-place
|
|
937
|
+
* @dbxUtilRelated add-to-set-copy, remove-from-set, toggle-in-set
|
|
938
|
+
*
|
|
830
939
|
* @param set - The set to add values to.
|
|
831
940
|
* @param values - The value or iterable of values to add.
|
|
832
941
|
*/ function addToSet(set, values) {
|
|
@@ -848,6 +957,11 @@ function _unsupported_iterable_to_array$z(o, minLen) {
|
|
|
848
957
|
/**
|
|
849
958
|
* Toggles values in the set in place: adds if absent, removes if present.
|
|
850
959
|
*
|
|
960
|
+
* @dbxUtil
|
|
961
|
+
* @dbxUtilCategory set
|
|
962
|
+
* @dbxUtilTags set, toggle, add, remove, mutate, in-place
|
|
963
|
+
* @dbxUtilRelated toggle-in-set-copy, add-to-set, remove-from-set
|
|
964
|
+
*
|
|
851
965
|
* @param set - The set to modify.
|
|
852
966
|
* @param values - The values to toggle.
|
|
853
967
|
*/ function toggleInSet(set, values) {
|
|
@@ -1329,6 +1443,12 @@ function _unsupported_iterable_to_array$y(o, minLen) {
|
|
|
1329
1443
|
* When mode is `'any'`, the resulting function returns `true` if at least one element satisfies the predicate.
|
|
1330
1444
|
* When mode is `'all'`, it returns `true` only if every element satisfies the predicate.
|
|
1331
1445
|
*
|
|
1446
|
+
* @dbxUtil
|
|
1447
|
+
* @dbxUtilCategory array
|
|
1448
|
+
* @dbxUtilKind factory
|
|
1449
|
+
* @dbxUtilTags array, decision, predicate, find, every, some, all, any, factory
|
|
1450
|
+
* @dbxUtilRelated array-decision
|
|
1451
|
+
*
|
|
1332
1452
|
* @param decision - Predicate used to test individual elements.
|
|
1333
1453
|
* @param mode - Whether all or any elements must satisfy the predicate.
|
|
1334
1454
|
* @returns A function that evaluates an array against the configured decision criteria.
|
|
@@ -1343,6 +1463,11 @@ function _unsupported_iterable_to_array$y(o, minLen) {
|
|
|
1343
1463
|
/**
|
|
1344
1464
|
* Convenience wrapper that creates and immediately invokes an {@link ArrayDecisionFunction}.
|
|
1345
1465
|
*
|
|
1466
|
+
* @dbxUtil
|
|
1467
|
+
* @dbxUtilCategory array
|
|
1468
|
+
* @dbxUtilTags array, decision, predicate, find, every, some, all, any
|
|
1469
|
+
* @dbxUtilRelated array-decision-function
|
|
1470
|
+
*
|
|
1346
1471
|
* @param values - Array to evaluate.
|
|
1347
1472
|
* @param decision - Predicate used to test individual elements.
|
|
1348
1473
|
* @param mode - Whether all or any elements must satisfy the predicate.
|
|
@@ -1351,7 +1476,7 @@ function _unsupported_iterable_to_array$y(o, minLen) {
|
|
|
1351
1476
|
return arrayDecisionFunction(decision, mode)(values);
|
|
1352
1477
|
}
|
|
1353
1478
|
|
|
1354
|
-
function _define_property$
|
|
1479
|
+
function _define_property$n(obj, key, value) {
|
|
1355
1480
|
if (key in obj) {
|
|
1356
1481
|
Object.defineProperty(obj, key, {
|
|
1357
1482
|
value: value,
|
|
@@ -1364,7 +1489,7 @@ function _define_property$m(obj, key, value) {
|
|
|
1364
1489
|
}
|
|
1365
1490
|
return obj;
|
|
1366
1491
|
}
|
|
1367
|
-
function _object_spread$
|
|
1492
|
+
function _object_spread$g(target) {
|
|
1368
1493
|
for(var i = 1; i < arguments.length; i++){
|
|
1369
1494
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
1370
1495
|
var ownKeys = Object.keys(source);
|
|
@@ -1374,7 +1499,7 @@ function _object_spread$f(target) {
|
|
|
1374
1499
|
}));
|
|
1375
1500
|
}
|
|
1376
1501
|
ownKeys.forEach(function(key) {
|
|
1377
|
-
_define_property$
|
|
1502
|
+
_define_property$n(target, key, source[key]);
|
|
1378
1503
|
});
|
|
1379
1504
|
}
|
|
1380
1505
|
return target;
|
|
@@ -1382,6 +1507,11 @@ function _object_spread$f(target) {
|
|
|
1382
1507
|
/**
|
|
1383
1508
|
* Checks whether the object has no own enumerable keys.
|
|
1384
1509
|
*
|
|
1510
|
+
* @dbxUtil
|
|
1511
|
+
* @dbxUtilCategory object
|
|
1512
|
+
* @dbxUtilTags object, empty, keys, check, type-guard
|
|
1513
|
+
* @dbxUtilRelated object-has-key, object-has-keys, has-value-or-not-empty-object
|
|
1514
|
+
*
|
|
1385
1515
|
* @param obj - Object to check
|
|
1386
1516
|
* @returns `true` if the object has zero keys
|
|
1387
1517
|
*/ function objectHasNoKeys(obj) {
|
|
@@ -1411,6 +1541,10 @@ function objectHasKeys(obj, keys, mode) {
|
|
|
1411
1541
|
/**
|
|
1412
1542
|
* Converts a Map to a plain object by iterating entries and assigning key-value pairs.
|
|
1413
1543
|
*
|
|
1544
|
+
* @dbxUtil
|
|
1545
|
+
* @dbxUtilCategory object
|
|
1546
|
+
* @dbxUtilTags object, map, convert, transform, dictionary
|
|
1547
|
+
*
|
|
1414
1548
|
* @param map - Map to convert
|
|
1415
1549
|
* @returns A plain object with the same key-value pairs
|
|
1416
1550
|
*/ function mapToObject(map) {
|
|
@@ -1423,10 +1557,15 @@ function objectHasKeys(obj, keys, mode) {
|
|
|
1423
1557
|
/**
|
|
1424
1558
|
* Creates a shallow copy of an object using the spread operator.
|
|
1425
1559
|
*
|
|
1560
|
+
* @dbxUtil
|
|
1561
|
+
* @dbxUtilCategory object
|
|
1562
|
+
* @dbxUtilTags object, copy, clone, shallow, spread
|
|
1563
|
+
* @dbxUtilRelated copy-array
|
|
1564
|
+
*
|
|
1426
1565
|
* @param input - Object to copy
|
|
1427
1566
|
* @returns A new object with the same properties
|
|
1428
1567
|
*/ function copyObject(input) {
|
|
1429
|
-
return _object_spread$
|
|
1568
|
+
return _object_spread$g({}, input);
|
|
1430
1569
|
}
|
|
1431
1570
|
|
|
1432
1571
|
function _type_of$l(obj) {
|
|
@@ -1436,6 +1575,11 @@ function _type_of$l(obj) {
|
|
|
1436
1575
|
/**
|
|
1437
1576
|
* Type guard that returns `true` if the value is not `null` or `undefined`.
|
|
1438
1577
|
*
|
|
1578
|
+
* @dbxUtil
|
|
1579
|
+
* @dbxUtilCategory value
|
|
1580
|
+
* @dbxUtilTags maybe, nullish, type-guard, defined, not-null, value
|
|
1581
|
+
* @dbxUtilRelated is-maybe-so, is-maybe-not, has-value-or-not-empty
|
|
1582
|
+
*
|
|
1439
1583
|
* @param value - the value to check
|
|
1440
1584
|
* @returns `true` if the value is not `null` or `undefined`
|
|
1441
1585
|
*/ function hasNonNullValue(value) {
|
|
@@ -1450,6 +1594,11 @@ function _type_of$l(obj) {
|
|
|
1450
1594
|
*
|
|
1451
1595
|
* NaN has undefined behavior.
|
|
1452
1596
|
*
|
|
1597
|
+
* @dbxUtil
|
|
1598
|
+
* @dbxUtilCategory value
|
|
1599
|
+
* @dbxUtilTags maybe, empty, type-guard, non-empty, value, has-value
|
|
1600
|
+
* @dbxUtilRelated has-value-or-not-empty-object, has-non-null-value, is-not-null-or-empty-string
|
|
1601
|
+
*
|
|
1453
1602
|
* @param value - the value to check
|
|
1454
1603
|
* @returns `true` if the value is non-nullish and not empty
|
|
1455
1604
|
*/ function hasValueOrNotEmpty(value) {
|
|
@@ -1463,6 +1612,11 @@ function _type_of$l(obj) {
|
|
|
1463
1612
|
*
|
|
1464
1613
|
* NaN has undefined behavior.
|
|
1465
1614
|
*
|
|
1615
|
+
* @dbxUtil
|
|
1616
|
+
* @dbxUtilCategory value
|
|
1617
|
+
* @dbxUtilTags maybe, empty, type-guard, object, non-empty, strict
|
|
1618
|
+
* @dbxUtilRelated has-value-or-not-empty, has-non-null-value, object-has-no-keys
|
|
1619
|
+
*
|
|
1466
1620
|
* @param value - the value to check
|
|
1467
1621
|
* @returns `true` if the value is non-nullish, non-empty, and not an empty object
|
|
1468
1622
|
*/ function hasValueOrNotEmptyObject(value) {
|
|
@@ -1489,6 +1643,11 @@ function _type_of$l(obj) {
|
|
|
1489
1643
|
*
|
|
1490
1644
|
* Useful for filtering out both nullish values and empty strings in a single check.
|
|
1491
1645
|
*
|
|
1646
|
+
* @dbxUtil
|
|
1647
|
+
* @dbxUtilCategory value
|
|
1648
|
+
* @dbxUtilTags maybe, string, empty, type-guard, nullish, non-empty
|
|
1649
|
+
* @dbxUtilRelated has-value-or-not-empty, has-non-null-value
|
|
1650
|
+
*
|
|
1492
1651
|
* @param value - the value to check
|
|
1493
1652
|
* @returns `true` if the value is not nullish and not an empty string
|
|
1494
1653
|
*/ function isNotNullOrEmptyString(value) {
|
|
@@ -1497,6 +1656,11 @@ function _type_of$l(obj) {
|
|
|
1497
1656
|
/**
|
|
1498
1657
|
* Type guard that returns `true` if the input is `null` or `undefined`.
|
|
1499
1658
|
*
|
|
1659
|
+
* @dbxUtil
|
|
1660
|
+
* @dbxUtilCategory value
|
|
1661
|
+
* @dbxUtilTags maybe, nullish, type-guard, null, undefined, missing
|
|
1662
|
+
* @dbxUtilRelated is-maybe-so, has-non-null-value
|
|
1663
|
+
*
|
|
1500
1664
|
* @param value - the value to check
|
|
1501
1665
|
* @returns `true` if the value is `null` or `undefined`
|
|
1502
1666
|
*/ function isMaybeNot(value) {
|
|
@@ -1507,6 +1671,11 @@ function _type_of$l(obj) {
|
|
|
1507
1671
|
*
|
|
1508
1672
|
* Equivalent to {@link hasNonNullValue} but with the `MaybeSo` narrowing type.
|
|
1509
1673
|
*
|
|
1674
|
+
* @dbxUtil
|
|
1675
|
+
* @dbxUtilCategory value
|
|
1676
|
+
* @dbxUtilTags maybe, nullish, type-guard, defined, present, non-null
|
|
1677
|
+
* @dbxUtilRelated is-maybe-not, has-non-null-value
|
|
1678
|
+
*
|
|
1510
1679
|
* @param value - the value to check
|
|
1511
1680
|
* @returns `true` if the value is neither `null` nor `undefined`
|
|
1512
1681
|
*/ function isMaybeSo(value) {
|
|
@@ -1525,6 +1694,11 @@ function _type_of$l(obj) {
|
|
|
1525
1694
|
/**
|
|
1526
1695
|
* Returns `true` if the input is not `null`, `undefined`, or `false`.
|
|
1527
1696
|
*
|
|
1697
|
+
* @dbxUtil
|
|
1698
|
+
* @dbxUtilCategory value
|
|
1699
|
+
* @dbxUtilTags maybe, boolean, defined, truthy, type-guard
|
|
1700
|
+
* @dbxUtilRelated is-not-false, has-non-null-value
|
|
1701
|
+
*
|
|
1528
1702
|
* @param value - the value to check
|
|
1529
1703
|
* @returns `true` if the value is not `null`, `undefined`, or `false`
|
|
1530
1704
|
*/ function isDefinedAndNotFalse(value) {
|
|
@@ -1541,6 +1715,11 @@ function _type_of$l(obj) {
|
|
|
1541
1715
|
/**
|
|
1542
1716
|
* Returns `true` if both inputs are non-nullish and strictly equal (`===`).
|
|
1543
1717
|
*
|
|
1718
|
+
* @dbxUtil
|
|
1719
|
+
* @dbxUtilCategory value
|
|
1720
|
+
* @dbxUtilTags maybe, equal, equality, compare, non-null
|
|
1721
|
+
* @dbxUtilRelated values-are-both-nullish-or-equivalent, has-non-null-value
|
|
1722
|
+
*
|
|
1544
1723
|
* @param a - first value
|
|
1545
1724
|
* @param b - second value
|
|
1546
1725
|
* @returns `true` if both values are non-nullish and strictly equal
|
|
@@ -1552,6 +1731,11 @@ function _type_of$l(obj) {
|
|
|
1552
1731
|
*
|
|
1553
1732
|
* This means `null` and `undefined` are considered equivalent to each other, but `false` and `null` are not.
|
|
1554
1733
|
*
|
|
1734
|
+
* @dbxUtil
|
|
1735
|
+
* @dbxUtilCategory value
|
|
1736
|
+
* @dbxUtilTags maybe, equal, equality, nullish, compare
|
|
1737
|
+
* @dbxUtilRelated is-same-non-null-value
|
|
1738
|
+
*
|
|
1555
1739
|
* @param a - first value
|
|
1556
1740
|
* @param b - second value
|
|
1557
1741
|
* @returns `true` if both are nullish or both are the same value
|
|
@@ -1565,6 +1749,10 @@ function _type_of$l(obj) {
|
|
|
1565
1749
|
* - If `b` is `null`, returns `null` (explicit clear).
|
|
1566
1750
|
* - If `b` is defined, returns `b` (new value).
|
|
1567
1751
|
*
|
|
1752
|
+
* @dbxUtil
|
|
1753
|
+
* @dbxUtilCategory value
|
|
1754
|
+
* @dbxUtilTags maybe, update, merge, sentinel, patch, optional
|
|
1755
|
+
*
|
|
1568
1756
|
* @param a - the current value
|
|
1569
1757
|
* @param b - the update value
|
|
1570
1758
|
* @returns `a` if `b` is undefined, otherwise `b`
|
|
@@ -1593,12 +1781,22 @@ function _type_of$l(obj) {
|
|
|
1593
1781
|
/**
|
|
1594
1782
|
* Filters all maybe values from the input array. If a maybe value is input, returns an empty array.
|
|
1595
1783
|
*
|
|
1784
|
+
* @dbxUtil
|
|
1785
|
+
* @dbxUtilCategory array
|
|
1786
|
+
* @dbxUtilTags array, filter, maybe, nullish, non-null, defined, compact
|
|
1787
|
+
* @dbxUtilRelated filter-empty-array-values, filter-maybe-array-function
|
|
1788
|
+
*
|
|
1596
1789
|
* @param values - Optional array of optional values to filter.
|
|
1597
1790
|
* @returns An array containing only non-null and non-undefined values.
|
|
1598
1791
|
*/ var filterMaybeArrayValues = filterMaybeArrayFunction(hasNonNullValue);
|
|
1599
1792
|
/**
|
|
1600
1793
|
* Filters all empty and maybe values from the input array. If a maybe value is input, returns an empty array.
|
|
1601
1794
|
*
|
|
1795
|
+
* @dbxUtil
|
|
1796
|
+
* @dbxUtilCategory array
|
|
1797
|
+
* @dbxUtilTags array, filter, empty, maybe, nullish, non-empty, compact
|
|
1798
|
+
* @dbxUtilRelated filter-maybe-array-values, filter-maybe-array-function
|
|
1799
|
+
*
|
|
1602
1800
|
* @param values - Optional array of optional values to filter.
|
|
1603
1801
|
* @returns An array containing only non-null, non-undefined, and non-empty values.
|
|
1604
1802
|
*/ var filterEmptyArrayValues = filterMaybeArrayFunction(hasValueOrNotEmpty);
|
|
@@ -1633,6 +1831,10 @@ function _type_of$l(obj) {
|
|
|
1633
1831
|
* @param config.build - function that mutates the base object to populate it with desired values
|
|
1634
1832
|
* @returns the fully constructed object of type T
|
|
1635
1833
|
*
|
|
1834
|
+
* @dbxUtil
|
|
1835
|
+
* @dbxUtilCategory value
|
|
1836
|
+
* @dbxUtilTags build, builder, construct, mutate, configure, factory
|
|
1837
|
+
*
|
|
1636
1838
|
* @example
|
|
1637
1839
|
* ```ts
|
|
1638
1840
|
* interface User { name: string; age: number; }
|
|
@@ -1657,6 +1859,12 @@ function _type_of$l(obj) {
|
|
|
1657
1859
|
* @param mapFunction - function to apply only when the input is defined
|
|
1658
1860
|
* @returns a new function that short-circuits on null/undefined inputs
|
|
1659
1861
|
*
|
|
1862
|
+
* @dbxUtil
|
|
1863
|
+
* @dbxUtilCategory value
|
|
1864
|
+
* @dbxUtilKind factory
|
|
1865
|
+
* @dbxUtilTags map, transform, maybe, nullish, factory, optional
|
|
1866
|
+
* @dbxUtilRelated map-array-function, map-identity-function
|
|
1867
|
+
*
|
|
1660
1868
|
* @example
|
|
1661
1869
|
* ```ts
|
|
1662
1870
|
* const double = (x: number) => x * 2;
|
|
@@ -1675,6 +1883,12 @@ function _type_of$l(obj) {
|
|
|
1675
1883
|
/**
|
|
1676
1884
|
* Lifts a per-element MapFunction into one that operates on arrays, applying the mapping to each element.
|
|
1677
1885
|
*
|
|
1886
|
+
* @dbxUtil
|
|
1887
|
+
* @dbxUtilCategory value
|
|
1888
|
+
* @dbxUtilKind factory
|
|
1889
|
+
* @dbxUtilTags map, transform, array, lift, factory
|
|
1890
|
+
* @dbxUtilRelated map-maybe-function, chain-map-functions
|
|
1891
|
+
*
|
|
1678
1892
|
* @param mapFunction - per-element transformation
|
|
1679
1893
|
* @returns a function that maps entire arrays
|
|
1680
1894
|
*/ function mapArrayFunction(mapFunction) {
|
|
@@ -1688,6 +1902,12 @@ function _type_of$l(obj) {
|
|
|
1688
1902
|
* Used as a sentinel value so that {@link chainMapSameFunctions} and other combinators can detect
|
|
1689
1903
|
* and skip no-op mappings for efficiency.
|
|
1690
1904
|
*
|
|
1905
|
+
* @dbxUtil
|
|
1906
|
+
* @dbxUtilCategory value
|
|
1907
|
+
* @dbxUtilKind const
|
|
1908
|
+
* @dbxUtilTags map, identity, no-op, sentinel, pass-through, constant
|
|
1909
|
+
* @dbxUtilRelated map-identity-function, is-map-identity-function
|
|
1910
|
+
*
|
|
1691
1911
|
* @param input - the value to pass through unchanged
|
|
1692
1912
|
* @returns the same input value, unmodified
|
|
1693
1913
|
*/ var MAP_IDENTITY = function MAP_IDENTITY(input) {
|
|
@@ -1757,6 +1977,11 @@ function _type_of$l(obj) {
|
|
|
1757
1977
|
* @param input - one or more optional same-type map functions to chain
|
|
1758
1978
|
* @returns a single composed function that runs all provided functions in order
|
|
1759
1979
|
*
|
|
1980
|
+
* @dbxUtil
|
|
1981
|
+
* @dbxUtilCategory value
|
|
1982
|
+
* @dbxUtilTags map, chain, compose, pipeline, identity, transform
|
|
1983
|
+
* @dbxUtilRelated chain-map-function, map-identity-function
|
|
1984
|
+
*
|
|
1760
1985
|
* @example
|
|
1761
1986
|
* ```ts
|
|
1762
1987
|
* const fnChain = chainMapSameFunctions([
|
|
@@ -1823,6 +2048,11 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
1823
2048
|
/**
|
|
1824
2049
|
* Concatenates multiple arrays and returns only unique values.
|
|
1825
2050
|
*
|
|
2051
|
+
* @dbxUtil
|
|
2052
|
+
* @dbxUtilCategory array
|
|
2053
|
+
* @dbxUtilTags array, unique, concat, distinct, dedupe, deduplicate
|
|
2054
|
+
* @dbxUtilRelated unique, flatten-array-unique, concat-arrays
|
|
2055
|
+
*
|
|
1826
2056
|
* @param arrays - Arrays to concatenate. Null/undefined arrays are ignored.
|
|
1827
2057
|
* @returns Array containing only unique values from all input arrays.
|
|
1828
2058
|
*/ function concatArraysUnique() {
|
|
@@ -1834,6 +2064,11 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
1834
2064
|
/**
|
|
1835
2065
|
* Flattens a 2D array and returns only unique values.
|
|
1836
2066
|
*
|
|
2067
|
+
* @dbxUtil
|
|
2068
|
+
* @dbxUtilCategory array
|
|
2069
|
+
* @dbxUtilTags array, flatten, unique, distinct, dedupe, nested
|
|
2070
|
+
* @dbxUtilRelated unique, concat-arrays-unique, flatten-array
|
|
2071
|
+
*
|
|
1837
2072
|
* @param array - Two-dimensional array to flatten and deduplicate.
|
|
1838
2073
|
* @returns Array containing only unique values from the flattened input.
|
|
1839
2074
|
*/ function flattenArrayUnique(array) {
|
|
@@ -1842,6 +2077,11 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
1842
2077
|
/**
|
|
1843
2078
|
* Filters the input values and only returns unique values.
|
|
1844
2079
|
*
|
|
2080
|
+
* @dbxUtil
|
|
2081
|
+
* @dbxUtilCategory array
|
|
2082
|
+
* @dbxUtilTags array, unique, distinct, dedupe, deduplicate, set
|
|
2083
|
+
* @dbxUtilRelated filter-unique-values, filter-unique-function, concat-arrays-unique
|
|
2084
|
+
*
|
|
1845
2085
|
* @param values - Array of primitive-key values to deduplicate.
|
|
1846
2086
|
* @param excludeInput - Optional keys or values to exclude from the result.
|
|
1847
2087
|
* @returns Array containing only unique values with exclusions removed.
|
|
@@ -1880,6 +2120,12 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
1880
2120
|
/**
|
|
1881
2121
|
* Creates a {@link FilterUniqueFunction} that deduplicates items by their computed key.
|
|
1882
2122
|
*
|
|
2123
|
+
* @dbxUtil
|
|
2124
|
+
* @dbxUtilCategory array
|
|
2125
|
+
* @dbxUtilKind factory
|
|
2126
|
+
* @dbxUtilTags array, unique, distinct, dedupe, factory, key, filter
|
|
2127
|
+
* @dbxUtilRelated filter-unique-values, unique, allow-value-once-filter
|
|
2128
|
+
*
|
|
1883
2129
|
* @param readKey - Function to extract a unique key from each item.
|
|
1884
2130
|
* @param additionalKeysInput - Optional keys or values to pre-seed as already seen, causing them to be excluded.
|
|
1885
2131
|
* @returns A reusable filter function that removes duplicate items from arrays.
|
|
@@ -1909,6 +2155,11 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
1909
2155
|
/**
|
|
1910
2156
|
* Filters an array to contain only items with unique keys.
|
|
1911
2157
|
*
|
|
2158
|
+
* @dbxUtil
|
|
2159
|
+
* @dbxUtilCategory array
|
|
2160
|
+
* @dbxUtilTags array, unique, filter, dedupe, key, distinct
|
|
2161
|
+
* @dbxUtilRelated filter-unique-function, unique, is-unique-keyed-function
|
|
2162
|
+
*
|
|
1912
2163
|
* @param values - Array of items to deduplicate.
|
|
1913
2164
|
* @param readKey - Function to extract a unique key from each item.
|
|
1914
2165
|
* @param additionalKeys - Optional keys to pre-seed as already seen, excluding matching items.
|
|
@@ -1920,6 +2171,12 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
1920
2171
|
/**
|
|
1921
2172
|
* Creates an {@link IsUniqueKeyedFunction} that checks whether all items in an array have unique keys.
|
|
1922
2173
|
*
|
|
2174
|
+
* @dbxUtil
|
|
2175
|
+
* @dbxUtilCategory array
|
|
2176
|
+
* @dbxUtilKind factory
|
|
2177
|
+
* @dbxUtilTags array, unique, validation, distinct, key, decision, factory
|
|
2178
|
+
* @dbxUtilRelated filter-unique-function, unique
|
|
2179
|
+
*
|
|
1923
2180
|
* @param readKey - Function to extract a unique key from each item.
|
|
1924
2181
|
* @returns A decision function that returns true if all items have distinct keys.
|
|
1925
2182
|
*/ function isUniqueKeyedFunction(readKey) {
|
|
@@ -1961,7 +2218,7 @@ function _class_call_check$b(instance, Constructor) {
|
|
|
1961
2218
|
throw new TypeError("Cannot call a class as a function");
|
|
1962
2219
|
}
|
|
1963
2220
|
}
|
|
1964
|
-
function _define_property$
|
|
2221
|
+
function _define_property$m(obj, key, value) {
|
|
1965
2222
|
if (key in obj) {
|
|
1966
2223
|
Object.defineProperty(obj, key, {
|
|
1967
2224
|
value: value,
|
|
@@ -2224,7 +2481,7 @@ function readModelKey(input) {
|
|
|
2224
2481
|
* @deprecated Use {@link UniqueModel} instead.
|
|
2225
2482
|
*/ var AbstractUniqueModel = function AbstractUniqueModel(template) {
|
|
2226
2483
|
_class_call_check$b(this, AbstractUniqueModel);
|
|
2227
|
-
_define_property$
|
|
2484
|
+
_define_property$m(this, "id", void 0);
|
|
2228
2485
|
this.id = template.id;
|
|
2229
2486
|
}
|
|
2230
2487
|
;
|
|
@@ -2385,7 +2642,7 @@ function _create_class$7(Constructor, protoProps, staticProps) {
|
|
|
2385
2642
|
if (protoProps) _defineProperties$7(Constructor.prototype, protoProps);
|
|
2386
2643
|
return Constructor;
|
|
2387
2644
|
}
|
|
2388
|
-
function _define_property$
|
|
2645
|
+
function _define_property$l(obj, key, value) {
|
|
2389
2646
|
if (key in obj) {
|
|
2390
2647
|
Object.defineProperty(obj, key, {
|
|
2391
2648
|
value: value,
|
|
@@ -2423,8 +2680,8 @@ function _unsupported_iterable_to_array$v(o, minLen) {
|
|
|
2423
2680
|
function HashSet(config, values) {
|
|
2424
2681
|
var _this = this;
|
|
2425
2682
|
_class_call_check$a(this, HashSet);
|
|
2426
|
-
_define_property$
|
|
2427
|
-
_define_property$
|
|
2683
|
+
_define_property$l(this, "_map", new Map());
|
|
2684
|
+
_define_property$l(this, "_config", void 0);
|
|
2428
2685
|
this._config = config;
|
|
2429
2686
|
if (values) {
|
|
2430
2687
|
values.forEach(function(x) {
|
|
@@ -2647,6 +2904,11 @@ function reverseCompareFn(compareFn) {
|
|
|
2647
2904
|
*
|
|
2648
2905
|
* The input comparison function must be in ascending order.
|
|
2649
2906
|
*
|
|
2907
|
+
* @dbxUtil
|
|
2908
|
+
* @dbxUtilCategory sort
|
|
2909
|
+
* @dbxUtilTags sort, order, ascending, descending, compare, direction
|
|
2910
|
+
* @dbxUtilRelated reverse-compare-fn, compare-with-mapped-values-function
|
|
2911
|
+
*
|
|
2650
2912
|
* @param ascendingCompareFn - a comparison function that sorts in ascending order
|
|
2651
2913
|
* @param order - the desired sort direction; defaults to 'asc'
|
|
2652
2914
|
* @returns the original function if ascending, or a reversed version if descending
|
|
@@ -2662,6 +2924,12 @@ function reverseCompareFn(compareFn) {
|
|
|
2662
2924
|
* @param comparesFunction - Compares the mapped values.
|
|
2663
2925
|
* @returns A sort comparison function for the original type.
|
|
2664
2926
|
*
|
|
2927
|
+
* @dbxUtil
|
|
2928
|
+
* @dbxUtilCategory sort
|
|
2929
|
+
* @dbxUtilKind factory
|
|
2930
|
+
* @dbxUtilTags sort, compare, map, derive, factory, by, key
|
|
2931
|
+
* @dbxUtilRelated reverse-compare-fn, compare-fn-order
|
|
2932
|
+
*
|
|
2665
2933
|
* @example
|
|
2666
2934
|
* ```ts
|
|
2667
2935
|
* const byName = compareWithMappedValuesFunction(
|
|
@@ -2832,6 +3100,11 @@ function _unsupported_iterable_to_array$t(o, minLen) {
|
|
|
2832
3100
|
* @param batchSize - Maximum number of items per batch.
|
|
2833
3101
|
* @returns An array of {@link IndexedBatch} arrays.
|
|
2834
3102
|
*
|
|
3103
|
+
* @dbxUtil
|
|
3104
|
+
* @dbxUtilCategory grouping
|
|
3105
|
+
* @dbxUtilTags array, batch, chunk, split, group, partition, indexed
|
|
3106
|
+
* @dbxUtilRelated batch-calc, item-count-for-batch-index
|
|
3107
|
+
*
|
|
2835
3108
|
* @example
|
|
2836
3109
|
* ```ts
|
|
2837
3110
|
* const result = batch(['a', 'b', 'c', 'd'], 2);
|
|
@@ -2853,6 +3126,11 @@ function _unsupported_iterable_to_array$t(o, minLen) {
|
|
|
2853
3126
|
/**
|
|
2854
3127
|
* Calculates batch metrics (count, full batches, remainder) from a {@link BatchCount} configuration.
|
|
2855
3128
|
*
|
|
3129
|
+
* @dbxUtil
|
|
3130
|
+
* @dbxUtilCategory grouping
|
|
3131
|
+
* @dbxUtilTags batch, calculate, count, remainder, math
|
|
3132
|
+
* @dbxUtilRelated batch, item-count-for-batch-index
|
|
3133
|
+
*
|
|
2856
3134
|
* @param input - The total items and items-per-batch configuration.
|
|
2857
3135
|
* @returns A {@link BatchCalc} with computed batch counts and remainder.
|
|
2858
3136
|
*/ function batchCalc(input) {
|
|
@@ -2911,6 +3189,11 @@ function _unsupported_iterable_to_array$t(o, minLen) {
|
|
|
2911
3189
|
* @param params.excludeNewItems - when true, values whose keys are not in `orderKeys` are omitted from the result; defaults to false
|
|
2912
3190
|
* @returns The reordered values array.
|
|
2913
3191
|
*
|
|
3192
|
+
* @dbxUtil
|
|
3193
|
+
* @dbxUtilCategory grouping
|
|
3194
|
+
* @dbxUtilTags array, order, restore, sort, key, reorder, dedupe
|
|
3195
|
+
* @dbxUtilRelated restore-order-with-values, group-values
|
|
3196
|
+
*
|
|
2914
3197
|
* @example
|
|
2915
3198
|
* ```ts
|
|
2916
3199
|
* const items = [{ key: 'a' }, { key: 'b' }, { key: 'c' }];
|
|
@@ -3034,6 +3317,11 @@ function _unsupported_iterable_to_array$t(o, minLen) {
|
|
|
3034
3317
|
/**
|
|
3035
3318
|
* Separates values into included and excluded groups based on a decision function.
|
|
3036
3319
|
*
|
|
3320
|
+
* @dbxUtil
|
|
3321
|
+
* @dbxUtilCategory grouping
|
|
3322
|
+
* @dbxUtilTags array, separate, partition, split, filter, group
|
|
3323
|
+
* @dbxUtilRelated group-values, pair-group-values
|
|
3324
|
+
*
|
|
3037
3325
|
* @param values - Values to separate.
|
|
3038
3326
|
* @param checkInclusion - Returns `true` for values that should be included.
|
|
3039
3327
|
* @returns A {@link SeparateResult} with included and excluded arrays.
|
|
@@ -3435,6 +3723,11 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3435
3723
|
* Returns true if the input is a function-like value with a prototype and constructor (i.e., a class or named function declaration).
|
|
3436
3724
|
* Returns false for arrow functions, class instances, plain objects, and primitives.
|
|
3437
3725
|
*
|
|
3726
|
+
* @dbxUtil
|
|
3727
|
+
* @dbxUtilCategory type
|
|
3728
|
+
* @dbxUtilTags type, type-guard, function, class, constructor, reflection
|
|
3729
|
+
* @dbxUtilRelated is-class-like-type, get-function-type, is-non-class-function
|
|
3730
|
+
*
|
|
3438
3731
|
* @param obj - The value to check.
|
|
3439
3732
|
* @returns Whether the value is a function with a constructor.
|
|
3440
3733
|
*/ function isObjectWithConstructor(obj) {
|
|
@@ -3444,6 +3737,11 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3444
3737
|
* Returns true if the input is a class (requires `new` to instantiate). Distinguishes classes from regular functions
|
|
3445
3738
|
* by checking that the prototype is non-writable.
|
|
3446
3739
|
*
|
|
3740
|
+
* @dbxUtil
|
|
3741
|
+
* @dbxUtilCategory type
|
|
3742
|
+
* @dbxUtilTags type, type-guard, class, reflection, instance
|
|
3743
|
+
* @dbxUtilRelated is-object-with-constructor, get-function-type
|
|
3744
|
+
*
|
|
3447
3745
|
* @param obj - The value to check.
|
|
3448
3746
|
* @returns Whether the value is a class type.
|
|
3449
3747
|
*/ function isClassLikeType(obj) {
|
|
@@ -3454,6 +3752,11 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3454
3752
|
* Determines the function type of the input value: `'class'`, `'function'`, or `'arrow'`.
|
|
3455
3753
|
* Returns `null` if the input is not a function.
|
|
3456
3754
|
*
|
|
3755
|
+
* @dbxUtil
|
|
3756
|
+
* @dbxUtilCategory type
|
|
3757
|
+
* @dbxUtilTags type, function, class, arrow, reflection, kind, detect
|
|
3758
|
+
* @dbxUtilRelated is-class-like-type, is-non-class-function, is-object-with-constructor
|
|
3759
|
+
*
|
|
3457
3760
|
* @param x - The value to inspect.
|
|
3458
3761
|
* @returns The {@link FunctionType}, or `null` for non-functions.
|
|
3459
3762
|
*/ function getFunctionType(x) {
|
|
@@ -3464,6 +3767,11 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3464
3767
|
/**
|
|
3465
3768
|
* Returns true if the input is a function but not a class (i.e., a regular function or arrow function).
|
|
3466
3769
|
*
|
|
3770
|
+
* @dbxUtil
|
|
3771
|
+
* @dbxUtilCategory type
|
|
3772
|
+
* @dbxUtilTags type, type-guard, function, arrow, reflection, callable
|
|
3773
|
+
* @dbxUtilRelated is-class-like-type, get-function-type
|
|
3774
|
+
*
|
|
3467
3775
|
* @param x - The value to check.
|
|
3468
3776
|
* @returns Whether the value is a non-class function.
|
|
3469
3777
|
*/ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
@@ -3479,6 +3787,11 @@ function _type_of$j(obj) {
|
|
|
3479
3787
|
/**
|
|
3480
3788
|
* Returns true if the input value is a non-class function (i.e., likely a Getter).
|
|
3481
3789
|
*
|
|
3790
|
+
* @dbxUtil
|
|
3791
|
+
* @dbxUtilCategory getter
|
|
3792
|
+
* @dbxUtilTags getter, type-guard, function, callable, check
|
|
3793
|
+
* @dbxUtilRelated as-getter, get-value-from-getter
|
|
3794
|
+
*
|
|
3482
3795
|
* @param value - The value to check
|
|
3483
3796
|
* @returns True if the value is a non-class function
|
|
3484
3797
|
*/ function isGetter(value) {
|
|
@@ -3490,6 +3803,11 @@ function getValueFromGetter(input, args) {
|
|
|
3490
3803
|
/**
|
|
3491
3804
|
* Wraps the input as a Getter function. If it's already a function, returns it directly.
|
|
3492
3805
|
*
|
|
3806
|
+
* @dbxUtil
|
|
3807
|
+
* @dbxUtilCategory getter
|
|
3808
|
+
* @dbxUtilTags getter, factory, wrap, ensure, normalize
|
|
3809
|
+
* @dbxUtilRelated get-value-from-getter, is-getter
|
|
3810
|
+
*
|
|
3493
3811
|
* @param input - A value or getter function
|
|
3494
3812
|
* @returns A Getter function that returns the value
|
|
3495
3813
|
*/ function asGetter(input) {
|
|
@@ -3500,6 +3818,12 @@ function getValueFromGetter(input, args) {
|
|
|
3500
3818
|
/**
|
|
3501
3819
|
* Creates a factory that returns a shallow copy of the input value on each call.
|
|
3502
3820
|
*
|
|
3821
|
+
* @dbxUtil
|
|
3822
|
+
* @dbxUtilCategory getter
|
|
3823
|
+
* @dbxUtilKind factory
|
|
3824
|
+
* @dbxUtilTags getter, factory, copy, clone, object
|
|
3825
|
+
* @dbxUtilRelated as-object-copy-factory, copy-object
|
|
3826
|
+
*
|
|
3503
3827
|
* @param value - The object to copy
|
|
3504
3828
|
* @param copyFunction - Optional custom copy function (defaults to copyObject)
|
|
3505
3829
|
* @returns A factory that produces copies of the value
|
|
@@ -3596,6 +3920,12 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3596
3920
|
/**
|
|
3597
3921
|
* Creates a function that checks whether a number falls within the specified inclusive bounds.
|
|
3598
3922
|
*
|
|
3923
|
+
* @dbxUtil
|
|
3924
|
+
* @dbxUtilCategory number
|
|
3925
|
+
* @dbxUtilKind factory
|
|
3926
|
+
* @dbxUtilTags number, bound, range, between, check, inclusive, factory
|
|
3927
|
+
* @dbxUtilRelated bound-number-function, bound-number, is-valid-number-bound
|
|
3928
|
+
*
|
|
3599
3929
|
* @param bounds - The min/max bounds to test against
|
|
3600
3930
|
* @returns A function that returns `true` if the input number is within bounds
|
|
3601
3931
|
* @throws Error if the bounds are invalid (min > max)
|
|
@@ -3613,6 +3943,12 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3613
3943
|
*
|
|
3614
3944
|
* When `fencePosts` is true, wraps to the nearest "fence post" value, extending the wrap range by one in each direction.
|
|
3615
3945
|
*
|
|
3946
|
+
* @dbxUtil
|
|
3947
|
+
* @dbxUtilCategory number
|
|
3948
|
+
* @dbxUtilKind factory
|
|
3949
|
+
* @dbxUtilTags number, wrap, modulo, modular, range, factory, circular
|
|
3950
|
+
* @dbxUtilRelated bound-number-function, bound-number, is-in-number-bound-function
|
|
3951
|
+
*
|
|
3616
3952
|
* @param wrapNumberFunctionConfig - Configuration with min, max, and optional fence post behavior
|
|
3617
3953
|
* @returns A function that wraps input numbers into the bounded range
|
|
3618
3954
|
*/ function wrapNumberFunction(wrapNumberFunctionConfig) {
|
|
@@ -3638,6 +3974,12 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3638
3974
|
*
|
|
3639
3975
|
* When `wrap` is true, uses modular wrapping. Otherwise, clamps values to the min/max range.
|
|
3640
3976
|
*
|
|
3977
|
+
* @dbxUtil
|
|
3978
|
+
* @dbxUtilCategory number
|
|
3979
|
+
* @dbxUtilKind factory
|
|
3980
|
+
* @dbxUtilTags number, bound, clamp, wrap, range, factory, constrain
|
|
3981
|
+
* @dbxUtilRelated bound-number, wrap-number-function, is-in-number-bound-function
|
|
3982
|
+
*
|
|
3641
3983
|
* @param boundNumberFunctionConfig - Configuration with min, max, and optional wrap behavior
|
|
3642
3984
|
* @returns A function that bounds input numbers into the configured range
|
|
3643
3985
|
*/ function boundNumberFunction(boundNumberFunctionConfig) {
|
|
@@ -3649,6 +3991,11 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3649
3991
|
/**
|
|
3650
3992
|
* Clamps the input number between the min and max values (inclusive).
|
|
3651
3993
|
*
|
|
3994
|
+
* @dbxUtil
|
|
3995
|
+
* @dbxUtilCategory number
|
|
3996
|
+
* @dbxUtilTags number, clamp, bound, min, max, range, constrain
|
|
3997
|
+
* @dbxUtilRelated bound-number-function, wrap-number-function, is-in-number-bound-function
|
|
3998
|
+
*
|
|
3652
3999
|
* @param input - Number to clamp
|
|
3653
4000
|
* @param min - Minimum allowed value
|
|
3654
4001
|
* @param max - Maximum allowed value
|
|
@@ -3666,6 +4013,11 @@ function _type_of$i(obj) {
|
|
|
3666
4013
|
*
|
|
3667
4014
|
* Returns 0 for null/undefined input.
|
|
3668
4015
|
*
|
|
4016
|
+
* @dbxUtil
|
|
4017
|
+
* @dbxUtilCategory number
|
|
4018
|
+
* @dbxUtilTags number, percent, decimal, convert, ratio
|
|
4019
|
+
* @dbxUtilRelated percent-number-from-decimal
|
|
4020
|
+
*
|
|
3669
4021
|
* @param input - A percent number value (e.g., 5 means 5%)
|
|
3670
4022
|
* @returns The decimal equivalent
|
|
3671
4023
|
*/ function percentNumberToDecimal(input) {
|
|
@@ -3676,6 +4028,11 @@ function _type_of$i(obj) {
|
|
|
3676
4028
|
*
|
|
3677
4029
|
* Returns 0 for null/undefined input.
|
|
3678
4030
|
*
|
|
4031
|
+
* @dbxUtil
|
|
4032
|
+
* @dbxUtilCategory number
|
|
4033
|
+
* @dbxUtilTags number, percent, decimal, convert, ratio
|
|
4034
|
+
* @dbxUtilRelated percent-number-to-decimal
|
|
4035
|
+
*
|
|
3679
4036
|
* @param input - A decimal percent value (e.g., 0.05 means 5%)
|
|
3680
4037
|
* @returns The percent number equivalent
|
|
3681
4038
|
*/ function percentNumberFromDecimal(input) {
|
|
@@ -3686,6 +4043,10 @@ function _type_of$i(obj) {
|
|
|
3686
4043
|
*
|
|
3687
4044
|
* Strings are parsed via `Number()`. Null/undefined returns 0.
|
|
3688
4045
|
*
|
|
4046
|
+
* @dbxUtil
|
|
4047
|
+
* @dbxUtilCategory number
|
|
4048
|
+
* @dbxUtilTags number, parse, convert, coerce, string, normalize
|
|
4049
|
+
*
|
|
3689
4050
|
* @param input - A number, number string, or null/undefined
|
|
3690
4051
|
* @returns The numeric value, or 0 for null/undefined
|
|
3691
4052
|
*/ function asNumber(input) {
|
|
@@ -3708,6 +4069,11 @@ function _type_of$i(obj) {
|
|
|
3708
4069
|
*
|
|
3709
4070
|
* Treats null/undefined as 0.
|
|
3710
4071
|
*
|
|
4072
|
+
* @dbxUtil
|
|
4073
|
+
* @dbxUtilCategory number
|
|
4074
|
+
* @dbxUtilTags number, divisible, modulo, division, math, check
|
|
4075
|
+
* @dbxUtilRelated nearest-divisible-values, is-even-number, is-odd-number
|
|
4076
|
+
*
|
|
3711
4077
|
* @param value - The number to check
|
|
3712
4078
|
* @param divisor - The divisor to test against
|
|
3713
4079
|
* @returns `true` if the remainder is zero
|
|
@@ -3718,6 +4084,11 @@ function _type_of$i(obj) {
|
|
|
3718
4084
|
/**
|
|
3719
4085
|
* Finds the nearest values that are evenly divisible by the divisor, both above (ceil) and below (floor) the input value.
|
|
3720
4086
|
*
|
|
4087
|
+
* @dbxUtil
|
|
4088
|
+
* @dbxUtilCategory number
|
|
4089
|
+
* @dbxUtilTags number, divisible, nearest, ceil, floor, round, snap, math
|
|
4090
|
+
* @dbxUtilRelated is-number-divisible-by
|
|
4091
|
+
*
|
|
3721
4092
|
* @param value - The value to find divisible neighbors for
|
|
3722
4093
|
* @param divisor - The divisor to align to
|
|
3723
4094
|
* @returns Object with the input value, divisor, and the nearest ceil/floor divisible values
|
|
@@ -3735,6 +4106,11 @@ function _type_of$i(obj) {
|
|
|
3735
4106
|
/**
|
|
3736
4107
|
* Checks whether the input is an even number.
|
|
3737
4108
|
*
|
|
4109
|
+
* @dbxUtil
|
|
4110
|
+
* @dbxUtilCategory number
|
|
4111
|
+
* @dbxUtilTags number, even, parity, math, check
|
|
4112
|
+
* @dbxUtilRelated is-odd-number, is-number-divisible-by
|
|
4113
|
+
*
|
|
3738
4114
|
* @param value - Number to test
|
|
3739
4115
|
* @returns `true` if even
|
|
3740
4116
|
*/ function isEvenNumber(value) {
|
|
@@ -3743,6 +4119,11 @@ function _type_of$i(obj) {
|
|
|
3743
4119
|
/**
|
|
3744
4120
|
* Checks whether the input is an odd number.
|
|
3745
4121
|
*
|
|
4122
|
+
* @dbxUtil
|
|
4123
|
+
* @dbxUtilCategory number
|
|
4124
|
+
* @dbxUtilTags number, odd, parity, math, check
|
|
4125
|
+
* @dbxUtilRelated is-even-number, is-number-divisible-by
|
|
4126
|
+
*
|
|
3746
4127
|
* @param value - Number to test
|
|
3747
4128
|
* @returns `true` if odd
|
|
3748
4129
|
*/ function isOddNumber(value) {
|
|
@@ -3753,6 +4134,10 @@ function _type_of$i(obj) {
|
|
|
3753
4134
|
*
|
|
3754
4135
|
* The `from` value is floored and the `to` value is ceiled before computation.
|
|
3755
4136
|
*
|
|
4137
|
+
* @dbxUtil
|
|
4138
|
+
* @dbxUtilCategory number
|
|
4139
|
+
* @dbxUtilTags number, sum, range, integers, math, gauss, total
|
|
4140
|
+
*
|
|
3756
4141
|
* @param from - The starting value (floored to nearest integer)
|
|
3757
4142
|
* @param to - The ending value (ceiled to nearest integer)
|
|
3758
4143
|
* @returns Sum of all integers in the range
|
|
@@ -3775,6 +4160,11 @@ function _type_of$i(obj) {
|
|
|
3775
4160
|
/**
|
|
3776
4161
|
* Finds the minimum and maximum values from an iterable of numbers.
|
|
3777
4162
|
*
|
|
4163
|
+
* @dbxUtil
|
|
4164
|
+
* @dbxUtilCategory number
|
|
4165
|
+
* @dbxUtilTags number, min, max, range, sort, bounds, extremes
|
|
4166
|
+
* @dbxUtilRelated sort-compare-number-function
|
|
4167
|
+
*
|
|
3778
4168
|
* @param values - Iterable of numbers to examine
|
|
3779
4169
|
* @returns Object with `min` and `max` values
|
|
3780
4170
|
*/ function minAndMaxNumber(values) {
|
|
@@ -3783,6 +4173,10 @@ function _type_of$i(obj) {
|
|
|
3783
4173
|
/**
|
|
3784
4174
|
* Computes the logarithm of `y` with base `x`.
|
|
3785
4175
|
*
|
|
4176
|
+
* @dbxUtil
|
|
4177
|
+
* @dbxUtilCategory number
|
|
4178
|
+
* @dbxUtilTags number, log, logarithm, math, base
|
|
4179
|
+
*
|
|
3786
4180
|
* @param x - The base of the logarithm
|
|
3787
4181
|
* @param y - The value to compute the logarithm of
|
|
3788
4182
|
* @returns The base-x logarithm of y
|
|
@@ -3803,6 +4197,12 @@ function _type_of$h(obj) {
|
|
|
3803
4197
|
/**
|
|
3804
4198
|
* Returns a rounding function for the specified rounding type.
|
|
3805
4199
|
*
|
|
4200
|
+
* @dbxUtil
|
|
4201
|
+
* @dbxUtilCategory number
|
|
4202
|
+
* @dbxUtilKind factory
|
|
4203
|
+
* @dbxUtilTags number, round, floor, ceil, math, factory, rounding
|
|
4204
|
+
* @dbxUtilRelated cut-value-to-precision-function, round-to-precision-function
|
|
4205
|
+
*
|
|
3806
4206
|
* @param type - The rounding strategy: 'floor', 'ceil', 'round', or 'none'
|
|
3807
4207
|
* @returns The corresponding Math function, or an identity function for 'none'
|
|
3808
4208
|
*/ function roundingFunction(type) {
|
|
@@ -3831,6 +4231,11 @@ function _type_of$h(obj) {
|
|
|
3831
4231
|
*
|
|
3832
4232
|
* Accepts strings and null/undefined via {@link asNumber}.
|
|
3833
4233
|
*
|
|
4234
|
+
* @dbxUtil
|
|
4235
|
+
* @dbxUtilCategory number
|
|
4236
|
+
* @dbxUtilTags number, precision, decimal, truncate, cut, round
|
|
4237
|
+
* @dbxUtilRelated cut-value-to-precision-function, cut-value-to-integer, round-to-precision
|
|
4238
|
+
*
|
|
3834
4239
|
* @param input - Number, number string, or null/undefined
|
|
3835
4240
|
* @param precision - Number of decimal places to retain
|
|
3836
4241
|
* @returns The truncated number value
|
|
@@ -3843,6 +4248,11 @@ function _type_of$h(obj) {
|
|
|
3843
4248
|
/**
|
|
3844
4249
|
* Truncates a value to an integer by cutting to zero decimal precision.
|
|
3845
4250
|
*
|
|
4251
|
+
* @dbxUtil
|
|
4252
|
+
* @dbxUtilCategory number
|
|
4253
|
+
* @dbxUtilTags number, integer, truncate, floor, cut, parse
|
|
4254
|
+
* @dbxUtilRelated cut-value-to-precision, as-number
|
|
4255
|
+
*
|
|
3846
4256
|
* @param input - Number, number string, or null/undefined
|
|
3847
4257
|
* @returns The truncated integer value
|
|
3848
4258
|
*/ function cutValueToInteger(input) {
|
|
@@ -3991,6 +4401,12 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
3991
4401
|
*
|
|
3992
4402
|
* Accepts either a simple max number or a full config object with min, max, and rounding options.
|
|
3993
4403
|
*
|
|
4404
|
+
* @dbxUtil
|
|
4405
|
+
* @dbxUtilCategory number
|
|
4406
|
+
* @dbxUtilKind factory
|
|
4407
|
+
* @dbxUtilTags number, random, factory, range, min, max, generate
|
|
4408
|
+
* @dbxUtilRelated random-number, rounding-function
|
|
4409
|
+
*
|
|
3994
4410
|
* @param maxOrArgs - Maximum value (exclusive) or full configuration object
|
|
3995
4411
|
* @param roundingInput - Optional rounding mode override
|
|
3996
4412
|
* @returns A factory function that produces random numbers within the range
|
|
@@ -4024,6 +4440,11 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4024
4440
|
/**
|
|
4025
4441
|
* Generates a single random number using {@link randomNumberFactory}. Convenience function for one-off usage.
|
|
4026
4442
|
*
|
|
4443
|
+
* @dbxUtil
|
|
4444
|
+
* @dbxUtilCategory number
|
|
4445
|
+
* @dbxUtilTags number, random, range, generate
|
|
4446
|
+
* @dbxUtilRelated random-number-factory
|
|
4447
|
+
*
|
|
4027
4448
|
* @param maxOrArgs - Maximum value (exclusive) or full configuration object
|
|
4028
4449
|
* @param roundingInput - Optional rounding mode
|
|
4029
4450
|
* @returns A single random number
|
|
@@ -5037,6 +5458,12 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5037
5458
|
/**
|
|
5038
5459
|
* Creates a new ArrayFactory that generates multiple values.
|
|
5039
5460
|
*
|
|
5461
|
+
* @dbxUtil
|
|
5462
|
+
* @dbxUtilCategory array
|
|
5463
|
+
* @dbxUtilKind factory
|
|
5464
|
+
* @dbxUtilTags array, factory, generate, make, build, create
|
|
5465
|
+
* @dbxUtilRelated array-input-factory, terminating-factory-from-array
|
|
5466
|
+
*
|
|
5040
5467
|
* @param factory - The factory function used to generate each item
|
|
5041
5468
|
* @returns A function that takes a count parameter and returns an array of generated items
|
|
5042
5469
|
*/ function arrayFactory(factory) {
|
|
@@ -5047,6 +5474,12 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5047
5474
|
/**
|
|
5048
5475
|
* Creates an ArrayInputFactory that transforms input values into output values.
|
|
5049
5476
|
*
|
|
5477
|
+
* @dbxUtil
|
|
5478
|
+
* @dbxUtilCategory array
|
|
5479
|
+
* @dbxUtilKind factory
|
|
5480
|
+
* @dbxUtilTags array, factory, transform, map, generate, build
|
|
5481
|
+
* @dbxUtilRelated array-factory
|
|
5482
|
+
*
|
|
5050
5483
|
* @param factory - The factory function used to transform each input value
|
|
5051
5484
|
* @returns A function that takes an array of input values and returns an array of output values
|
|
5052
5485
|
*/ function arrayInputFactory(factory) {
|
|
@@ -5305,6 +5738,12 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5305
5738
|
/**
|
|
5306
5739
|
* Creates a {@link RandomPickFactory} from the input values.
|
|
5307
5740
|
*
|
|
5741
|
+
* @dbxUtil
|
|
5742
|
+
* @dbxUtilCategory array
|
|
5743
|
+
* @dbxUtilKind factory
|
|
5744
|
+
* @dbxUtilTags array, random, pick, sample, choose, factory
|
|
5745
|
+
* @dbxUtilRelated pick-one-randomly, random-array-index
|
|
5746
|
+
*
|
|
5308
5747
|
* @param values - array of values to randomly pick from
|
|
5309
5748
|
* @returns a callable factory that returns a random value from the array on each invocation
|
|
5310
5749
|
* @throws Error if the input array is empty
|
|
@@ -5322,6 +5761,11 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5322
5761
|
/**
|
|
5323
5762
|
* Returns a random index from the input array. Returns 0 if the array is empty.
|
|
5324
5763
|
*
|
|
5764
|
+
* @dbxUtil
|
|
5765
|
+
* @dbxUtilCategory array
|
|
5766
|
+
* @dbxUtilTags array, random, index, position
|
|
5767
|
+
* @dbxUtilRelated pick-one-randomly, random-pick-factory
|
|
5768
|
+
*
|
|
5325
5769
|
* @param values - array to generate a random index for
|
|
5326
5770
|
* @returns a random valid index within the array, or 0 if the array is empty
|
|
5327
5771
|
*/ function randomArrayIndex(values) {
|
|
@@ -5330,6 +5774,11 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5330
5774
|
/**
|
|
5331
5775
|
* Picks a single item randomly from the input array.
|
|
5332
5776
|
*
|
|
5777
|
+
* @dbxUtil
|
|
5778
|
+
* @dbxUtilCategory array
|
|
5779
|
+
* @dbxUtilTags array, random, pick, sample, choose
|
|
5780
|
+
* @dbxUtilRelated random-pick-factory, random-array-index
|
|
5781
|
+
*
|
|
5333
5782
|
* @param values - array to pick a random item from
|
|
5334
5783
|
* @returns a randomly selected item from the array
|
|
5335
5784
|
* @throws Error if the input array is empty
|
|
@@ -5341,6 +5790,11 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5341
5790
|
/**
|
|
5342
5791
|
* Returns items that exist in both arrays (intersection).
|
|
5343
5792
|
*
|
|
5793
|
+
* @dbxUtil
|
|
5794
|
+
* @dbxUtilCategory array
|
|
5795
|
+
* @dbxUtilTags array, set, intersection, intersect, keep, common, both
|
|
5796
|
+
* @dbxUtilRelated exclude-values-from-array
|
|
5797
|
+
*
|
|
5344
5798
|
* @param values - The source array to filter.
|
|
5345
5799
|
* @param secondArray - The array of values to keep.
|
|
5346
5800
|
* @returns A new array containing only the values from `values` that also exist in `secondArray`.
|
|
@@ -5350,6 +5804,11 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5350
5804
|
/**
|
|
5351
5805
|
* Returns items from the first array that do not exist in the second array (difference).
|
|
5352
5806
|
*
|
|
5807
|
+
* @dbxUtil
|
|
5808
|
+
* @dbxUtilCategory array
|
|
5809
|
+
* @dbxUtilTags array, set, difference, exclude, subtract, diff
|
|
5810
|
+
* @dbxUtilRelated keep-values-from-array
|
|
5811
|
+
*
|
|
5353
5812
|
* @param values - The source array to filter.
|
|
5354
5813
|
* @param secondArray - The array of values to exclude.
|
|
5355
5814
|
* @returns A new array containing only the values from `values` that do not exist in `secondArray`.
|
|
@@ -5359,6 +5818,11 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5359
5818
|
/**
|
|
5360
5819
|
* Checks whether the given array contains any duplicate values.
|
|
5361
5820
|
*
|
|
5821
|
+
* @dbxUtil
|
|
5822
|
+
* @dbxUtilCategory array
|
|
5823
|
+
* @dbxUtilTags array, duplicate, check, validation, set
|
|
5824
|
+
* @dbxUtilRelated find-index-of-first-duplicate-value, unique
|
|
5825
|
+
*
|
|
5362
5826
|
* @param values - The array to check for duplicates.
|
|
5363
5827
|
* @returns `true` if the array contains at least one duplicate value, `false` otherwise.
|
|
5364
5828
|
*/ function arrayContainsDuplicateValue(values) {
|
|
@@ -5367,6 +5831,11 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5367
5831
|
/**
|
|
5368
5832
|
* Finds the index of the first duplicate value in the given array.
|
|
5369
5833
|
*
|
|
5834
|
+
* @dbxUtil
|
|
5835
|
+
* @dbxUtilCategory array
|
|
5836
|
+
* @dbxUtilTags array, duplicate, find, index, search
|
|
5837
|
+
* @dbxUtilRelated array-contains-duplicate-value, unique
|
|
5838
|
+
*
|
|
5370
5839
|
* @param values - The array to search for duplicates.
|
|
5371
5840
|
* @returns The index of the first value that is a duplicate of an earlier value, or `-1` if no duplicates exist.
|
|
5372
5841
|
*/ function findIndexOfFirstDuplicateValue(values) {
|
|
@@ -5403,6 +5872,11 @@ function joinStrings(input) {
|
|
|
5403
5872
|
* Splits a string like {@link String.prototype.split}, but joins overflow segments back together
|
|
5404
5873
|
* instead of discarding them. Useful when you only want to split on the first N-1 occurrences.
|
|
5405
5874
|
*
|
|
5875
|
+
* @dbxUtil
|
|
5876
|
+
* @dbxUtilCategory string
|
|
5877
|
+
* @dbxUtilTags string, split, limit, separator, parts, segments
|
|
5878
|
+
* @dbxUtilRelated join-strings, string-split-join-instance
|
|
5879
|
+
*
|
|
5406
5880
|
* @param input - string to split
|
|
5407
5881
|
* @param separator - delimiter to split on
|
|
5408
5882
|
* @param limit - maximum number of resulting segments; overflow segments are rejoined with the separator
|
|
@@ -5515,6 +5989,11 @@ function caseInsensitiveString(input) {
|
|
|
5515
5989
|
/**
|
|
5516
5990
|
* Capitalizes the first letter of the input string.
|
|
5517
5991
|
*
|
|
5992
|
+
* @dbxUtil
|
|
5993
|
+
* @dbxUtilCategory string
|
|
5994
|
+
* @dbxUtilTags string, capitalize, case, uppercase, first
|
|
5995
|
+
* @dbxUtilRelated lowercase-first-letter, case-insensitive-string
|
|
5996
|
+
*
|
|
5518
5997
|
* @param value - string to capitalize
|
|
5519
5998
|
* @returns the input string with its first character uppercased
|
|
5520
5999
|
*/ function capitalizeFirstLetter(value) {
|
|
@@ -5523,6 +6002,11 @@ function caseInsensitiveString(input) {
|
|
|
5523
6002
|
/**
|
|
5524
6003
|
* Lowercases the first letter of the input string.
|
|
5525
6004
|
*
|
|
6005
|
+
* @dbxUtil
|
|
6006
|
+
* @dbxUtilCategory string
|
|
6007
|
+
* @dbxUtilTags string, lowercase, case, first, decapitalize
|
|
6008
|
+
* @dbxUtilRelated capitalize-first-letter, case-insensitive-string
|
|
6009
|
+
*
|
|
5526
6010
|
* @param value - string to modify
|
|
5527
6011
|
* @returns the input string with its first character lowercased
|
|
5528
6012
|
*/ function lowercaseFirstLetter(value) {
|
|
@@ -5532,6 +6016,11 @@ function caseInsensitiveString(input) {
|
|
|
5532
6016
|
* Splits the input string into a first name and last name tuple using a space as the delimiter.
|
|
5533
6017
|
* If the name contains more than one space, the remainder is treated as the last name.
|
|
5534
6018
|
*
|
|
6019
|
+
* @dbxUtil
|
|
6020
|
+
* @dbxUtilCategory string
|
|
6021
|
+
* @dbxUtilTags string, name, split, first, last, person, parse
|
|
6022
|
+
* @dbxUtilRelated split-join-remainder
|
|
6023
|
+
*
|
|
5535
6024
|
* @param input - full name string to split
|
|
5536
6025
|
* @returns a tuple of [firstName, lastName], where lastName includes all text after the first space
|
|
5537
6026
|
*/ function splitJoinNameString(input) {
|
|
@@ -5540,6 +6029,10 @@ function caseInsensitiveString(input) {
|
|
|
5540
6029
|
/**
|
|
5541
6030
|
* Creates a string that repeats the given string a specified number of times.
|
|
5542
6031
|
*
|
|
6032
|
+
* @dbxUtil
|
|
6033
|
+
* @dbxUtilCategory string
|
|
6034
|
+
* @dbxUtilTags string, repeat, build, generate, fill
|
|
6035
|
+
*
|
|
5543
6036
|
* @param string - the string to repeat
|
|
5544
6037
|
* @param reapeat - number of times to repeat the string
|
|
5545
6038
|
* @returns the repeated string concatenation
|
|
@@ -5556,6 +6049,11 @@ function caseInsensitiveString(input) {
|
|
|
5556
6049
|
/**
|
|
5557
6050
|
* Creates a {@link CutStringFunction} that truncates strings exceeding the configured maximum length.
|
|
5558
6051
|
*
|
|
6052
|
+
* @dbxUtil
|
|
6053
|
+
* @dbxUtilCategory string
|
|
6054
|
+
* @dbxUtilKind factory
|
|
6055
|
+
* @dbxUtilTags string, cut, truncate, ellipsis, max-length, factory, abbreviate
|
|
6056
|
+
*
|
|
5559
6057
|
* @param config - configuration controlling max length and end text behavior
|
|
5560
6058
|
* @returns a reusable function that truncates input strings
|
|
5561
6059
|
*/ function cutStringFunction(config) {
|
|
@@ -5578,6 +6076,11 @@ function caseInsensitiveString(input) {
|
|
|
5578
6076
|
/**
|
|
5579
6077
|
* Truncates a string to the given maximum length, appending end text (defaults to "...") if truncated.
|
|
5580
6078
|
*
|
|
6079
|
+
* @dbxUtil
|
|
6080
|
+
* @dbxUtilCategory string
|
|
6081
|
+
* @dbxUtilTags string, cut, truncate, ellipsis, max-length, abbreviate, shorten
|
|
6082
|
+
* @dbxUtilRelated cut-string-function
|
|
6083
|
+
*
|
|
5581
6084
|
* @param input - the string to truncate, or null/undefined
|
|
5582
6085
|
* @param maxLength - maximum allowed length for the output string
|
|
5583
6086
|
* @param endText - text to append when truncated; defaults to "..."
|
|
@@ -5593,6 +6096,11 @@ function caseInsensitiveString(input) {
|
|
|
5593
6096
|
*
|
|
5594
6097
|
* Newlines are preserved.
|
|
5595
6098
|
*
|
|
6099
|
+
* @dbxUtil
|
|
6100
|
+
* @dbxUtilCategory string
|
|
6101
|
+
* @dbxUtilTags string, whitespace, flatten, collapse, normalize, trim
|
|
6102
|
+
* @dbxUtilRelated simplify-whitespace
|
|
6103
|
+
*
|
|
5596
6104
|
* @param input - string to flatten
|
|
5597
6105
|
* @returns the string with collapsed whitespace
|
|
5598
6106
|
*/ function flattenWhitespace(input) {
|
|
@@ -5601,6 +6109,11 @@ function caseInsensitiveString(input) {
|
|
|
5601
6109
|
/**
|
|
5602
6110
|
* Reduces multiple consecutive newlines to a single newline and collapses multiple whitespace characters to a single space.
|
|
5603
6111
|
*
|
|
6112
|
+
* @dbxUtil
|
|
6113
|
+
* @dbxUtilCategory string
|
|
6114
|
+
* @dbxUtilTags string, whitespace, simplify, normalize, newline, trim
|
|
6115
|
+
* @dbxUtilRelated flatten-whitespace
|
|
6116
|
+
*
|
|
5604
6117
|
* @param input - string to simplify
|
|
5605
6118
|
* @returns the string with simplified whitespace and newlines
|
|
5606
6119
|
*/ function simplifyWhitespace(input) {
|
|
@@ -5992,7 +6505,7 @@ function _create_class$6(Constructor, protoProps, staticProps) {
|
|
|
5992
6505
|
if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
|
|
5993
6506
|
return Constructor;
|
|
5994
6507
|
}
|
|
5995
|
-
function _define_property$
|
|
6508
|
+
function _define_property$k(obj, key, value) {
|
|
5996
6509
|
if (key in obj) {
|
|
5997
6510
|
Object.defineProperty(obj, key, {
|
|
5998
6511
|
value: value,
|
|
@@ -6062,7 +6575,7 @@ function _is_native_reflect_construct$4() {
|
|
|
6062
6575
|
var _this;
|
|
6063
6576
|
_this = _call_super$4(this, AssertionError, [
|
|
6064
6577
|
message
|
|
6065
|
-
]), _define_property$
|
|
6578
|
+
]), _define_property$k(_this, "code", ASSERTION_ERROR_CODE), _define_property$k(_this, "_target", void 0), _define_property$k(_this, "_property", void 0);
|
|
6066
6579
|
_this.name = 'AssertionError';
|
|
6067
6580
|
_this._target = error.target;
|
|
6068
6581
|
_this._property = error.propertyKey;
|
|
@@ -6167,7 +6680,7 @@ function _create_class$5(Constructor, protoProps, staticProps) {
|
|
|
6167
6680
|
if (staticProps) _defineProperties$5(Constructor, staticProps);
|
|
6168
6681
|
return Constructor;
|
|
6169
6682
|
}
|
|
6170
|
-
function _define_property$
|
|
6683
|
+
function _define_property$j(obj, key, value) {
|
|
6171
6684
|
if (key in obj) {
|
|
6172
6685
|
Object.defineProperty(obj, key, {
|
|
6173
6686
|
value: value,
|
|
@@ -6180,7 +6693,7 @@ function _define_property$i(obj, key, value) {
|
|
|
6180
6693
|
}
|
|
6181
6694
|
return obj;
|
|
6182
6695
|
}
|
|
6183
|
-
function _object_spread$
|
|
6696
|
+
function _object_spread$f(target) {
|
|
6184
6697
|
for(var i = 1; i < arguments.length; i++){
|
|
6185
6698
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
6186
6699
|
var ownKeys = Object.keys(source);
|
|
@@ -6190,7 +6703,7 @@ function _object_spread$e(target) {
|
|
|
6190
6703
|
}));
|
|
6191
6704
|
}
|
|
6192
6705
|
ownKeys.forEach(function(key) {
|
|
6193
|
-
_define_property$
|
|
6706
|
+
_define_property$j(target, key, source[key]);
|
|
6194
6707
|
});
|
|
6195
6708
|
}
|
|
6196
6709
|
return target;
|
|
@@ -6217,7 +6730,7 @@ function _object_spread$e(target) {
|
|
|
6217
6730
|
* @returns A property descriptor interceptor function
|
|
6218
6731
|
*/ function makePropertyDescriptorAssertion(assertValueFn, options, defaultOptions) {
|
|
6219
6732
|
// Build options
|
|
6220
|
-
options = _object_spread$
|
|
6733
|
+
options = _object_spread$f({}, defaultOptions, options);
|
|
6221
6734
|
return this.makeSetPropertyDescriptorInterceptor(function(param) {
|
|
6222
6735
|
var target = param.target, propertyKey = param.propertyKey, setValue = param.setValue;
|
|
6223
6736
|
var _options_map;
|
|
@@ -6703,7 +7216,7 @@ function _array_like_to_array$q(arr, len) {
|
|
|
6703
7216
|
function _array_with_holes$i(arr) {
|
|
6704
7217
|
if (Array.isArray(arr)) return arr;
|
|
6705
7218
|
}
|
|
6706
|
-
function _define_property$
|
|
7219
|
+
function _define_property$i(obj, key, value) {
|
|
6707
7220
|
if (key in obj) {
|
|
6708
7221
|
Object.defineProperty(obj, key, {
|
|
6709
7222
|
value: value,
|
|
@@ -6743,7 +7256,7 @@ function _iterable_to_array_limit$i(arr, i) {
|
|
|
6743
7256
|
function _non_iterable_rest$i() {
|
|
6744
7257
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6745
7258
|
}
|
|
6746
|
-
function _object_spread$
|
|
7259
|
+
function _object_spread$e(target) {
|
|
6747
7260
|
for(var i = 1; i < arguments.length; i++){
|
|
6748
7261
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
6749
7262
|
var ownKeys = Object.keys(source);
|
|
@@ -6753,7 +7266,7 @@ function _object_spread$d(target) {
|
|
|
6753
7266
|
}));
|
|
6754
7267
|
}
|
|
6755
7268
|
ownKeys.forEach(function(key) {
|
|
6756
|
-
_define_property$
|
|
7269
|
+
_define_property$i(target, key, source[key]);
|
|
6757
7270
|
});
|
|
6758
7271
|
}
|
|
6759
7272
|
return target;
|
|
@@ -6774,8 +7287,22 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
6774
7287
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$q(o, minLen);
|
|
6775
7288
|
}
|
|
6776
7289
|
/**
|
|
7290
|
+
* Creates a reusable {@link StripObjectFunction} that filters values from an object and returns
|
|
7291
|
+
* `undefined` when no keys remain after filtering.
|
|
6777
7292
|
*
|
|
6778
|
-
*
|
|
7293
|
+
* Useful when an upstream consumer treats an "empty" object as a missing value (e.g. for skipping
|
|
7294
|
+
* persistence or omitting a field from a request body).
|
|
7295
|
+
*
|
|
7296
|
+
* @param filter - Filter controlling which key/value pairs are removed from the input object.
|
|
7297
|
+
* @param copy - When true (default), the returned function shallow-copies the input before filtering instead of mutating it.
|
|
7298
|
+
* @returns A function that returns the stripped object, or `undefined` when filtering removed every key.
|
|
7299
|
+
*
|
|
7300
|
+
* @example
|
|
7301
|
+
* ```ts
|
|
7302
|
+
* const stripUndef = stripObjectFunction(KeyValueTypleValueFilter.UNDEFINED);
|
|
7303
|
+
* stripUndef({ a: 1, b: undefined }); // { a: 1 }
|
|
7304
|
+
* stripUndef({ a: undefined }); // undefined
|
|
7305
|
+
* ```
|
|
6779
7306
|
*/ function stripObjectFunction(filter) {
|
|
6780
7307
|
var copy = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
6781
7308
|
var filterFn = filterFromPOJOFunction({
|
|
@@ -6791,7 +7318,22 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
6791
7318
|
return result;
|
|
6792
7319
|
};
|
|
6793
7320
|
}
|
|
6794
|
-
|
|
7321
|
+
/**
|
|
7322
|
+
* Removes `undefined` values from the input object and returns `undefined` when no keys remain.
|
|
7323
|
+
*
|
|
7324
|
+
* Convenience wrapper around {@link stripObjectFunction} pre-configured to filter out `undefined`.
|
|
7325
|
+
*
|
|
7326
|
+
* @param input - The object to strip; null/undefined inputs short-circuit and return `undefined`.
|
|
7327
|
+
* @param copy - When true (default), shallow-copies the input before filtering instead of mutating it.
|
|
7328
|
+
* @returns The stripped object, or `undefined` when input was missing or filtering removed every key.
|
|
7329
|
+
*
|
|
7330
|
+
* @example
|
|
7331
|
+
* ```ts
|
|
7332
|
+
* stripObject({ a: 1, b: undefined }); // { a: 1 }
|
|
7333
|
+
* stripObject({ a: undefined }); // undefined
|
|
7334
|
+
* stripObject(null); // undefined
|
|
7335
|
+
* ```
|
|
7336
|
+
*/ function stripObject(input, copy) {
|
|
6795
7337
|
return stripObjectFunction(exports.KeyValueTypleValueFilter.UNDEFINED, copy)(input);
|
|
6796
7338
|
}
|
|
6797
7339
|
// MARK: Object Merging/Overriding
|
|
@@ -6859,7 +7401,7 @@ function stripObject(input, copy) {
|
|
|
6859
7401
|
var rebuildTemplate = function rebuildTemplate() {
|
|
6860
7402
|
var template = {};
|
|
6861
7403
|
from.forEach(function(x) {
|
|
6862
|
-
var relevantValues = filterToRelevantValuesObject(_object_spread$
|
|
7404
|
+
var relevantValues = filterToRelevantValuesObject(_object_spread$e({}, x));
|
|
6863
7405
|
Object.assign(template, relevantValues);
|
|
6864
7406
|
});
|
|
6865
7407
|
return template;
|
|
@@ -7217,7 +7759,7 @@ function stripObject(input, copy) {
|
|
|
7217
7759
|
return function(obj, copyOverride) {
|
|
7218
7760
|
var copyObj = typeof copyOverride === 'boolean' ? copyOverride : copy;
|
|
7219
7761
|
if (copyObj) {
|
|
7220
|
-
obj = _object_spread$
|
|
7762
|
+
obj = _object_spread$e({}, obj);
|
|
7221
7763
|
}
|
|
7222
7764
|
forEachFn(obj);
|
|
7223
7765
|
return obj;
|
|
@@ -7293,7 +7835,7 @@ function stripObject(input, copy) {
|
|
|
7293
7835
|
});
|
|
7294
7836
|
var fn = function fn(inputTarget, obj) {
|
|
7295
7837
|
var returnCopy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : copy;
|
|
7296
|
-
var target = returnCopy ? _object_spread$
|
|
7838
|
+
var target = returnCopy ? _object_spread$e({}, inputTarget) : inputTarget;
|
|
7297
7839
|
assignEachValueToTarget(obj, target);
|
|
7298
7840
|
return target;
|
|
7299
7841
|
};
|
|
@@ -7745,33 +8287,1495 @@ var AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE = null;
|
|
|
7745
8287
|
addToSet(roles, decodedRoles);
|
|
7746
8288
|
}
|
|
7747
8289
|
}
|
|
7748
|
-
});
|
|
7749
|
-
var toRoles = function toRoles(claims) {
|
|
7750
|
-
var roles = new Set();
|
|
7751
|
-
forEachKeyValueAddToSet(claims, roles);
|
|
7752
|
-
return roles;
|
|
7753
|
-
};
|
|
7754
|
-
return {
|
|
7755
|
-
toClaims: toClaims,
|
|
7756
|
-
toRoles: toRoles,
|
|
7757
|
-
defaultClaimValue: defaultClaimValue,
|
|
7758
|
-
defaultEmptyValue: defaultEmptyValue
|
|
8290
|
+
});
|
|
8291
|
+
var toRoles = function toRoles(claims) {
|
|
8292
|
+
var roles = new Set();
|
|
8293
|
+
forEachKeyValueAddToSet(claims, roles);
|
|
8294
|
+
return roles;
|
|
8295
|
+
};
|
|
8296
|
+
return {
|
|
8297
|
+
toClaims: toClaims,
|
|
8298
|
+
toRoles: toRoles,
|
|
8299
|
+
defaultClaimValue: defaultClaimValue,
|
|
8300
|
+
defaultEmptyValue: defaultEmptyValue
|
|
8301
|
+
};
|
|
8302
|
+
}
|
|
8303
|
+
/**
|
|
8304
|
+
* Converts an {@link AuthClaimsUpdate} to {@link AuthClaims} by stripping all null-valued keys.
|
|
8305
|
+
*
|
|
8306
|
+
* Useful for cleaning up a claims update before persisting or comparing, since update objects
|
|
8307
|
+
* use `null` to indicate claim removal.
|
|
8308
|
+
*
|
|
8309
|
+
* @param authClaimsUpdate - The claims update object potentially containing null values
|
|
8310
|
+
* @returns A clean claims object with all null entries removed
|
|
8311
|
+
*/ function authClaims(authClaimsUpdate) {
|
|
8312
|
+
return filterFromPOJO(authClaimsUpdate, {
|
|
8313
|
+
filter: {
|
|
8314
|
+
valueFilter: exports.KeyValueTypleValueFilter.NULL
|
|
8315
|
+
}
|
|
8316
|
+
});
|
|
8317
|
+
}
|
|
8318
|
+
|
|
8319
|
+
/**
|
|
8320
|
+
* Standard "out-of-band" OAuth 2.0 redirect URI URN.
|
|
8321
|
+
*
|
|
8322
|
+
* Defined by RFC 6749 §1.3 / draft-ietf-oauth-native-apps. Used by native and CLI clients that
|
|
8323
|
+
* have no HTTP server to receive the redirect — the authorization server displays the
|
|
8324
|
+
* authorization code on a final page and the user pastes it back into the application.
|
|
8325
|
+
*
|
|
8326
|
+
* Many providers have deprecated this in favor of loopback redirects (e.g.
|
|
8327
|
+
* `http://127.0.0.1:<port>/callback`), but it remains in use as a fallback for tools that cannot
|
|
8328
|
+
* bind a local port.
|
|
8329
|
+
*/ var OAUTH_OOB_REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
|
8330
|
+
|
|
8331
|
+
function asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8332
|
+
try {
|
|
8333
|
+
var info = gen[key](arg);
|
|
8334
|
+
var value = info.value;
|
|
8335
|
+
} catch (error) {
|
|
8336
|
+
reject(error);
|
|
8337
|
+
return;
|
|
8338
|
+
}
|
|
8339
|
+
if (info.done) {
|
|
8340
|
+
resolve(value);
|
|
8341
|
+
} else {
|
|
8342
|
+
Promise.resolve(value).then(_next, _throw);
|
|
8343
|
+
}
|
|
8344
|
+
}
|
|
8345
|
+
function _async_to_generator$d(fn) {
|
|
8346
|
+
return function() {
|
|
8347
|
+
var self = this, args = arguments;
|
|
8348
|
+
return new Promise(function(resolve, reject) {
|
|
8349
|
+
var gen = fn.apply(self, args);
|
|
8350
|
+
function _next(value) {
|
|
8351
|
+
asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, "next", value);
|
|
8352
|
+
}
|
|
8353
|
+
function _throw(err) {
|
|
8354
|
+
asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, "throw", err);
|
|
8355
|
+
}
|
|
8356
|
+
_next(undefined);
|
|
8357
|
+
});
|
|
8358
|
+
};
|
|
8359
|
+
}
|
|
8360
|
+
function _ts_generator$d(thisArg, body) {
|
|
8361
|
+
var f, y, t, _ = {
|
|
8362
|
+
label: 0,
|
|
8363
|
+
sent: function() {
|
|
8364
|
+
if (t[0] & 1) throw t[1];
|
|
8365
|
+
return t[1];
|
|
8366
|
+
},
|
|
8367
|
+
trys: [],
|
|
8368
|
+
ops: []
|
|
8369
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
8370
|
+
return d(g, "next", {
|
|
8371
|
+
value: verb(0)
|
|
8372
|
+
}), d(g, "throw", {
|
|
8373
|
+
value: verb(1)
|
|
8374
|
+
}), d(g, "return", {
|
|
8375
|
+
value: verb(2)
|
|
8376
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
8377
|
+
value: function() {
|
|
8378
|
+
return this;
|
|
8379
|
+
}
|
|
8380
|
+
}), g;
|
|
8381
|
+
function verb(n) {
|
|
8382
|
+
return function(v) {
|
|
8383
|
+
return step([
|
|
8384
|
+
n,
|
|
8385
|
+
v
|
|
8386
|
+
]);
|
|
8387
|
+
};
|
|
8388
|
+
}
|
|
8389
|
+
function step(op) {
|
|
8390
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
8391
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
8392
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
8393
|
+
if (y = 0, t) op = [
|
|
8394
|
+
op[0] & 2,
|
|
8395
|
+
t.value
|
|
8396
|
+
];
|
|
8397
|
+
switch(op[0]){
|
|
8398
|
+
case 0:
|
|
8399
|
+
case 1:
|
|
8400
|
+
t = op;
|
|
8401
|
+
break;
|
|
8402
|
+
case 4:
|
|
8403
|
+
_.label++;
|
|
8404
|
+
return {
|
|
8405
|
+
value: op[1],
|
|
8406
|
+
done: false
|
|
8407
|
+
};
|
|
8408
|
+
case 5:
|
|
8409
|
+
_.label++;
|
|
8410
|
+
y = op[1];
|
|
8411
|
+
op = [
|
|
8412
|
+
0
|
|
8413
|
+
];
|
|
8414
|
+
continue;
|
|
8415
|
+
case 7:
|
|
8416
|
+
op = _.ops.pop();
|
|
8417
|
+
_.trys.pop();
|
|
8418
|
+
continue;
|
|
8419
|
+
default:
|
|
8420
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
8421
|
+
_ = 0;
|
|
8422
|
+
continue;
|
|
8423
|
+
}
|
|
8424
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
8425
|
+
_.label = op[1];
|
|
8426
|
+
break;
|
|
8427
|
+
}
|
|
8428
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
8429
|
+
_.label = t[1];
|
|
8430
|
+
t = op;
|
|
8431
|
+
break;
|
|
8432
|
+
}
|
|
8433
|
+
if (t && _.label < t[2]) {
|
|
8434
|
+
_.label = t[2];
|
|
8435
|
+
_.ops.push(op);
|
|
8436
|
+
break;
|
|
8437
|
+
}
|
|
8438
|
+
if (t[2]) _.ops.pop();
|
|
8439
|
+
_.trys.pop();
|
|
8440
|
+
continue;
|
|
8441
|
+
}
|
|
8442
|
+
op = body.call(thisArg, _);
|
|
8443
|
+
} catch (e) {
|
|
8444
|
+
op = [
|
|
8445
|
+
6,
|
|
8446
|
+
e
|
|
8447
|
+
];
|
|
8448
|
+
y = 0;
|
|
8449
|
+
} finally{
|
|
8450
|
+
f = t = 0;
|
|
8451
|
+
}
|
|
8452
|
+
if (op[0] & 5) throw op[1];
|
|
8453
|
+
return {
|
|
8454
|
+
value: op[0] ? op[1] : void 0,
|
|
8455
|
+
done: true
|
|
8456
|
+
};
|
|
8457
|
+
}
|
|
8458
|
+
}
|
|
8459
|
+
/**
|
|
8460
|
+
* Generates a random PKCE code verifier string (43 characters, base64url-encoded).
|
|
8461
|
+
*
|
|
8462
|
+
* @returns A cryptographically random base64url string suitable for use as a PKCE code_verifier.
|
|
8463
|
+
*/ function generatePkceCodeVerifier() {
|
|
8464
|
+
var bytes = new Uint8Array(32);
|
|
8465
|
+
crypto.getRandomValues(bytes);
|
|
8466
|
+
return base64UrlEncode(bytes);
|
|
8467
|
+
}
|
|
8468
|
+
/**
|
|
8469
|
+
* Generates a PKCE code challenge from a code verifier using SHA-256.
|
|
8470
|
+
*
|
|
8471
|
+
* @param verifier - The code verifier string to hash
|
|
8472
|
+
* @returns A base64url-encoded SHA-256 hash of the verifier
|
|
8473
|
+
*/ function generatePkceCodeChallenge(verifier) {
|
|
8474
|
+
return _async_to_generator$d(function() {
|
|
8475
|
+
var encoder, data, digest;
|
|
8476
|
+
return _ts_generator$d(this, function(_state) {
|
|
8477
|
+
switch(_state.label){
|
|
8478
|
+
case 0:
|
|
8479
|
+
encoder = new TextEncoder();
|
|
8480
|
+
data = encoder.encode(verifier);
|
|
8481
|
+
return [
|
|
8482
|
+
4,
|
|
8483
|
+
crypto.subtle.digest('SHA-256', data)
|
|
8484
|
+
];
|
|
8485
|
+
case 1:
|
|
8486
|
+
digest = _state.sent();
|
|
8487
|
+
return [
|
|
8488
|
+
2,
|
|
8489
|
+
base64UrlEncode(new Uint8Array(digest))
|
|
8490
|
+
];
|
|
8491
|
+
}
|
|
8492
|
+
});
|
|
8493
|
+
})();
|
|
8494
|
+
}
|
|
8495
|
+
function base64UrlEncode(bytes) {
|
|
8496
|
+
var binString = Array.from(bytes, function(byte) {
|
|
8497
|
+
return String.fromCharCode(byte);
|
|
8498
|
+
}).join('');
|
|
8499
|
+
return btoa(binString).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
|
|
8500
|
+
}
|
|
8501
|
+
|
|
8502
|
+
function asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8503
|
+
try {
|
|
8504
|
+
var info = gen[key](arg);
|
|
8505
|
+
var value = info.value;
|
|
8506
|
+
} catch (error) {
|
|
8507
|
+
reject(error);
|
|
8508
|
+
return;
|
|
8509
|
+
}
|
|
8510
|
+
if (info.done) {
|
|
8511
|
+
resolve(value);
|
|
8512
|
+
} else {
|
|
8513
|
+
Promise.resolve(value).then(_next, _throw);
|
|
8514
|
+
}
|
|
8515
|
+
}
|
|
8516
|
+
function _async_to_generator$c(fn) {
|
|
8517
|
+
return function() {
|
|
8518
|
+
var self = this, args = arguments;
|
|
8519
|
+
return new Promise(function(resolve, reject) {
|
|
8520
|
+
var gen = fn.apply(self, args);
|
|
8521
|
+
function _next(value) {
|
|
8522
|
+
asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, "next", value);
|
|
8523
|
+
}
|
|
8524
|
+
function _throw(err) {
|
|
8525
|
+
asyncGeneratorStep$c(gen, resolve, reject, _next, _throw, "throw", err);
|
|
8526
|
+
}
|
|
8527
|
+
_next(undefined);
|
|
8528
|
+
});
|
|
8529
|
+
};
|
|
8530
|
+
}
|
|
8531
|
+
function _ts_generator$c(thisArg, body) {
|
|
8532
|
+
var f, y, t, _ = {
|
|
8533
|
+
label: 0,
|
|
8534
|
+
sent: function() {
|
|
8535
|
+
if (t[0] & 1) throw t[1];
|
|
8536
|
+
return t[1];
|
|
8537
|
+
},
|
|
8538
|
+
trys: [],
|
|
8539
|
+
ops: []
|
|
8540
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
8541
|
+
return d(g, "next", {
|
|
8542
|
+
value: verb(0)
|
|
8543
|
+
}), d(g, "throw", {
|
|
8544
|
+
value: verb(1)
|
|
8545
|
+
}), d(g, "return", {
|
|
8546
|
+
value: verb(2)
|
|
8547
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
8548
|
+
value: function() {
|
|
8549
|
+
return this;
|
|
8550
|
+
}
|
|
8551
|
+
}), g;
|
|
8552
|
+
function verb(n) {
|
|
8553
|
+
return function(v) {
|
|
8554
|
+
return step([
|
|
8555
|
+
n,
|
|
8556
|
+
v
|
|
8557
|
+
]);
|
|
8558
|
+
};
|
|
8559
|
+
}
|
|
8560
|
+
function step(op) {
|
|
8561
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
8562
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
8563
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
8564
|
+
if (y = 0, t) op = [
|
|
8565
|
+
op[0] & 2,
|
|
8566
|
+
t.value
|
|
8567
|
+
];
|
|
8568
|
+
switch(op[0]){
|
|
8569
|
+
case 0:
|
|
8570
|
+
case 1:
|
|
8571
|
+
t = op;
|
|
8572
|
+
break;
|
|
8573
|
+
case 4:
|
|
8574
|
+
_.label++;
|
|
8575
|
+
return {
|
|
8576
|
+
value: op[1],
|
|
8577
|
+
done: false
|
|
8578
|
+
};
|
|
8579
|
+
case 5:
|
|
8580
|
+
_.label++;
|
|
8581
|
+
y = op[1];
|
|
8582
|
+
op = [
|
|
8583
|
+
0
|
|
8584
|
+
];
|
|
8585
|
+
continue;
|
|
8586
|
+
case 7:
|
|
8587
|
+
op = _.ops.pop();
|
|
8588
|
+
_.trys.pop();
|
|
8589
|
+
continue;
|
|
8590
|
+
default:
|
|
8591
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
8592
|
+
_ = 0;
|
|
8593
|
+
continue;
|
|
8594
|
+
}
|
|
8595
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
8596
|
+
_.label = op[1];
|
|
8597
|
+
break;
|
|
8598
|
+
}
|
|
8599
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
8600
|
+
_.label = t[1];
|
|
8601
|
+
t = op;
|
|
8602
|
+
break;
|
|
8603
|
+
}
|
|
8604
|
+
if (t && _.label < t[2]) {
|
|
8605
|
+
_.label = t[2];
|
|
8606
|
+
_.ops.push(op);
|
|
8607
|
+
break;
|
|
8608
|
+
}
|
|
8609
|
+
if (t[2]) _.ops.pop();
|
|
8610
|
+
_.trys.pop();
|
|
8611
|
+
continue;
|
|
8612
|
+
}
|
|
8613
|
+
op = body.call(thisArg, _);
|
|
8614
|
+
} catch (e) {
|
|
8615
|
+
op = [
|
|
8616
|
+
6,
|
|
8617
|
+
e
|
|
8618
|
+
];
|
|
8619
|
+
y = 0;
|
|
8620
|
+
} finally{
|
|
8621
|
+
f = t = 0;
|
|
8622
|
+
}
|
|
8623
|
+
if (op[0] & 5) throw op[1];
|
|
8624
|
+
return {
|
|
8625
|
+
value: op[0] ? op[1] : void 0,
|
|
8626
|
+
done: true
|
|
8627
|
+
};
|
|
8628
|
+
}
|
|
8629
|
+
}
|
|
8630
|
+
/**
|
|
8631
|
+
* Creates an in-memory {@link AsyncValueCache} backed by a single closure-scoped variable.
|
|
8632
|
+
*
|
|
8633
|
+
* Useful as the inner of {@link memoizeAsyncValueCache} and as a stand-in for tests.
|
|
8634
|
+
*
|
|
8635
|
+
* @param initialValue - Optional starting value for the cache. When omitted (or null), the cache starts empty and {@link AsyncValueCache.load} resolves to undefined.
|
|
8636
|
+
* @returns An {@link AsyncValueCache} that stores the latest written value in process memory.
|
|
8637
|
+
*
|
|
8638
|
+
* @example
|
|
8639
|
+
* ```ts
|
|
8640
|
+
* const cache = inMemoryAsyncValueCache<string>('hello');
|
|
8641
|
+
* await cache.load(); // 'hello'
|
|
8642
|
+
* await cache.update('world');
|
|
8643
|
+
* await cache.load(); // 'world'
|
|
8644
|
+
* ```
|
|
8645
|
+
*/ function inMemoryAsyncValueCache(initialValue) {
|
|
8646
|
+
var value = initialValue !== null && initialValue !== void 0 ? initialValue : undefined;
|
|
8647
|
+
return {
|
|
8648
|
+
load: function load() {
|
|
8649
|
+
return _async_to_generator$c(function() {
|
|
8650
|
+
return _ts_generator$c(this, function(_state) {
|
|
8651
|
+
return [
|
|
8652
|
+
2,
|
|
8653
|
+
value
|
|
8654
|
+
];
|
|
8655
|
+
});
|
|
8656
|
+
})();
|
|
8657
|
+
},
|
|
8658
|
+
update: function update(next) {
|
|
8659
|
+
return _async_to_generator$c(function() {
|
|
8660
|
+
return _ts_generator$c(this, function(_state) {
|
|
8661
|
+
value = next;
|
|
8662
|
+
return [
|
|
8663
|
+
2
|
|
8664
|
+
];
|
|
8665
|
+
});
|
|
8666
|
+
})();
|
|
8667
|
+
},
|
|
8668
|
+
clear: function clear() {
|
|
8669
|
+
return _async_to_generator$c(function() {
|
|
8670
|
+
return _ts_generator$c(this, function(_state) {
|
|
8671
|
+
value = undefined;
|
|
8672
|
+
return [
|
|
8673
|
+
2
|
|
8674
|
+
];
|
|
8675
|
+
});
|
|
8676
|
+
})();
|
|
8677
|
+
}
|
|
8678
|
+
};
|
|
8679
|
+
}
|
|
8680
|
+
/**
|
|
8681
|
+
* Creates an in-memory {@link AsyncKeyedValueCache} backed by a closure-scoped record.
|
|
8682
|
+
*
|
|
8683
|
+
* Useful as the inner of {@link memoizeAsyncKeyedValueCache} and as a stand-in for tests.
|
|
8684
|
+
*
|
|
8685
|
+
* Backed by a null-prototype object so inherited properties (`toString`, `hasOwnProperty`, etc.)
|
|
8686
|
+
* are never returned from `get` and `__proto__` keys cannot mutate the prototype chain.
|
|
8687
|
+
*
|
|
8688
|
+
* @param initialEntries - Optional starting entries for the cache. When omitted (or null), the cache starts empty.
|
|
8689
|
+
* @returns An {@link AsyncKeyedValueCache} that stores entries in process memory.
|
|
8690
|
+
*
|
|
8691
|
+
* @example
|
|
8692
|
+
* ```ts
|
|
8693
|
+
* const cache = inMemoryAsyncKeyedValueCache<number>({ a: 1 });
|
|
8694
|
+
* await cache.get('a'); // 1
|
|
8695
|
+
* await cache.set('b', 2);
|
|
8696
|
+
* await cache.load(); // { a: 1, b: 2 }
|
|
8697
|
+
* ```
|
|
8698
|
+
*/ function inMemoryAsyncKeyedValueCache(initialEntries) {
|
|
8699
|
+
var entries = Object.assign(Object.create(null), initialEntries !== null && initialEntries !== void 0 ? initialEntries : {});
|
|
8700
|
+
return {
|
|
8701
|
+
load: function load() {
|
|
8702
|
+
return _async_to_generator$c(function() {
|
|
8703
|
+
return _ts_generator$c(this, function(_state) {
|
|
8704
|
+
return [
|
|
8705
|
+
2,
|
|
8706
|
+
Object.assign(Object.create(null), entries)
|
|
8707
|
+
];
|
|
8708
|
+
});
|
|
8709
|
+
})();
|
|
8710
|
+
},
|
|
8711
|
+
get: function get(key) {
|
|
8712
|
+
return _async_to_generator$c(function() {
|
|
8713
|
+
return _ts_generator$c(this, function(_state) {
|
|
8714
|
+
return [
|
|
8715
|
+
2,
|
|
8716
|
+
Object.hasOwn(entries, key) ? entries[key] : undefined
|
|
8717
|
+
];
|
|
8718
|
+
});
|
|
8719
|
+
})();
|
|
8720
|
+
},
|
|
8721
|
+
set: function set(key, value) {
|
|
8722
|
+
return _async_to_generator$c(function() {
|
|
8723
|
+
var next;
|
|
8724
|
+
return _ts_generator$c(this, function(_state) {
|
|
8725
|
+
next = Object.assign(Object.create(null), entries);
|
|
8726
|
+
next[key] = value;
|
|
8727
|
+
entries = next;
|
|
8728
|
+
return [
|
|
8729
|
+
2
|
|
8730
|
+
];
|
|
8731
|
+
});
|
|
8732
|
+
})();
|
|
8733
|
+
},
|
|
8734
|
+
remove: function remove(key) {
|
|
8735
|
+
return _async_to_generator$c(function() {
|
|
8736
|
+
var next;
|
|
8737
|
+
return _ts_generator$c(this, function(_state) {
|
|
8738
|
+
next = Object.assign(Object.create(null), entries);
|
|
8739
|
+
delete next[key];
|
|
8740
|
+
entries = next;
|
|
8741
|
+
return [
|
|
8742
|
+
2
|
|
8743
|
+
];
|
|
8744
|
+
});
|
|
8745
|
+
})();
|
|
8746
|
+
},
|
|
8747
|
+
clear: function clear() {
|
|
8748
|
+
return _async_to_generator$c(function() {
|
|
8749
|
+
return _ts_generator$c(this, function(_state) {
|
|
8750
|
+
entries = Object.create(null);
|
|
8751
|
+
return [
|
|
8752
|
+
2
|
|
8753
|
+
];
|
|
8754
|
+
});
|
|
8755
|
+
})();
|
|
8756
|
+
}
|
|
8757
|
+
};
|
|
8758
|
+
}
|
|
8759
|
+
|
|
8760
|
+
function asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, key, arg) {
|
|
8761
|
+
try {
|
|
8762
|
+
var info = gen[key](arg);
|
|
8763
|
+
var value = info.value;
|
|
8764
|
+
} catch (error) {
|
|
8765
|
+
reject(error);
|
|
8766
|
+
return;
|
|
8767
|
+
}
|
|
8768
|
+
if (info.done) {
|
|
8769
|
+
resolve(value);
|
|
8770
|
+
} else {
|
|
8771
|
+
Promise.resolve(value).then(_next, _throw);
|
|
8772
|
+
}
|
|
8773
|
+
}
|
|
8774
|
+
function _async_to_generator$b(fn) {
|
|
8775
|
+
return function() {
|
|
8776
|
+
var self = this, args = arguments;
|
|
8777
|
+
return new Promise(function(resolve, reject) {
|
|
8778
|
+
var gen = fn.apply(self, args);
|
|
8779
|
+
function _next(value) {
|
|
8780
|
+
asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "next", value);
|
|
8781
|
+
}
|
|
8782
|
+
function _throw(err) {
|
|
8783
|
+
asyncGeneratorStep$b(gen, resolve, reject, _next, _throw, "throw", err);
|
|
8784
|
+
}
|
|
8785
|
+
_next(undefined);
|
|
8786
|
+
});
|
|
8787
|
+
};
|
|
8788
|
+
}
|
|
8789
|
+
function _define_property$h(obj, key, value) {
|
|
8790
|
+
if (key in obj) {
|
|
8791
|
+
Object.defineProperty(obj, key, {
|
|
8792
|
+
value: value,
|
|
8793
|
+
enumerable: true,
|
|
8794
|
+
configurable: true,
|
|
8795
|
+
writable: true
|
|
8796
|
+
});
|
|
8797
|
+
} else {
|
|
8798
|
+
obj[key] = value;
|
|
8799
|
+
}
|
|
8800
|
+
return obj;
|
|
8801
|
+
}
|
|
8802
|
+
function _object_spread$d(target) {
|
|
8803
|
+
for(var i = 1; i < arguments.length; i++){
|
|
8804
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
8805
|
+
var ownKeys = Object.keys(source);
|
|
8806
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
8807
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
8808
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
8809
|
+
}));
|
|
8810
|
+
}
|
|
8811
|
+
ownKeys.forEach(function(key) {
|
|
8812
|
+
_define_property$h(target, key, source[key]);
|
|
8813
|
+
});
|
|
8814
|
+
}
|
|
8815
|
+
return target;
|
|
8816
|
+
}
|
|
8817
|
+
function ownKeys$7(object, enumerableOnly) {
|
|
8818
|
+
var keys = Object.keys(object);
|
|
8819
|
+
if (Object.getOwnPropertySymbols) {
|
|
8820
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
8821
|
+
keys.push.apply(keys, symbols);
|
|
8822
|
+
}
|
|
8823
|
+
return keys;
|
|
8824
|
+
}
|
|
8825
|
+
function _object_spread_props$7(target, source) {
|
|
8826
|
+
source = source != null ? source : {};
|
|
8827
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
8828
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
8829
|
+
} else {
|
|
8830
|
+
ownKeys$7(Object(source)).forEach(function(key) {
|
|
8831
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
8832
|
+
});
|
|
8833
|
+
}
|
|
8834
|
+
return target;
|
|
8835
|
+
}
|
|
8836
|
+
function _ts_generator$b(thisArg, body) {
|
|
8837
|
+
var f, y, t, _ = {
|
|
8838
|
+
label: 0,
|
|
8839
|
+
sent: function() {
|
|
8840
|
+
if (t[0] & 1) throw t[1];
|
|
8841
|
+
return t[1];
|
|
8842
|
+
},
|
|
8843
|
+
trys: [],
|
|
8844
|
+
ops: []
|
|
8845
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
8846
|
+
return d(g, "next", {
|
|
8847
|
+
value: verb(0)
|
|
8848
|
+
}), d(g, "throw", {
|
|
8849
|
+
value: verb(1)
|
|
8850
|
+
}), d(g, "return", {
|
|
8851
|
+
value: verb(2)
|
|
8852
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
8853
|
+
value: function() {
|
|
8854
|
+
return this;
|
|
8855
|
+
}
|
|
8856
|
+
}), g;
|
|
8857
|
+
function verb(n) {
|
|
8858
|
+
return function(v) {
|
|
8859
|
+
return step([
|
|
8860
|
+
n,
|
|
8861
|
+
v
|
|
8862
|
+
]);
|
|
8863
|
+
};
|
|
8864
|
+
}
|
|
8865
|
+
function step(op) {
|
|
8866
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
8867
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
8868
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
8869
|
+
if (y = 0, t) op = [
|
|
8870
|
+
op[0] & 2,
|
|
8871
|
+
t.value
|
|
8872
|
+
];
|
|
8873
|
+
switch(op[0]){
|
|
8874
|
+
case 0:
|
|
8875
|
+
case 1:
|
|
8876
|
+
t = op;
|
|
8877
|
+
break;
|
|
8878
|
+
case 4:
|
|
8879
|
+
_.label++;
|
|
8880
|
+
return {
|
|
8881
|
+
value: op[1],
|
|
8882
|
+
done: false
|
|
8883
|
+
};
|
|
8884
|
+
case 5:
|
|
8885
|
+
_.label++;
|
|
8886
|
+
y = op[1];
|
|
8887
|
+
op = [
|
|
8888
|
+
0
|
|
8889
|
+
];
|
|
8890
|
+
continue;
|
|
8891
|
+
case 7:
|
|
8892
|
+
op = _.ops.pop();
|
|
8893
|
+
_.trys.pop();
|
|
8894
|
+
continue;
|
|
8895
|
+
default:
|
|
8896
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
8897
|
+
_ = 0;
|
|
8898
|
+
continue;
|
|
8899
|
+
}
|
|
8900
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
8901
|
+
_.label = op[1];
|
|
8902
|
+
break;
|
|
8903
|
+
}
|
|
8904
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
8905
|
+
_.label = t[1];
|
|
8906
|
+
t = op;
|
|
8907
|
+
break;
|
|
8908
|
+
}
|
|
8909
|
+
if (t && _.label < t[2]) {
|
|
8910
|
+
_.label = t[2];
|
|
8911
|
+
_.ops.push(op);
|
|
8912
|
+
break;
|
|
8913
|
+
}
|
|
8914
|
+
if (t[2]) _.ops.pop();
|
|
8915
|
+
_.trys.pop();
|
|
8916
|
+
continue;
|
|
8917
|
+
}
|
|
8918
|
+
op = body.call(thisArg, _);
|
|
8919
|
+
} catch (e) {
|
|
8920
|
+
op = [
|
|
8921
|
+
6,
|
|
8922
|
+
e
|
|
8923
|
+
];
|
|
8924
|
+
y = 0;
|
|
8925
|
+
} finally{
|
|
8926
|
+
f = t = 0;
|
|
8927
|
+
}
|
|
8928
|
+
if (op[0] & 5) throw op[1];
|
|
8929
|
+
return {
|
|
8930
|
+
value: op[0] ? op[1] : void 0,
|
|
8931
|
+
done: true
|
|
8932
|
+
};
|
|
8933
|
+
}
|
|
8934
|
+
}
|
|
8935
|
+
/**
|
|
8936
|
+
* Wraps an inner {@link AsyncValueCache} with a single-load in-memory memoization layer.
|
|
8937
|
+
*
|
|
8938
|
+
* The first {@link AsyncValueCache.load} call delegates to the inner cache and stores the
|
|
8939
|
+
* result; subsequent calls return the memoized value without touching the inner cache again.
|
|
8940
|
+
* {@link AsyncValueCache.update} writes through to the inner cache and refreshes the memo.
|
|
8941
|
+
* {@link AsyncValueCache.clear} clears both layers.
|
|
8942
|
+
*
|
|
8943
|
+
* Note: the memoized value is per-process. Long-running processes will not observe writes
|
|
8944
|
+
* made by other processes to the inner backing once the memo is populated.
|
|
8945
|
+
*
|
|
8946
|
+
* @dbxUtil
|
|
8947
|
+
* @dbxUtilCategory cache
|
|
8948
|
+
* @dbxUtilTags memoize, memo, cache, async, single-load, async-value
|
|
8949
|
+
* @dbxUtilRelated memoize-async-keyed-value-cache
|
|
8950
|
+
*
|
|
8951
|
+
* @param inner - The backing cache to memoize. Reads are delegated once and cached; writes are forwarded through and refresh the memo.
|
|
8952
|
+
* @returns An {@link AsyncValueCache} that proxies the inner cache with a single-load memoization layer.
|
|
8953
|
+
*
|
|
8954
|
+
* @example
|
|
8955
|
+
* ```ts
|
|
8956
|
+
* const memo = memoizeAsyncValueCache(inMemoryAsyncValueCache<string>('initial'));
|
|
8957
|
+
* await memo.load(); // delegates to inner.load() once
|
|
8958
|
+
* await memo.load(); // returns memoized value without hitting inner
|
|
8959
|
+
* await memo.update('next'); // writes through to inner and refreshes memo
|
|
8960
|
+
* ```
|
|
8961
|
+
*/ function memoizeAsyncValueCache(inner) {
|
|
8962
|
+
var loaded;
|
|
8963
|
+
var inFlight;
|
|
8964
|
+
// Bumped on every write/clear so a slow inner.load() resolved after a concurrent
|
|
8965
|
+
// update()/clear() can detect that its result is stale and skip clobbering newer state.
|
|
8966
|
+
var generation = 0;
|
|
8967
|
+
return {
|
|
8968
|
+
load: function load() {
|
|
8969
|
+
if (loaded != null) {
|
|
8970
|
+
return Promise.resolve(loaded.value);
|
|
8971
|
+
}
|
|
8972
|
+
if (inFlight == null) {
|
|
8973
|
+
// Cache the in-flight promise so concurrent callers share the same load instead
|
|
8974
|
+
// of each firing an independent inner.load(). Cleared on settle so a failed load
|
|
8975
|
+
// doesn't permanently poison the memo. The captured generation lets a slow
|
|
8976
|
+
// resolve detect a concurrent update()/clear() and skip clobbering newer state.
|
|
8977
|
+
var startGen = generation;
|
|
8978
|
+
inFlight = inner.load().then(function(value) {
|
|
8979
|
+
if (generation === startGen) {
|
|
8980
|
+
loaded = {
|
|
8981
|
+
value: value
|
|
8982
|
+
};
|
|
8983
|
+
inFlight = undefined;
|
|
8984
|
+
}
|
|
8985
|
+
return value;
|
|
8986
|
+
}, function(error) {
|
|
8987
|
+
if (generation === startGen) {
|
|
8988
|
+
inFlight = undefined;
|
|
8989
|
+
}
|
|
8990
|
+
throw error;
|
|
8991
|
+
});
|
|
8992
|
+
}
|
|
8993
|
+
return inFlight;
|
|
8994
|
+
},
|
|
8995
|
+
update: function update(next) {
|
|
8996
|
+
return _async_to_generator$b(function() {
|
|
8997
|
+
return _ts_generator$b(this, function(_state) {
|
|
8998
|
+
switch(_state.label){
|
|
8999
|
+
case 0:
|
|
9000
|
+
generation += 1;
|
|
9001
|
+
inFlight = undefined;
|
|
9002
|
+
// Write through to the inner first; only mutate the memoized snapshot once the inner
|
|
9003
|
+
// call succeeds, so a thrown inner.update doesn't leave the memo with a value that
|
|
9004
|
+
// never made it to the backing store.
|
|
9005
|
+
return [
|
|
9006
|
+
4,
|
|
9007
|
+
inner.update(next)
|
|
9008
|
+
];
|
|
9009
|
+
case 1:
|
|
9010
|
+
_state.sent();
|
|
9011
|
+
loaded = {
|
|
9012
|
+
value: next
|
|
9013
|
+
};
|
|
9014
|
+
return [
|
|
9015
|
+
2
|
|
9016
|
+
];
|
|
9017
|
+
}
|
|
9018
|
+
});
|
|
9019
|
+
})();
|
|
9020
|
+
},
|
|
9021
|
+
clear: function clear() {
|
|
9022
|
+
return _async_to_generator$b(function() {
|
|
9023
|
+
return _ts_generator$b(this, function(_state) {
|
|
9024
|
+
switch(_state.label){
|
|
9025
|
+
case 0:
|
|
9026
|
+
generation += 1;
|
|
9027
|
+
inFlight = undefined;
|
|
9028
|
+
return [
|
|
9029
|
+
4,
|
|
9030
|
+
inner.clear()
|
|
9031
|
+
];
|
|
9032
|
+
case 1:
|
|
9033
|
+
_state.sent();
|
|
9034
|
+
loaded = {
|
|
9035
|
+
value: undefined
|
|
9036
|
+
};
|
|
9037
|
+
return [
|
|
9038
|
+
2
|
|
9039
|
+
];
|
|
9040
|
+
}
|
|
9041
|
+
});
|
|
9042
|
+
})();
|
|
9043
|
+
}
|
|
9044
|
+
};
|
|
9045
|
+
}
|
|
9046
|
+
/**
|
|
9047
|
+
* Wraps an inner {@link AsyncKeyedValueCache} with a single-load in-memory memoization layer
|
|
9048
|
+
* over the full record.
|
|
9049
|
+
*
|
|
9050
|
+
* The first call to any read method ({@link AsyncKeyedValueCache.load} or {@link AsyncKeyedValueCache.get})
|
|
9051
|
+
* delegates to the inner cache and stores the loaded record; subsequent reads return entries
|
|
9052
|
+
* from the memoized record without re-hitting the inner cache. Writes ({@link AsyncKeyedValueCache.set} /
|
|
9053
|
+
* {@link AsyncKeyedValueCache.remove}) update the memoized record and write through to the inner cache.
|
|
9054
|
+
* {@link AsyncKeyedValueCache.clear} clears both layers.
|
|
9055
|
+
*
|
|
9056
|
+
* Note: the memoized record is per-process. Long-running processes will not observe writes
|
|
9057
|
+
* made by other processes to the inner backing once the memo is populated.
|
|
9058
|
+
*
|
|
9059
|
+
* @dbxUtil
|
|
9060
|
+
* @dbxUtilCategory cache
|
|
9061
|
+
* @dbxUtilTags memoize, memo, cache, async, keyed, record
|
|
9062
|
+
* @dbxUtilRelated memoize-async-value-cache
|
|
9063
|
+
*
|
|
9064
|
+
* @param inner - The backing keyed cache to memoize. The full record is loaded once and cached; writes are forwarded through and applied to the memo.
|
|
9065
|
+
* @returns An {@link AsyncKeyedValueCache} that proxies the inner cache with a record-level memoization layer.
|
|
9066
|
+
*
|
|
9067
|
+
* @example
|
|
9068
|
+
* ```ts
|
|
9069
|
+
* const memo = memoizeAsyncKeyedValueCache(inMemoryAsyncKeyedValueCache<number>({ a: 1 }));
|
|
9070
|
+
* await memo.get('a'); // delegates to inner.load() once
|
|
9071
|
+
* await memo.get('a'); // returns memoized entry without hitting inner
|
|
9072
|
+
* await memo.set('b', 2); // writes through to inner and updates memo
|
|
9073
|
+
* ```
|
|
9074
|
+
*/ function memoizeAsyncKeyedValueCache(inner) {
|
|
9075
|
+
var loaded;
|
|
9076
|
+
var inFlight;
|
|
9077
|
+
// Bumped on every write/clear so a slow inner.load() resolved after a concurrent
|
|
9078
|
+
// set()/remove()/clear() can detect that its result is stale and skip clobbering newer state.
|
|
9079
|
+
var generation = 0;
|
|
9080
|
+
function ensureLoaded() {
|
|
9081
|
+
if (loaded != null) {
|
|
9082
|
+
return Promise.resolve(loaded.entries);
|
|
9083
|
+
}
|
|
9084
|
+
if (inFlight == null) {
|
|
9085
|
+
var startGen = generation;
|
|
9086
|
+
inFlight = inner.load().then(function(entries) {
|
|
9087
|
+
if (generation === startGen) {
|
|
9088
|
+
loaded = {
|
|
9089
|
+
entries: entries
|
|
9090
|
+
};
|
|
9091
|
+
inFlight = undefined;
|
|
9092
|
+
}
|
|
9093
|
+
return entries;
|
|
9094
|
+
}, function(error) {
|
|
9095
|
+
if (generation === startGen) {
|
|
9096
|
+
inFlight = undefined;
|
|
9097
|
+
}
|
|
9098
|
+
throw error;
|
|
9099
|
+
});
|
|
9100
|
+
}
|
|
9101
|
+
return inFlight;
|
|
9102
|
+
}
|
|
9103
|
+
return {
|
|
9104
|
+
load: function load() {
|
|
9105
|
+
return _async_to_generator$b(function() {
|
|
9106
|
+
var _tmp;
|
|
9107
|
+
return _ts_generator$b(this, function(_state) {
|
|
9108
|
+
switch(_state.label){
|
|
9109
|
+
case 0:
|
|
9110
|
+
_tmp = [
|
|
9111
|
+
{}
|
|
9112
|
+
];
|
|
9113
|
+
return [
|
|
9114
|
+
4,
|
|
9115
|
+
ensureLoaded()
|
|
9116
|
+
];
|
|
9117
|
+
case 1:
|
|
9118
|
+
return [
|
|
9119
|
+
2,
|
|
9120
|
+
_object_spread$d.apply(void 0, _tmp.concat([
|
|
9121
|
+
_state.sent()
|
|
9122
|
+
]))
|
|
9123
|
+
];
|
|
9124
|
+
}
|
|
9125
|
+
});
|
|
9126
|
+
})();
|
|
9127
|
+
},
|
|
9128
|
+
get: function get(key) {
|
|
9129
|
+
return _async_to_generator$b(function() {
|
|
9130
|
+
return _ts_generator$b(this, function(_state) {
|
|
9131
|
+
switch(_state.label){
|
|
9132
|
+
case 0:
|
|
9133
|
+
return [
|
|
9134
|
+
4,
|
|
9135
|
+
ensureLoaded()
|
|
9136
|
+
];
|
|
9137
|
+
case 1:
|
|
9138
|
+
return [
|
|
9139
|
+
2,
|
|
9140
|
+
_state.sent()[key]
|
|
9141
|
+
];
|
|
9142
|
+
}
|
|
9143
|
+
});
|
|
9144
|
+
})();
|
|
9145
|
+
},
|
|
9146
|
+
set: function set(key, value) {
|
|
9147
|
+
return _async_to_generator$b(function() {
|
|
9148
|
+
var current;
|
|
9149
|
+
return _ts_generator$b(this, function(_state) {
|
|
9150
|
+
switch(_state.label){
|
|
9151
|
+
case 0:
|
|
9152
|
+
return [
|
|
9153
|
+
4,
|
|
9154
|
+
ensureLoaded()
|
|
9155
|
+
];
|
|
9156
|
+
case 1:
|
|
9157
|
+
current = _state.sent();
|
|
9158
|
+
generation += 1;
|
|
9159
|
+
inFlight = undefined;
|
|
9160
|
+
// Write through to the inner first so a failed inner.set doesn't leave the memo with
|
|
9161
|
+
// an entry that never made it to the backing store.
|
|
9162
|
+
return [
|
|
9163
|
+
4,
|
|
9164
|
+
inner.set(key, value)
|
|
9165
|
+
];
|
|
9166
|
+
case 2:
|
|
9167
|
+
_state.sent();
|
|
9168
|
+
loaded = {
|
|
9169
|
+
entries: _object_spread_props$7(_object_spread$d({}, current), _define_property$h({}, key, value))
|
|
9170
|
+
};
|
|
9171
|
+
return [
|
|
9172
|
+
2
|
|
9173
|
+
];
|
|
9174
|
+
}
|
|
9175
|
+
});
|
|
9176
|
+
})();
|
|
9177
|
+
},
|
|
9178
|
+
remove: function remove(key) {
|
|
9179
|
+
return _async_to_generator$b(function() {
|
|
9180
|
+
var current, next;
|
|
9181
|
+
return _ts_generator$b(this, function(_state) {
|
|
9182
|
+
switch(_state.label){
|
|
9183
|
+
case 0:
|
|
9184
|
+
return [
|
|
9185
|
+
4,
|
|
9186
|
+
ensureLoaded()
|
|
9187
|
+
];
|
|
9188
|
+
case 1:
|
|
9189
|
+
current = _state.sent();
|
|
9190
|
+
generation += 1;
|
|
9191
|
+
inFlight = undefined;
|
|
9192
|
+
return [
|
|
9193
|
+
4,
|
|
9194
|
+
inner.remove(key)
|
|
9195
|
+
];
|
|
9196
|
+
case 2:
|
|
9197
|
+
_state.sent();
|
|
9198
|
+
next = _object_spread$d({}, current);
|
|
9199
|
+
delete next[key];
|
|
9200
|
+
loaded = {
|
|
9201
|
+
entries: next
|
|
9202
|
+
};
|
|
9203
|
+
return [
|
|
9204
|
+
2
|
|
9205
|
+
];
|
|
9206
|
+
}
|
|
9207
|
+
});
|
|
9208
|
+
})();
|
|
9209
|
+
},
|
|
9210
|
+
clear: function clear() {
|
|
9211
|
+
return _async_to_generator$b(function() {
|
|
9212
|
+
return _ts_generator$b(this, function(_state) {
|
|
9213
|
+
switch(_state.label){
|
|
9214
|
+
case 0:
|
|
9215
|
+
generation += 1;
|
|
9216
|
+
inFlight = undefined;
|
|
9217
|
+
return [
|
|
9218
|
+
4,
|
|
9219
|
+
inner.clear()
|
|
9220
|
+
];
|
|
9221
|
+
case 1:
|
|
9222
|
+
_state.sent();
|
|
9223
|
+
loaded = {
|
|
9224
|
+
entries: {}
|
|
9225
|
+
};
|
|
9226
|
+
return [
|
|
9227
|
+
2
|
|
9228
|
+
];
|
|
9229
|
+
}
|
|
9230
|
+
});
|
|
9231
|
+
})();
|
|
9232
|
+
}
|
|
9233
|
+
};
|
|
9234
|
+
}
|
|
9235
|
+
|
|
9236
|
+
function asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, key, arg) {
|
|
9237
|
+
try {
|
|
9238
|
+
var info = gen[key](arg);
|
|
9239
|
+
var value = info.value;
|
|
9240
|
+
} catch (error) {
|
|
9241
|
+
reject(error);
|
|
9242
|
+
return;
|
|
9243
|
+
}
|
|
9244
|
+
if (info.done) {
|
|
9245
|
+
resolve(value);
|
|
9246
|
+
} else {
|
|
9247
|
+
Promise.resolve(value).then(_next, _throw);
|
|
9248
|
+
}
|
|
9249
|
+
}
|
|
9250
|
+
function _async_to_generator$a(fn) {
|
|
9251
|
+
return function() {
|
|
9252
|
+
var self = this, args = arguments;
|
|
9253
|
+
return new Promise(function(resolve, reject) {
|
|
9254
|
+
var gen = fn.apply(self, args);
|
|
9255
|
+
function _next(value) {
|
|
9256
|
+
asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "next", value);
|
|
9257
|
+
}
|
|
9258
|
+
function _throw(err) {
|
|
9259
|
+
asyncGeneratorStep$a(gen, resolve, reject, _next, _throw, "throw", err);
|
|
9260
|
+
}
|
|
9261
|
+
_next(undefined);
|
|
9262
|
+
});
|
|
9263
|
+
};
|
|
9264
|
+
}
|
|
9265
|
+
function _ts_generator$a(thisArg, body) {
|
|
9266
|
+
var f, y, t, _ = {
|
|
9267
|
+
label: 0,
|
|
9268
|
+
sent: function() {
|
|
9269
|
+
if (t[0] & 1) throw t[1];
|
|
9270
|
+
return t[1];
|
|
9271
|
+
},
|
|
9272
|
+
trys: [],
|
|
9273
|
+
ops: []
|
|
9274
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
9275
|
+
return d(g, "next", {
|
|
9276
|
+
value: verb(0)
|
|
9277
|
+
}), d(g, "throw", {
|
|
9278
|
+
value: verb(1)
|
|
9279
|
+
}), d(g, "return", {
|
|
9280
|
+
value: verb(2)
|
|
9281
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
9282
|
+
value: function() {
|
|
9283
|
+
return this;
|
|
9284
|
+
}
|
|
9285
|
+
}), g;
|
|
9286
|
+
function verb(n) {
|
|
9287
|
+
return function(v) {
|
|
9288
|
+
return step([
|
|
9289
|
+
n,
|
|
9290
|
+
v
|
|
9291
|
+
]);
|
|
9292
|
+
};
|
|
9293
|
+
}
|
|
9294
|
+
function step(op) {
|
|
9295
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
9296
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
9297
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
9298
|
+
if (y = 0, t) op = [
|
|
9299
|
+
op[0] & 2,
|
|
9300
|
+
t.value
|
|
9301
|
+
];
|
|
9302
|
+
switch(op[0]){
|
|
9303
|
+
case 0:
|
|
9304
|
+
case 1:
|
|
9305
|
+
t = op;
|
|
9306
|
+
break;
|
|
9307
|
+
case 4:
|
|
9308
|
+
_.label++;
|
|
9309
|
+
return {
|
|
9310
|
+
value: op[1],
|
|
9311
|
+
done: false
|
|
9312
|
+
};
|
|
9313
|
+
case 5:
|
|
9314
|
+
_.label++;
|
|
9315
|
+
y = op[1];
|
|
9316
|
+
op = [
|
|
9317
|
+
0
|
|
9318
|
+
];
|
|
9319
|
+
continue;
|
|
9320
|
+
case 7:
|
|
9321
|
+
op = _.ops.pop();
|
|
9322
|
+
_.trys.pop();
|
|
9323
|
+
continue;
|
|
9324
|
+
default:
|
|
9325
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
9326
|
+
_ = 0;
|
|
9327
|
+
continue;
|
|
9328
|
+
}
|
|
9329
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
9330
|
+
_.label = op[1];
|
|
9331
|
+
break;
|
|
9332
|
+
}
|
|
9333
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
9334
|
+
_.label = t[1];
|
|
9335
|
+
t = op;
|
|
9336
|
+
break;
|
|
9337
|
+
}
|
|
9338
|
+
if (t && _.label < t[2]) {
|
|
9339
|
+
_.label = t[2];
|
|
9340
|
+
_.ops.push(op);
|
|
9341
|
+
break;
|
|
9342
|
+
}
|
|
9343
|
+
if (t[2]) _.ops.pop();
|
|
9344
|
+
_.trys.pop();
|
|
9345
|
+
continue;
|
|
9346
|
+
}
|
|
9347
|
+
op = body.call(thisArg, _);
|
|
9348
|
+
} catch (e) {
|
|
9349
|
+
op = [
|
|
9350
|
+
6,
|
|
9351
|
+
e
|
|
9352
|
+
];
|
|
9353
|
+
y = 0;
|
|
9354
|
+
} finally{
|
|
9355
|
+
f = t = 0;
|
|
9356
|
+
}
|
|
9357
|
+
if (op[0] & 5) throw op[1];
|
|
9358
|
+
return {
|
|
9359
|
+
value: op[0] ? op[1] : void 0,
|
|
9360
|
+
done: true
|
|
9361
|
+
};
|
|
9362
|
+
}
|
|
9363
|
+
}
|
|
9364
|
+
/**
|
|
9365
|
+
* Composes multiple {@link AsyncValueCache} instances into a single read-from-first-write-to-all cache.
|
|
9366
|
+
*
|
|
9367
|
+
* - {@link AsyncValueCache.load} returns the first non-null/undefined value from the input caches in order.
|
|
9368
|
+
* - {@link AsyncValueCache.update} writes the value to every input cache, propagating from the
|
|
9369
|
+
* lowest-precedence (slowest, source-of-truth) tier up to the highest-precedence (fastest) tier
|
|
9370
|
+
* so a failed write to the backing store is not masked by a successful write to memory.
|
|
9371
|
+
* - {@link AsyncValueCache.clear} clears every input cache in the same lower-to-higher order.
|
|
9372
|
+
*
|
|
9373
|
+
* Useful for memory-then-disk layering or for combining a fast tier with a slow source-of-truth tier.
|
|
9374
|
+
*
|
|
9375
|
+
* @param caches - Ordered tiers from highest-precedence (fastest, e.g. memory) to lowest-precedence (source-of-truth, e.g. disk). Reads honor this order; writes propagate in reverse.
|
|
9376
|
+
* @returns A single {@link AsyncValueCache} layered across the provided tiers.
|
|
9377
|
+
*
|
|
9378
|
+
* @example
|
|
9379
|
+
* ```ts
|
|
9380
|
+
* const layered = mergeAsyncValueCaches<string>([
|
|
9381
|
+
* inMemoryAsyncValueCache(),
|
|
9382
|
+
* diskBackedAsyncValueCache()
|
|
9383
|
+
* ]);
|
|
9384
|
+
* await layered.update('hello'); // writes to disk first, then memory
|
|
9385
|
+
* await layered.load(); // returns from memory if present
|
|
9386
|
+
* ```
|
|
9387
|
+
*/ function mergeAsyncValueCaches(caches) {
|
|
9388
|
+
return {
|
|
9389
|
+
load: function load() {
|
|
9390
|
+
return _async_to_generator$a(function() {
|
|
9391
|
+
var result, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, cache, value, err;
|
|
9392
|
+
return _ts_generator$a(this, function(_state) {
|
|
9393
|
+
switch(_state.label){
|
|
9394
|
+
case 0:
|
|
9395
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
9396
|
+
_state.label = 1;
|
|
9397
|
+
case 1:
|
|
9398
|
+
_state.trys.push([
|
|
9399
|
+
1,
|
|
9400
|
+
6,
|
|
9401
|
+
7,
|
|
9402
|
+
8
|
|
9403
|
+
]);
|
|
9404
|
+
_iterator = caches[Symbol.iterator]();
|
|
9405
|
+
_state.label = 2;
|
|
9406
|
+
case 2:
|
|
9407
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
9408
|
+
3,
|
|
9409
|
+
5
|
|
9410
|
+
];
|
|
9411
|
+
cache = _step.value;
|
|
9412
|
+
return [
|
|
9413
|
+
4,
|
|
9414
|
+
cache.load()
|
|
9415
|
+
];
|
|
9416
|
+
case 3:
|
|
9417
|
+
value = _state.sent();
|
|
9418
|
+
if (value != null) {
|
|
9419
|
+
result = value;
|
|
9420
|
+
return [
|
|
9421
|
+
3,
|
|
9422
|
+
5
|
|
9423
|
+
];
|
|
9424
|
+
}
|
|
9425
|
+
_state.label = 4;
|
|
9426
|
+
case 4:
|
|
9427
|
+
_iteratorNormalCompletion = true;
|
|
9428
|
+
return [
|
|
9429
|
+
3,
|
|
9430
|
+
2
|
|
9431
|
+
];
|
|
9432
|
+
case 5:
|
|
9433
|
+
return [
|
|
9434
|
+
3,
|
|
9435
|
+
8
|
|
9436
|
+
];
|
|
9437
|
+
case 6:
|
|
9438
|
+
err = _state.sent();
|
|
9439
|
+
_didIteratorError = true;
|
|
9440
|
+
_iteratorError = err;
|
|
9441
|
+
return [
|
|
9442
|
+
3,
|
|
9443
|
+
8
|
|
9444
|
+
];
|
|
9445
|
+
case 7:
|
|
9446
|
+
try {
|
|
9447
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
9448
|
+
_iterator.return();
|
|
9449
|
+
}
|
|
9450
|
+
} finally{
|
|
9451
|
+
if (_didIteratorError) {
|
|
9452
|
+
throw _iteratorError;
|
|
9453
|
+
}
|
|
9454
|
+
}
|
|
9455
|
+
return [
|
|
9456
|
+
7
|
|
9457
|
+
];
|
|
9458
|
+
case 8:
|
|
9459
|
+
return [
|
|
9460
|
+
2,
|
|
9461
|
+
result
|
|
9462
|
+
];
|
|
9463
|
+
}
|
|
9464
|
+
});
|
|
9465
|
+
})();
|
|
9466
|
+
},
|
|
9467
|
+
update: function update(value) {
|
|
9468
|
+
return _async_to_generator$a(function() {
|
|
9469
|
+
var i;
|
|
9470
|
+
return _ts_generator$a(this, function(_state) {
|
|
9471
|
+
switch(_state.label){
|
|
9472
|
+
case 0:
|
|
9473
|
+
i = caches.length - 1;
|
|
9474
|
+
_state.label = 1;
|
|
9475
|
+
case 1:
|
|
9476
|
+
if (!(i >= 0)) return [
|
|
9477
|
+
3,
|
|
9478
|
+
4
|
|
9479
|
+
];
|
|
9480
|
+
return [
|
|
9481
|
+
4,
|
|
9482
|
+
caches[i].update(value)
|
|
9483
|
+
];
|
|
9484
|
+
case 2:
|
|
9485
|
+
_state.sent();
|
|
9486
|
+
_state.label = 3;
|
|
9487
|
+
case 3:
|
|
9488
|
+
i -= 1;
|
|
9489
|
+
return [
|
|
9490
|
+
3,
|
|
9491
|
+
1
|
|
9492
|
+
];
|
|
9493
|
+
case 4:
|
|
9494
|
+
return [
|
|
9495
|
+
2
|
|
9496
|
+
];
|
|
9497
|
+
}
|
|
9498
|
+
});
|
|
9499
|
+
})();
|
|
9500
|
+
},
|
|
9501
|
+
clear: function clear() {
|
|
9502
|
+
return _async_to_generator$a(function() {
|
|
9503
|
+
var i;
|
|
9504
|
+
return _ts_generator$a(this, function(_state) {
|
|
9505
|
+
switch(_state.label){
|
|
9506
|
+
case 0:
|
|
9507
|
+
i = caches.length - 1;
|
|
9508
|
+
_state.label = 1;
|
|
9509
|
+
case 1:
|
|
9510
|
+
if (!(i >= 0)) return [
|
|
9511
|
+
3,
|
|
9512
|
+
4
|
|
9513
|
+
];
|
|
9514
|
+
return [
|
|
9515
|
+
4,
|
|
9516
|
+
caches[i].clear()
|
|
9517
|
+
];
|
|
9518
|
+
case 2:
|
|
9519
|
+
_state.sent();
|
|
9520
|
+
_state.label = 3;
|
|
9521
|
+
case 3:
|
|
9522
|
+
i -= 1;
|
|
9523
|
+
return [
|
|
9524
|
+
3,
|
|
9525
|
+
1
|
|
9526
|
+
];
|
|
9527
|
+
case 4:
|
|
9528
|
+
return [
|
|
9529
|
+
2
|
|
9530
|
+
];
|
|
9531
|
+
}
|
|
9532
|
+
});
|
|
9533
|
+
})();
|
|
9534
|
+
}
|
|
7759
9535
|
};
|
|
7760
9536
|
}
|
|
7761
9537
|
/**
|
|
7762
|
-
*
|
|
9538
|
+
* Composes multiple {@link AsyncKeyedValueCache} instances into a single read-from-first-write-to-all cache.
|
|
7763
9539
|
*
|
|
7764
|
-
*
|
|
7765
|
-
*
|
|
9540
|
+
* - {@link AsyncKeyedValueCache.get} returns the first non-null/undefined value from the input caches in order for a given key.
|
|
9541
|
+
* - {@link AsyncKeyedValueCache.load} returns a merged record where earlier caches' entries take precedence over later caches'.
|
|
9542
|
+
* - Writes ({@link AsyncKeyedValueCache.set} / {@link AsyncKeyedValueCache.remove}) propagate to every input cache.
|
|
9543
|
+
* - {@link AsyncKeyedValueCache.clear} clears every input cache.
|
|
7766
9544
|
*
|
|
7767
|
-
* @param
|
|
7768
|
-
* @returns A
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
9545
|
+
* @param caches - Ordered tiers from highest-precedence (fastest, e.g. memory) to lowest-precedence (source-of-truth, e.g. disk). Reads honor this order; writes propagate in reverse.
|
|
9546
|
+
* @returns A single {@link AsyncKeyedValueCache} layered across the provided tiers.
|
|
9547
|
+
*
|
|
9548
|
+
* @example
|
|
9549
|
+
* ```ts
|
|
9550
|
+
* const layered = mergeAsyncKeyedValueCaches<number>([
|
|
9551
|
+
* inMemoryAsyncKeyedValueCache(),
|
|
9552
|
+
* diskBackedAsyncKeyedValueCache()
|
|
9553
|
+
* ]);
|
|
9554
|
+
* await layered.set('a', 1); // writes to disk first, then memory
|
|
9555
|
+
* await layered.get('a'); // returns from memory if present
|
|
9556
|
+
* ```
|
|
9557
|
+
*/ function mergeAsyncKeyedValueCaches(caches) {
|
|
9558
|
+
return {
|
|
9559
|
+
load: function load() {
|
|
9560
|
+
return _async_to_generator$a(function() {
|
|
9561
|
+
var merged, i, entries;
|
|
9562
|
+
return _ts_generator$a(this, function(_state) {
|
|
9563
|
+
switch(_state.label){
|
|
9564
|
+
case 0:
|
|
9565
|
+
// Use a null-prototype object so a key like "__proto__" loaded from any cache cannot
|
|
9566
|
+
// mutate the prototype chain via Object.assign.
|
|
9567
|
+
merged = Object.create(null);
|
|
9568
|
+
i = caches.length - 1;
|
|
9569
|
+
_state.label = 1;
|
|
9570
|
+
case 1:
|
|
9571
|
+
if (!(i >= 0)) return [
|
|
9572
|
+
3,
|
|
9573
|
+
4
|
|
9574
|
+
];
|
|
9575
|
+
return [
|
|
9576
|
+
4,
|
|
9577
|
+
caches[i].load()
|
|
9578
|
+
];
|
|
9579
|
+
case 2:
|
|
9580
|
+
entries = _state.sent();
|
|
9581
|
+
Object.assign(merged, entries);
|
|
9582
|
+
_state.label = 3;
|
|
9583
|
+
case 3:
|
|
9584
|
+
i -= 1;
|
|
9585
|
+
return [
|
|
9586
|
+
3,
|
|
9587
|
+
1
|
|
9588
|
+
];
|
|
9589
|
+
case 4:
|
|
9590
|
+
return [
|
|
9591
|
+
2,
|
|
9592
|
+
merged
|
|
9593
|
+
];
|
|
9594
|
+
}
|
|
9595
|
+
});
|
|
9596
|
+
})();
|
|
9597
|
+
},
|
|
9598
|
+
get: function get(key) {
|
|
9599
|
+
return _async_to_generator$a(function() {
|
|
9600
|
+
var result, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, cache, value, err;
|
|
9601
|
+
return _ts_generator$a(this, function(_state) {
|
|
9602
|
+
switch(_state.label){
|
|
9603
|
+
case 0:
|
|
9604
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
9605
|
+
_state.label = 1;
|
|
9606
|
+
case 1:
|
|
9607
|
+
_state.trys.push([
|
|
9608
|
+
1,
|
|
9609
|
+
6,
|
|
9610
|
+
7,
|
|
9611
|
+
8
|
|
9612
|
+
]);
|
|
9613
|
+
_iterator = caches[Symbol.iterator]();
|
|
9614
|
+
_state.label = 2;
|
|
9615
|
+
case 2:
|
|
9616
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
9617
|
+
3,
|
|
9618
|
+
5
|
|
9619
|
+
];
|
|
9620
|
+
cache = _step.value;
|
|
9621
|
+
return [
|
|
9622
|
+
4,
|
|
9623
|
+
cache.get(key)
|
|
9624
|
+
];
|
|
9625
|
+
case 3:
|
|
9626
|
+
value = _state.sent();
|
|
9627
|
+
if (value != null) {
|
|
9628
|
+
result = value;
|
|
9629
|
+
return [
|
|
9630
|
+
3,
|
|
9631
|
+
5
|
|
9632
|
+
];
|
|
9633
|
+
}
|
|
9634
|
+
_state.label = 4;
|
|
9635
|
+
case 4:
|
|
9636
|
+
_iteratorNormalCompletion = true;
|
|
9637
|
+
return [
|
|
9638
|
+
3,
|
|
9639
|
+
2
|
|
9640
|
+
];
|
|
9641
|
+
case 5:
|
|
9642
|
+
return [
|
|
9643
|
+
3,
|
|
9644
|
+
8
|
|
9645
|
+
];
|
|
9646
|
+
case 6:
|
|
9647
|
+
err = _state.sent();
|
|
9648
|
+
_didIteratorError = true;
|
|
9649
|
+
_iteratorError = err;
|
|
9650
|
+
return [
|
|
9651
|
+
3,
|
|
9652
|
+
8
|
|
9653
|
+
];
|
|
9654
|
+
case 7:
|
|
9655
|
+
try {
|
|
9656
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
9657
|
+
_iterator.return();
|
|
9658
|
+
}
|
|
9659
|
+
} finally{
|
|
9660
|
+
if (_didIteratorError) {
|
|
9661
|
+
throw _iteratorError;
|
|
9662
|
+
}
|
|
9663
|
+
}
|
|
9664
|
+
return [
|
|
9665
|
+
7
|
|
9666
|
+
];
|
|
9667
|
+
case 8:
|
|
9668
|
+
return [
|
|
9669
|
+
2,
|
|
9670
|
+
result
|
|
9671
|
+
];
|
|
9672
|
+
}
|
|
9673
|
+
});
|
|
9674
|
+
})();
|
|
9675
|
+
},
|
|
9676
|
+
set: function set(key, value) {
|
|
9677
|
+
return _async_to_generator$a(function() {
|
|
9678
|
+
var i;
|
|
9679
|
+
return _ts_generator$a(this, function(_state) {
|
|
9680
|
+
switch(_state.label){
|
|
9681
|
+
case 0:
|
|
9682
|
+
i = caches.length - 1;
|
|
9683
|
+
_state.label = 1;
|
|
9684
|
+
case 1:
|
|
9685
|
+
if (!(i >= 0)) return [
|
|
9686
|
+
3,
|
|
9687
|
+
4
|
|
9688
|
+
];
|
|
9689
|
+
return [
|
|
9690
|
+
4,
|
|
9691
|
+
caches[i].set(key, value)
|
|
9692
|
+
];
|
|
9693
|
+
case 2:
|
|
9694
|
+
_state.sent();
|
|
9695
|
+
_state.label = 3;
|
|
9696
|
+
case 3:
|
|
9697
|
+
i -= 1;
|
|
9698
|
+
return [
|
|
9699
|
+
3,
|
|
9700
|
+
1
|
|
9701
|
+
];
|
|
9702
|
+
case 4:
|
|
9703
|
+
return [
|
|
9704
|
+
2
|
|
9705
|
+
];
|
|
9706
|
+
}
|
|
9707
|
+
});
|
|
9708
|
+
})();
|
|
9709
|
+
},
|
|
9710
|
+
remove: function remove(key) {
|
|
9711
|
+
return _async_to_generator$a(function() {
|
|
9712
|
+
var i;
|
|
9713
|
+
return _ts_generator$a(this, function(_state) {
|
|
9714
|
+
switch(_state.label){
|
|
9715
|
+
case 0:
|
|
9716
|
+
i = caches.length - 1;
|
|
9717
|
+
_state.label = 1;
|
|
9718
|
+
case 1:
|
|
9719
|
+
if (!(i >= 0)) return [
|
|
9720
|
+
3,
|
|
9721
|
+
4
|
|
9722
|
+
];
|
|
9723
|
+
return [
|
|
9724
|
+
4,
|
|
9725
|
+
caches[i].remove(key)
|
|
9726
|
+
];
|
|
9727
|
+
case 2:
|
|
9728
|
+
_state.sent();
|
|
9729
|
+
_state.label = 3;
|
|
9730
|
+
case 3:
|
|
9731
|
+
i -= 1;
|
|
9732
|
+
return [
|
|
9733
|
+
3,
|
|
9734
|
+
1
|
|
9735
|
+
];
|
|
9736
|
+
case 4:
|
|
9737
|
+
return [
|
|
9738
|
+
2
|
|
9739
|
+
];
|
|
9740
|
+
}
|
|
9741
|
+
});
|
|
9742
|
+
})();
|
|
9743
|
+
},
|
|
9744
|
+
clear: function clear() {
|
|
9745
|
+
return _async_to_generator$a(function() {
|
|
9746
|
+
var i;
|
|
9747
|
+
return _ts_generator$a(this, function(_state) {
|
|
9748
|
+
switch(_state.label){
|
|
9749
|
+
case 0:
|
|
9750
|
+
i = caches.length - 1;
|
|
9751
|
+
_state.label = 1;
|
|
9752
|
+
case 1:
|
|
9753
|
+
if (!(i >= 0)) return [
|
|
9754
|
+
3,
|
|
9755
|
+
4
|
|
9756
|
+
];
|
|
9757
|
+
return [
|
|
9758
|
+
4,
|
|
9759
|
+
caches[i].clear()
|
|
9760
|
+
];
|
|
9761
|
+
case 2:
|
|
9762
|
+
_state.sent();
|
|
9763
|
+
_state.label = 3;
|
|
9764
|
+
case 3:
|
|
9765
|
+
i -= 1;
|
|
9766
|
+
return [
|
|
9767
|
+
3,
|
|
9768
|
+
1
|
|
9769
|
+
];
|
|
9770
|
+
case 4:
|
|
9771
|
+
return [
|
|
9772
|
+
2
|
|
9773
|
+
];
|
|
9774
|
+
}
|
|
9775
|
+
});
|
|
9776
|
+
})();
|
|
7773
9777
|
}
|
|
7774
|
-
}
|
|
9778
|
+
};
|
|
7775
9779
|
}
|
|
7776
9780
|
|
|
7777
9781
|
function _array_like_to_array$o(arr, len) {
|
|
@@ -8430,6 +10434,12 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
8430
10434
|
* @param decision - the constant boolean value to return
|
|
8431
10435
|
* @returns a decision function that always returns the given boolean
|
|
8432
10436
|
*
|
|
10437
|
+
* @dbxUtil
|
|
10438
|
+
* @dbxUtilCategory value
|
|
10439
|
+
* @dbxUtilKind factory
|
|
10440
|
+
* @dbxUtilTags decision, boolean, predicate, factory, constant
|
|
10441
|
+
* @dbxUtilRelated as-decision-function, invert-decision
|
|
10442
|
+
*
|
|
8433
10443
|
* @example
|
|
8434
10444
|
* ```ts
|
|
8435
10445
|
* const alwaysTrue = decisionFunction(true);
|
|
@@ -8464,6 +10474,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
8464
10474
|
* @param defaultIfUndefined - fallback boolean when the input is nullish (defaults to true)
|
|
8465
10475
|
* @returns a {@link DecisionFunction} derived from the input
|
|
8466
10476
|
*
|
|
10477
|
+
* @dbxUtil
|
|
10478
|
+
* @dbxUtilCategory value
|
|
10479
|
+
* @dbxUtilTags decision, normalize, boolean, default, coerce, predicate
|
|
10480
|
+
* @dbxUtilRelated decision-function, invert-decision
|
|
10481
|
+
*
|
|
8467
10482
|
* @example
|
|
8468
10483
|
* ```ts
|
|
8469
10484
|
* const fn = asDecisionFunction(true);
|
|
@@ -8567,9 +10582,33 @@ function _unsupported_iterable_to_array$m(o, minLen) {
|
|
|
8567
10582
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
8568
10583
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$m(o, minLen);
|
|
8569
10584
|
}
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
10585
|
+
/**
|
|
10586
|
+
* The forward-slash character used to separate parts of a slash path.
|
|
10587
|
+
*
|
|
10588
|
+
* @dbxUtil
|
|
10589
|
+
* @dbxUtilCategory path
|
|
10590
|
+
* @dbxUtilKind const
|
|
10591
|
+
* @dbxUtilTags path, slash, separator, constant, delimiter
|
|
10592
|
+
* @dbxUtilRelated slash-path-file-type-separator, slash-path-parts
|
|
10593
|
+
*/ var SLASH_PATH_SEPARATOR = '/';
|
|
10594
|
+
/**
|
|
10595
|
+
* The dot character used to separate the file extension from the file name within a slash path.
|
|
10596
|
+
*
|
|
10597
|
+
* @dbxUtil
|
|
10598
|
+
* @dbxUtilCategory path
|
|
10599
|
+
* @dbxUtilKind const
|
|
10600
|
+
* @dbxUtilTags path, slash, separator, dot, file-type, extension, constant
|
|
10601
|
+
* @dbxUtilRelated slash-path-separator, slash-path-type, slash-path-details
|
|
10602
|
+
*/ var SLASH_PATH_FILE_TYPE_SEPARATOR = '.';
|
|
10603
|
+
/**
|
|
10604
|
+
* The default set of characters that are considered illegal in a slash path.
|
|
10605
|
+
*
|
|
10606
|
+
* @dbxUtil
|
|
10607
|
+
* @dbxUtilCategory path
|
|
10608
|
+
* @dbxUtilKind const
|
|
10609
|
+
* @dbxUtilTags path, slash, illegal, characters, default, sanitize, validate
|
|
10610
|
+
* @dbxUtilRelated default-slash-path-illegal-character-replacement, slash-path-validation-factory
|
|
10611
|
+
*/ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = [
|
|
8573
10612
|
'#',
|
|
8574
10613
|
'[',
|
|
8575
10614
|
']',
|
|
@@ -8578,10 +10617,21 @@ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = [
|
|
|
8578
10617
|
];
|
|
8579
10618
|
/**
|
|
8580
10619
|
* Default replacement character for illegal characters.
|
|
10620
|
+
*
|
|
10621
|
+
* @dbxUtil
|
|
10622
|
+
* @dbxUtilCategory path
|
|
10623
|
+
* @dbxUtilKind const
|
|
10624
|
+
* @dbxUtilTags path, slash, illegal, replacement, default, sanitize
|
|
10625
|
+
* @dbxUtilRelated default-slash-path-illegal-characters, slash-path-validation-factory
|
|
8581
10626
|
*/ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT = '_';
|
|
8582
10627
|
/**
|
|
8583
10628
|
* Determines the type of a slash path string.
|
|
8584
10629
|
*
|
|
10630
|
+
* @dbxUtil
|
|
10631
|
+
* @dbxUtilCategory path
|
|
10632
|
+
* @dbxUtilTags path, slash, type, classify, file, folder, typed, detect
|
|
10633
|
+
* @dbxUtilRelated is-slash-path-file, is-slash-path-folder, is-slash-path-typed-file, is-valid-slash-path
|
|
10634
|
+
*
|
|
8585
10635
|
* @param input - The slash path to classify.
|
|
8586
10636
|
* @returns The path type classification.
|
|
8587
10637
|
*/ function slashPathType(input) {
|
|
@@ -8612,6 +10662,11 @@ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = [
|
|
|
8612
10662
|
/**
|
|
8613
10663
|
* Type guard that checks if the input is a file path (typed or untyped).
|
|
8614
10664
|
*
|
|
10665
|
+
* @dbxUtil
|
|
10666
|
+
* @dbxUtilCategory path
|
|
10667
|
+
* @dbxUtilTags path, slash, file, type-guard, predicate, check, is
|
|
10668
|
+
* @dbxUtilRelated is-slash-path-typed-file, is-slash-path-folder, slash-path-type
|
|
10669
|
+
*
|
|
8615
10670
|
* @param input - The string to check.
|
|
8616
10671
|
* @returns Whether the input is a file path.
|
|
8617
10672
|
*/ function isSlashPathFile(input) {
|
|
@@ -8621,6 +10676,11 @@ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = [
|
|
|
8621
10676
|
/**
|
|
8622
10677
|
* Type guard that checks if the input is a typed file path (contains a file extension).
|
|
8623
10678
|
*
|
|
10679
|
+
* @dbxUtil
|
|
10680
|
+
* @dbxUtilCategory path
|
|
10681
|
+
* @dbxUtilTags path, slash, file, extension, type-guard, predicate, typed
|
|
10682
|
+
* @dbxUtilRelated is-slash-path-file, is-slash-path-folder, slash-path-type
|
|
10683
|
+
*
|
|
8624
10684
|
* @param input - The string to check.
|
|
8625
10685
|
* @returns Whether the input is a typed file path.
|
|
8626
10686
|
*/ function isSlashPathTypedFile(input) {
|
|
@@ -8630,6 +10690,11 @@ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = [
|
|
|
8630
10690
|
/**
|
|
8631
10691
|
* Type guard that checks if the input is a folder path (ends with a slash).
|
|
8632
10692
|
*
|
|
10693
|
+
* @dbxUtil
|
|
10694
|
+
* @dbxUtilCategory path
|
|
10695
|
+
* @dbxUtilTags path, slash, folder, directory, type-guard, predicate, trailing
|
|
10696
|
+
* @dbxUtilRelated is-slash-path-file, is-valid-slash-path, slash-path-type
|
|
10697
|
+
*
|
|
8633
10698
|
* @param input - The string to check.
|
|
8634
10699
|
* @returns Whether the input is a folder path.
|
|
8635
10700
|
*/ function isSlashPathFolder(input) {
|
|
@@ -8638,6 +10703,11 @@ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = [
|
|
|
8638
10703
|
/**
|
|
8639
10704
|
* Type guard that checks if the input is a valid slash path (not 'invalid' type).
|
|
8640
10705
|
*
|
|
10706
|
+
* @dbxUtil
|
|
10707
|
+
* @dbxUtilCategory path
|
|
10708
|
+
* @dbxUtilTags path, slash, valid, type-guard, predicate, check, validate
|
|
10709
|
+
* @dbxUtilRelated slash-path-type, slash-path-validation-factory, slash-path-invalid-error
|
|
10710
|
+
*
|
|
8641
10711
|
* @param input - The string to check.
|
|
8642
10712
|
* @returns Whether the input is a valid slash path.
|
|
8643
10713
|
*/ function isValidSlashPath(input) {
|
|
@@ -8646,6 +10716,11 @@ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = [
|
|
|
8646
10716
|
/**
|
|
8647
10717
|
* Returns the last part of the slash path.
|
|
8648
10718
|
*
|
|
10719
|
+
* @dbxUtil
|
|
10720
|
+
* @dbxUtilCategory path
|
|
10721
|
+
* @dbxUtilTags path, slash, name, last, basename, leaf, file, folder
|
|
10722
|
+
* @dbxUtilRelated slash-path-parts, slash-path-details, isolate-slash-path
|
|
10723
|
+
*
|
|
8649
10724
|
* @param slashPath - The path to extract the name from.
|
|
8650
10725
|
* @returns The last part of the path (file name or folder name).
|
|
8651
10726
|
*/ function slashPathName(slashPath) {
|
|
@@ -8655,6 +10730,11 @@ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = [
|
|
|
8655
10730
|
/**
|
|
8656
10731
|
* Returns each section of a SlashPath.
|
|
8657
10732
|
*
|
|
10733
|
+
* @dbxUtil
|
|
10734
|
+
* @dbxUtilCategory path
|
|
10735
|
+
* @dbxUtilTags path, slash, split, parts, segments, sections, components
|
|
10736
|
+
* @dbxUtilRelated slash-path-name, slash-path-details, isolate-slash-path
|
|
10737
|
+
*
|
|
8658
10738
|
* @param slashPath - The path to split.
|
|
8659
10739
|
* @returns Array of non-empty path segments.
|
|
8660
10740
|
*/ function slashPathParts(slashPath) {
|
|
@@ -8663,6 +10743,12 @@ var DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = [
|
|
|
8663
10743
|
/**
|
|
8664
10744
|
* Creates a function that enforces the specified start type on a slash path.
|
|
8665
10745
|
*
|
|
10746
|
+
* @dbxUtil
|
|
10747
|
+
* @dbxUtilCategory path
|
|
10748
|
+
* @dbxUtilKind factory
|
|
10749
|
+
* @dbxUtilTags path, slash, factory, start-type, relative, absolute, normalize
|
|
10750
|
+
* @dbxUtilRelated to-relative-slash-path-start-type, to-absolute-slash-path-start-type, slash-path-factory
|
|
10751
|
+
*
|
|
8666
10752
|
* @param type - The start type to enforce.
|
|
8667
10753
|
* @returns A function that transforms paths to the specified start type.
|
|
8668
10754
|
*/ function slashPathStartTypeFactory(type) {
|
|
@@ -8689,6 +10775,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8689
10775
|
/**
|
|
8690
10776
|
* Converts a slash path to a relative path by removing all leading slashes.
|
|
8691
10777
|
*
|
|
10778
|
+
* @dbxUtil
|
|
10779
|
+
* @dbxUtilCategory path
|
|
10780
|
+
* @dbxUtilTags path, slash, relative, leading, strip, normalize, convert
|
|
10781
|
+
* @dbxUtilRelated to-absolute-slash-path-start-type, slash-path-start-type-factory
|
|
10782
|
+
*
|
|
8692
10783
|
* @param input - The slash path to convert.
|
|
8693
10784
|
* @returns A relative path without leading slashes.
|
|
8694
10785
|
*/ function toRelativeSlashPathStartType(input) {
|
|
@@ -8698,6 +10789,12 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8698
10789
|
/**
|
|
8699
10790
|
* Creates a SlashPathFolderFactory.
|
|
8700
10791
|
*
|
|
10792
|
+
* @dbxUtil
|
|
10793
|
+
* @dbxUtilCategory path
|
|
10794
|
+
* @dbxUtilKind factory
|
|
10795
|
+
* @dbxUtilTags path, slash, folder, factory, validate, normalize, trailing-slash
|
|
10796
|
+
* @dbxUtilRelated slash-path-folder, slash-path-validation-factory, add-trailing-slash
|
|
10797
|
+
*
|
|
8701
10798
|
* @param config Configuration options for the factory.
|
|
8702
10799
|
* @returns A SlashPathFolderFactory.
|
|
8703
10800
|
*/ function slashPathFolderFactory() {
|
|
@@ -8753,6 +10850,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8753
10850
|
*
|
|
8754
10851
|
* If the input is a file, the folder of the file is returned instead.
|
|
8755
10852
|
*
|
|
10853
|
+
* @dbxUtil
|
|
10854
|
+
* @dbxUtilCategory path
|
|
10855
|
+
* @dbxUtilTags path, slash, folder, convert, normalize, validate, directory
|
|
10856
|
+
* @dbxUtilRelated slash-path-folder-factory, slash-path-details, add-trailing-slash
|
|
10857
|
+
*
|
|
8756
10858
|
* @param input - the string path to convert to a folder path
|
|
8757
10859
|
* @param config - optional configuration controlling path type inference and invalid-path handling
|
|
8758
10860
|
* @returns a valid slash path folder string with a trailing slash, or an empty string for relative root
|
|
@@ -8762,6 +10864,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8762
10864
|
/**
|
|
8763
10865
|
* Converts a slash path to an absolute path by ensuring exactly one leading slash.
|
|
8764
10866
|
*
|
|
10867
|
+
* @dbxUtil
|
|
10868
|
+
* @dbxUtilCategory path
|
|
10869
|
+
* @dbxUtilTags path, slash, absolute, leading, prefix, normalize, convert
|
|
10870
|
+
* @dbxUtilRelated to-relative-slash-path-start-type, slash-path-start-type-factory, fix-multi-slashes-in-slash-path
|
|
10871
|
+
*
|
|
8765
10872
|
* @param input - The slash path to convert.
|
|
8766
10873
|
* @returns An absolute path starting with a single slash.
|
|
8767
10874
|
*/ function toAbsoluteSlashPathStartType(input) {
|
|
@@ -8771,6 +10878,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8771
10878
|
/**
|
|
8772
10879
|
* Replaces consecutive double slashes with single slashes.
|
|
8773
10880
|
*
|
|
10881
|
+
* @dbxUtil
|
|
10882
|
+
* @dbxUtilCategory path
|
|
10883
|
+
* @dbxUtilTags path, slash, fix, collapse, double, normalize, dedupe
|
|
10884
|
+
* @dbxUtilRelated merge-slash-paths, replace-multiple-file-paths-in-slash-path
|
|
10885
|
+
*
|
|
8774
10886
|
* @param input - The slash path to fix.
|
|
8775
10887
|
* @returns The path with double slashes collapsed.
|
|
8776
10888
|
*/ function fixMultiSlashesInSlashPath(input) {
|
|
@@ -8779,6 +10891,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8779
10891
|
/**
|
|
8780
10892
|
* Replaces consecutive double slashes with single slashes. Alias for {@link fixMultiSlashesInSlashPath}.
|
|
8781
10893
|
*
|
|
10894
|
+
* @dbxUtil
|
|
10895
|
+
* @dbxUtilCategory path
|
|
10896
|
+
* @dbxUtilTags path, slash, alias, collapse, double, normalize
|
|
10897
|
+
* @dbxUtilRelated fix-multi-slashes-in-slash-path, merge-slash-paths
|
|
10898
|
+
*
|
|
8782
10899
|
* @param input - The slash path to fix.
|
|
8783
10900
|
* @returns The path with double slashes collapsed.
|
|
8784
10901
|
*/ function replaceMultipleFilePathsInSlashPath(input) {
|
|
@@ -8787,6 +10904,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8787
10904
|
/**
|
|
8788
10905
|
* Removes all trailing slashes from a slash path.
|
|
8789
10906
|
*
|
|
10907
|
+
* @dbxUtil
|
|
10908
|
+
* @dbxUtilCategory path
|
|
10909
|
+
* @dbxUtilTags path, slash, trim, trailing, strip, remove, normalize
|
|
10910
|
+
* @dbxUtilRelated add-trailing-slash, remove-trailing-file-type-separators
|
|
10911
|
+
*
|
|
8790
10912
|
* @param input - The slash path to trim.
|
|
8791
10913
|
* @returns The path without trailing slashes.
|
|
8792
10914
|
*/ function removeTrailingSlashes(input) {
|
|
@@ -8795,6 +10917,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8795
10917
|
/**
|
|
8796
10918
|
* Removes all trailing dots from a slash path.
|
|
8797
10919
|
*
|
|
10920
|
+
* @dbxUtil
|
|
10921
|
+
* @dbxUtilCategory path
|
|
10922
|
+
* @dbxUtilTags path, slash, trim, trailing, dot, file-type, strip, normalize
|
|
10923
|
+
* @dbxUtilRelated remove-trailing-slashes, replace-invalid-file-path-type-separators-in-slash-path
|
|
10924
|
+
*
|
|
8798
10925
|
* @param input - The slash path to trim.
|
|
8799
10926
|
* @returns The path without trailing dots.
|
|
8800
10927
|
*/ function removeTrailingFileTypeSeparators(input) {
|
|
@@ -8803,6 +10930,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8803
10930
|
/**
|
|
8804
10931
|
* Adds a trailing slash to the input if it does not already have one.
|
|
8805
10932
|
*
|
|
10933
|
+
* @dbxUtil
|
|
10934
|
+
* @dbxUtilCategory path
|
|
10935
|
+
* @dbxUtilTags path, slash, trailing, append, folder, ensure, normalize
|
|
10936
|
+
* @dbxUtilRelated remove-trailing-slashes, slash-path-folder, slash-path-folder-factory
|
|
10937
|
+
*
|
|
8806
10938
|
* @param input A slash path.
|
|
8807
10939
|
* @returns A slash path folder.
|
|
8808
10940
|
*/ function addTrailingSlash(input) {
|
|
@@ -8811,6 +10943,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8811
10943
|
/**
|
|
8812
10944
|
* Replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
|
|
8813
10945
|
*
|
|
10946
|
+
* @dbxUtil
|
|
10947
|
+
* @dbxUtilCategory path
|
|
10948
|
+
* @dbxUtilTags path, slash, dot, file-type, replace, sanitize, fix, validate
|
|
10949
|
+
* @dbxUtilRelated replace-invalid-file-path-type-separators-in-slash-path-function, slash-path-validation-factory
|
|
10950
|
+
*
|
|
8814
10951
|
* @param input
|
|
8815
10952
|
* @param replaceWith
|
|
8816
10953
|
* @returns
|
|
@@ -8820,6 +10957,12 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8820
10957
|
/**
|
|
8821
10958
|
* Creates a function that replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
|
|
8822
10959
|
*
|
|
10960
|
+
* @dbxUtil
|
|
10961
|
+
* @dbxUtilCategory path
|
|
10962
|
+
* @dbxUtilKind factory
|
|
10963
|
+
* @dbxUtilTags path, slash, dot, file-type, factory, replace, sanitize, validate
|
|
10964
|
+
* @dbxUtilRelated replace-invalid-file-path-type-separators-in-slash-path, slash-path-validation-factory
|
|
10965
|
+
*
|
|
8823
10966
|
* @param input
|
|
8824
10967
|
* @param replaceWith
|
|
8825
10968
|
* @returns
|
|
@@ -8860,6 +11003,12 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8860
11003
|
/**
|
|
8861
11004
|
* Creates a validation/fixup function for slash paths that replaces illegal characters and extra dots.
|
|
8862
11005
|
*
|
|
11006
|
+
* @dbxUtil
|
|
11007
|
+
* @dbxUtilCategory path
|
|
11008
|
+
* @dbxUtilKind factory
|
|
11009
|
+
* @dbxUtilTags path, slash, validate, factory, sanitize, illegal, replace, fix
|
|
11010
|
+
* @dbxUtilRelated is-valid-slash-path, replace-invalid-file-path-type-separators-in-slash-path-function, slash-path-factory, slash-path-invalid-error
|
|
11011
|
+
*
|
|
8863
11012
|
* @param config - Configuration for validation behavior.
|
|
8864
11013
|
* @returns A function that validates and fixes a slash path.
|
|
8865
11014
|
*/ function slashPathValidationFactory(config) {
|
|
@@ -8885,6 +11034,12 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8885
11034
|
/**
|
|
8886
11035
|
* Creates a factory function that merges path segments together with optional base path, start type enforcement, and validation.
|
|
8887
11036
|
*
|
|
11037
|
+
* @dbxUtil
|
|
11038
|
+
* @dbxUtilCategory path
|
|
11039
|
+
* @dbxUtilKind factory
|
|
11040
|
+
* @dbxUtilTags path, slash, factory, merge, base, start-type, validate, normalize
|
|
11041
|
+
* @dbxUtilRelated merge-slash-paths, slash-path-validation-factory, slash-path-start-type-factory
|
|
11042
|
+
*
|
|
8888
11043
|
* @param config - Configuration for path generation.
|
|
8889
11044
|
* @returns A factory function that merges input paths into a single validated slash path.
|
|
8890
11045
|
*/ function slashPathFactory(config) {
|
|
@@ -8903,6 +11058,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8903
11058
|
/**
|
|
8904
11059
|
* Merges an array of path segments into a single slash path, filtering nullish values and collapsing double slashes.
|
|
8905
11060
|
*
|
|
11061
|
+
* @dbxUtil
|
|
11062
|
+
* @dbxUtilCategory path
|
|
11063
|
+
* @dbxUtilTags path, slash, merge, join, concat, segments, normalize, dedupe
|
|
11064
|
+
* @dbxUtilRelated slash-path-factory, fix-multi-slashes-in-slash-path, slash-path-parts
|
|
11065
|
+
*
|
|
8906
11066
|
* @param paths - Array of path segments to merge.
|
|
8907
11067
|
* @returns The merged slash path.
|
|
8908
11068
|
*/ function mergeSlashPaths(paths) {
|
|
@@ -8912,6 +11072,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8912
11072
|
/**
|
|
8913
11073
|
* Creates an Error indicating that a slash path is invalid.
|
|
8914
11074
|
*
|
|
11075
|
+
* @dbxUtil
|
|
11076
|
+
* @dbxUtilCategory path
|
|
11077
|
+
* @dbxUtilTags path, slash, error, invalid, throw, validate
|
|
11078
|
+
* @dbxUtilRelated is-valid-slash-path, slash-path-validation-factory
|
|
11079
|
+
*
|
|
8915
11080
|
* @returns A new Error with a descriptive message.
|
|
8916
11081
|
*/ function slashPathInvalidError() {
|
|
8917
11082
|
return new Error('The slashPath is invalid.');
|
|
@@ -8919,6 +11084,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8919
11084
|
/**
|
|
8920
11085
|
* Splits the path and returns the items at the given ranges.
|
|
8921
11086
|
*
|
|
11087
|
+
* @dbxUtil
|
|
11088
|
+
* @dbxUtilCategory path
|
|
11089
|
+
* @dbxUtilTags path, slash, isolate, slice, range, segments, extract, sub-path
|
|
11090
|
+
* @dbxUtilRelated isolate-slash-path-function, slash-path-parts, slash-path-details
|
|
11091
|
+
*
|
|
8922
11092
|
* @param path - The path to isolate parts from.
|
|
8923
11093
|
* @param range - Index range defining which path segments to extract.
|
|
8924
11094
|
* @returns A new slash path containing only the segments within the range.
|
|
@@ -8930,6 +11100,12 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8930
11100
|
/**
|
|
8931
11101
|
* Creates an IsolateSlashPathFunction.
|
|
8932
11102
|
*
|
|
11103
|
+
* @dbxUtil
|
|
11104
|
+
* @dbxUtilCategory path
|
|
11105
|
+
* @dbxUtilKind factory
|
|
11106
|
+
* @dbxUtilTags path, slash, isolate, factory, slice, range, segments, sub-path
|
|
11107
|
+
* @dbxUtilRelated isolate-slash-path, slash-path-parts, slash-path-details
|
|
11108
|
+
*
|
|
8933
11109
|
* @param config - Configuration with range, optional start type, and file mode.
|
|
8934
11110
|
* @returns A function that isolates path segments within the configured range.
|
|
8935
11111
|
*/ function isolateSlashPathFunction(config) {
|
|
@@ -8950,6 +11126,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
8950
11126
|
/**
|
|
8951
11127
|
* Returns the details of a path.
|
|
8952
11128
|
*
|
|
11129
|
+
* @dbxUtil
|
|
11130
|
+
* @dbxUtilCategory path
|
|
11131
|
+
* @dbxUtilTags path, slash, details, parse, decompose, file, folder, extension, parts
|
|
11132
|
+
* @dbxUtilRelated slash-path-type, slash-path-parts, slash-path-folder, slash-path-name
|
|
11133
|
+
*
|
|
8953
11134
|
* @param path The path to get details for.
|
|
8954
11135
|
* @returns The details of the path.
|
|
8955
11136
|
*/ function slashPathDetails(path) {
|
|
@@ -9022,6 +11203,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
9022
11203
|
/**
|
|
9023
11204
|
* Expands the input matcher path into decision functions.
|
|
9024
11205
|
*
|
|
11206
|
+
* @dbxUtil
|
|
11207
|
+
* @dbxUtilCategory path
|
|
11208
|
+
* @dbxUtilTags path, slash, matcher, expand, decision, predicate, wildcard, build
|
|
11209
|
+
* @dbxUtilRelated slash-path-path-matcher, slash-path-sub-path-matcher, slash-path-path-matcher-config
|
|
11210
|
+
*
|
|
9025
11211
|
* @param path - Matcher path parts to expand into decision functions.
|
|
9026
11212
|
* @returns Array of decision functions for each path part.
|
|
9027
11213
|
*/ function expandSlashPathPathMatcherPartToDecisionFunctions(path) {
|
|
@@ -9064,6 +11250,11 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
9064
11250
|
/**
|
|
9065
11251
|
* Creates a SlashPathPathMatcherConfig from the input.
|
|
9066
11252
|
*
|
|
11253
|
+
* @dbxUtil
|
|
11254
|
+
* @dbxUtilCategory path
|
|
11255
|
+
* @dbxUtilTags path, slash, matcher, config, normalize, coerce
|
|
11256
|
+
* @dbxUtilRelated slash-path-path-matcher, slash-path-sub-path-matcher
|
|
11257
|
+
*
|
|
9067
11258
|
* @param input The configuration input.
|
|
9068
11259
|
* @returns The configuration.
|
|
9069
11260
|
*/ function slashPathPathMatcherConfig(input) {
|
|
@@ -9093,6 +11284,12 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
9093
11284
|
/**
|
|
9094
11285
|
* Creates a SlashPathPathMatcher.
|
|
9095
11286
|
*
|
|
11287
|
+
* @dbxUtil
|
|
11288
|
+
* @dbxUtilCategory path
|
|
11289
|
+
* @dbxUtilKind factory
|
|
11290
|
+
* @dbxUtilTags path, slash, matcher, factory, predicate, wildcard, target, compare
|
|
11291
|
+
* @dbxUtilRelated slash-path-sub-path-matcher, expand-slash-path-path-matcher-part-to-decision-functions, slash-path-path-matcher-config
|
|
11292
|
+
*
|
|
9096
11293
|
* @param input - the matcher configuration, which may be a target path string, an array of path parts, or a full config object
|
|
9097
11294
|
* @returns The matcher.
|
|
9098
11295
|
*/ function slashPathPathMatcher(input) {
|
|
@@ -9148,6 +11345,12 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
9148
11345
|
/**
|
|
9149
11346
|
* Creates a SlashPathSubPathMatcher.
|
|
9150
11347
|
*
|
|
11348
|
+
* @dbxUtil
|
|
11349
|
+
* @dbxUtilCategory path
|
|
11350
|
+
* @dbxUtilKind factory
|
|
11351
|
+
* @dbxUtilTags path, slash, matcher, sub-path, factory, base-path, prefix, predicate
|
|
11352
|
+
* @dbxUtilRelated slash-path-path-matcher, expand-slash-path-path-matcher-part-to-decision-functions
|
|
11353
|
+
*
|
|
9151
11354
|
* @param config The configuration for the matcher.
|
|
9152
11355
|
* @returns The matcher.
|
|
9153
11356
|
*/ function slashPathSubPathMatcher(config) {
|
|
@@ -9621,6 +11824,11 @@ function _unsupported_iterable_to_array$l(o, minLen) {
|
|
|
9621
11824
|
/**
|
|
9622
11825
|
* Extracts unique domain names from a list of email addresses (case-insensitive).
|
|
9623
11826
|
*
|
|
11827
|
+
* @dbxUtil
|
|
11828
|
+
* @dbxUtilCategory contact
|
|
11829
|
+
* @dbxUtilTags email, domain, extract, unique, dedupe, case-insensitive
|
|
11830
|
+
* @dbxUtilRelated read-domain-from-email-address, read-email-domain-from-url-or-email-address
|
|
11831
|
+
*
|
|
9624
11832
|
* @param addresses - Array of email addresses to extract domains from
|
|
9625
11833
|
* @returns Array of unique lowercase domain strings
|
|
9626
11834
|
*/ function readDomainsFromEmailAddresses(addresses) {
|
|
@@ -9629,6 +11837,11 @@ function _unsupported_iterable_to_array$l(o, minLen) {
|
|
|
9629
11837
|
/**
|
|
9630
11838
|
* Extracts the domain portion from a single email address.
|
|
9631
11839
|
*
|
|
11840
|
+
* @dbxUtil
|
|
11841
|
+
* @dbxUtilCategory contact
|
|
11842
|
+
* @dbxUtilTags email, domain, extract, parse, lowercase
|
|
11843
|
+
* @dbxUtilRelated read-domains-from-email-addresses, read-email-domain-from-url-or-email-address
|
|
11844
|
+
*
|
|
9632
11845
|
* @param address - The email address to extract the domain from
|
|
9633
11846
|
* @returns The lowercase domain string
|
|
9634
11847
|
*/ function readDomainFromEmailAddress(address) {
|
|
@@ -9647,6 +11860,11 @@ function _unsupported_iterable_to_array$l(o, minLen) {
|
|
|
9647
11860
|
*
|
|
9648
11861
|
* The "www." prefix is stripped from URL-style inputs since emails typically don't use it.
|
|
9649
11862
|
*
|
|
11863
|
+
* @dbxUtil
|
|
11864
|
+
* @dbxUtilCategory contact
|
|
11865
|
+
* @dbxUtilTags email, domain, url, extract, normalize, parse, www
|
|
11866
|
+
* @dbxUtilRelated read-domain-from-email-address, read-domains-from-email-addresses
|
|
11867
|
+
*
|
|
9650
11868
|
* @param urlLikeInput - A URL, email address, or domain string
|
|
9651
11869
|
* @returns The extracted domain
|
|
9652
11870
|
*/ function readEmailDomainFromUrlOrEmailAddress(urlLikeInput) {
|
|
@@ -9695,6 +11913,11 @@ function _unsupported_iterable_to_array$k(o, minLen) {
|
|
|
9695
11913
|
* Converts an EmailParticipant object to a formatted string representation.
|
|
9696
11914
|
* The format is: "name<email>" or "<email>" if no name is provided.
|
|
9697
11915
|
*
|
|
11916
|
+
* @dbxUtil
|
|
11917
|
+
* @dbxUtilCategory contact
|
|
11918
|
+
* @dbxUtilTags email, participant, convert, format, serialize, name
|
|
11919
|
+
* @dbxUtilRelated convert-email-participant-string-to-participant, coerce-to-email-participants
|
|
11920
|
+
*
|
|
9698
11921
|
* @param participant - The email participant to convert
|
|
9699
11922
|
* @returns A formatted string representation of the participant
|
|
9700
11923
|
*/ function convertParticipantToEmailParticipantString(participant) {
|
|
@@ -9706,6 +11929,11 @@ function _unsupported_iterable_to_array$k(o, minLen) {
|
|
|
9706
11929
|
* Converts a formatted participant string into an EmailParticipant object.
|
|
9707
11930
|
* Parses strings in the format "name<email>" or "<email>".
|
|
9708
11931
|
*
|
|
11932
|
+
* @dbxUtil
|
|
11933
|
+
* @dbxUtilCategory contact
|
|
11934
|
+
* @dbxUtilTags email, participant, parse, deserialize, name, address
|
|
11935
|
+
* @dbxUtilRelated convert-participant-to-email-participant-string, coerce-to-email-participants
|
|
11936
|
+
*
|
|
9709
11937
|
* @param participantString - The string to parse
|
|
9710
11938
|
* @returns An EmailParticipant object with the extracted name and email
|
|
9711
11939
|
*/ function convertEmailParticipantStringToParticipant(participantString) {
|
|
@@ -9721,6 +11949,11 @@ function _unsupported_iterable_to_array$k(o, minLen) {
|
|
|
9721
11949
|
* Combines an array of EmailParticipants with an array of email addresses.
|
|
9722
11950
|
* Email addresses that don't already exist in the participants array are converted to EmailParticipant objects.
|
|
9723
11951
|
*
|
|
11952
|
+
* @dbxUtil
|
|
11953
|
+
* @dbxUtilCategory contact
|
|
11954
|
+
* @dbxUtilTags email, participant, merge, combine, dedupe, coerce, normalize
|
|
11955
|
+
* @dbxUtilRelated convert-participant-to-email-participant-string, convert-email-participant-string-to-participant
|
|
11956
|
+
*
|
|
9724
11957
|
* @param options - Object containing participants and/or emails arrays
|
|
9725
11958
|
* @param options.participants - Array of existing EmailParticipant objects
|
|
9726
11959
|
* @param options.emails - Array of email addresses to include
|
|
@@ -10219,6 +12452,12 @@ function _unsupported_iterable_to_array$j(o, minLen) {
|
|
|
10219
12452
|
};
|
|
10220
12453
|
}
|
|
10221
12454
|
|
|
12455
|
+
/**
|
|
12456
|
+
* No-op function. Useful as a default callback or as a yargs command's `handler` for parent
|
|
12457
|
+
* commands that only register subcommands.
|
|
12458
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
12459
|
+
function noop() {}
|
|
12460
|
+
|
|
10222
12461
|
function _array_like_to_array$i(arr, len) {
|
|
10223
12462
|
if (len == null || len > arr.length) len = arr.length;
|
|
10224
12463
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -12522,6 +14761,12 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
12522
14761
|
* @param compare - the comparator to wrap
|
|
12523
14762
|
* @returns a new comparator that handles nullish values safely before delegating to the wrapped comparator
|
|
12524
14763
|
*
|
|
14764
|
+
* @dbxUtil
|
|
14765
|
+
* @dbxUtilCategory value
|
|
14766
|
+
* @dbxUtilKind factory
|
|
14767
|
+
* @dbxUtilTags equal, equality, compare, comparator, maybe, safe, factory
|
|
14768
|
+
* @dbxUtilRelated safe-compare-equality
|
|
14769
|
+
*
|
|
12525
14770
|
* @example
|
|
12526
14771
|
* ```ts
|
|
12527
14772
|
* const safeCompare = safeEqualityComparatorFunction((a: number, b: number) => a === b);
|
|
@@ -12545,6 +14790,11 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
12545
14790
|
* @param compare - the equality comparator for non-nullish values
|
|
12546
14791
|
* @returns `true` if the values are considered equal
|
|
12547
14792
|
*
|
|
14793
|
+
* @dbxUtil
|
|
14794
|
+
* @dbxUtilCategory value
|
|
14795
|
+
* @dbxUtilTags equal, equality, compare, maybe, safe
|
|
14796
|
+
* @dbxUtilRelated safe-equality-comparator-function
|
|
14797
|
+
*
|
|
12548
14798
|
* @example
|
|
12549
14799
|
* ```ts
|
|
12550
14800
|
* safeCompareEquality(0, 1, (a, b) => a === b);
|
|
@@ -13102,6 +15352,12 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
13102
15352
|
* @param fn - the equality comparator
|
|
13103
15353
|
* @returns a function that checks whether a given value equals the captured reference
|
|
13104
15354
|
*
|
|
15355
|
+
* @dbxUtil
|
|
15356
|
+
* @dbxUtilCategory value
|
|
15357
|
+
* @dbxUtilKind factory
|
|
15358
|
+
* @dbxUtilTags equal, equality, compare, context, factory
|
|
15359
|
+
* @dbxUtilRelated are-equal-context, all-objects-are-equal
|
|
15360
|
+
*
|
|
13105
15361
|
* @example
|
|
13106
15362
|
* ```ts
|
|
13107
15363
|
* const isEqual = (a: number, b: number) => a === b;
|
|
@@ -13125,6 +15381,12 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
13125
15381
|
* @param fn - the equality comparator
|
|
13126
15382
|
* @returns a function that checks whether all input values equal the captured reference
|
|
13127
15383
|
*
|
|
15384
|
+
* @dbxUtil
|
|
15385
|
+
* @dbxUtilCategory value
|
|
15386
|
+
* @dbxUtilKind factory
|
|
15387
|
+
* @dbxUtilTags equal, equality, compare, context, iterable, all, factory
|
|
15388
|
+
* @dbxUtilRelated is-equal-context, all-objects-are-equal
|
|
15389
|
+
*
|
|
13128
15390
|
* @example
|
|
13129
15391
|
* ```ts
|
|
13130
15392
|
* const isEqual = (a: number, b: number) => a === b;
|
|
@@ -13157,6 +15419,11 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
13157
15419
|
* @param fn - the equality comparator
|
|
13158
15420
|
* @returns `true` if all values are equal to each other, or if fewer than two values are provided
|
|
13159
15421
|
*
|
|
15422
|
+
* @dbxUtil
|
|
15423
|
+
* @dbxUtilCategory value
|
|
15424
|
+
* @dbxUtilTags equal, equality, compare, all, iterable, every
|
|
15425
|
+
* @dbxUtilRelated is-equal-context, are-equal-context
|
|
15426
|
+
*
|
|
13160
15427
|
* @example
|
|
13161
15428
|
* ```ts
|
|
13162
15429
|
* const isEqual = (a: unknown, b: unknown) => a === b;
|
|
@@ -13208,6 +15475,11 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
13208
15475
|
* @param modify - function that mutates the target value
|
|
13209
15476
|
* @returns a new {@link Modifier} pairing the key with the modify function
|
|
13210
15477
|
*
|
|
15478
|
+
* @dbxUtil
|
|
15479
|
+
* @dbxUtilCategory value
|
|
15480
|
+
* @dbxUtilTags modifier, mutate, transform, key, factory
|
|
15481
|
+
* @dbxUtilRelated apply-modifiers, modifier-function
|
|
15482
|
+
*
|
|
13211
15483
|
* @example
|
|
13212
15484
|
* ```ts
|
|
13213
15485
|
* const uppercaseName = modifier<{ name: string }>('uppercase', (x) => { x.name = x.name.toUpperCase(); });
|
|
@@ -13939,6 +16211,11 @@ function _type_of$6(obj) {
|
|
|
13939
16211
|
* Recursively checks whether an object is "empty" — meaning it is null/undefined, has no keys,
|
|
13940
16212
|
* or all of its values are themselves empty (recursively for nested objects, or falsy for primitives).
|
|
13941
16213
|
*
|
|
16214
|
+
* @dbxUtil
|
|
16215
|
+
* @dbxUtilCategory object
|
|
16216
|
+
* @dbxUtilTags object, empty, recursive, deep, check, has-value
|
|
16217
|
+
* @dbxUtilRelated object-has-no-keys, has-value-or-not-empty-object
|
|
16218
|
+
*
|
|
13942
16219
|
* @param obj - Object to check
|
|
13943
16220
|
* @returns `true` if the object is considered empty
|
|
13944
16221
|
*/ function objectIsEmpty(obj) {
|
|
@@ -13977,6 +16254,11 @@ function _type_of$6(obj) {
|
|
|
13977
16254
|
/**
|
|
13978
16255
|
* Converts a Date object or unix timestamp number to a unix timestamp number.
|
|
13979
16256
|
*
|
|
16257
|
+
* @dbxUtil
|
|
16258
|
+
* @dbxUtilCategory date
|
|
16259
|
+
* @dbxUtilTags date, unix, seconds, timestamp, convert, normalize
|
|
16260
|
+
* @dbxUtilRelated unix-date-time-seconds-number-from-date, date-from-date-or-time-seconds-number
|
|
16261
|
+
*
|
|
13980
16262
|
* @param input - Date object or unix timestamp number to convert
|
|
13981
16263
|
* @returns Unix timestamp number if input is valid, null/undefined if input is null/undefined
|
|
13982
16264
|
*/ function unixDateTimeSecondsNumberFromDateOrTimeNumber(input) {
|
|
@@ -13993,6 +16275,11 @@ function _type_of$6(obj) {
|
|
|
13993
16275
|
/**
|
|
13994
16276
|
* Gets the current time as a unix timestamp number.
|
|
13995
16277
|
*
|
|
16278
|
+
* @dbxUtil
|
|
16279
|
+
* @dbxUtilCategory date
|
|
16280
|
+
* @dbxUtilTags date, unix, seconds, timestamp, now, current, time
|
|
16281
|
+
* @dbxUtilRelated unix-date-time-seconds-number-from-date
|
|
16282
|
+
*
|
|
13996
16283
|
* @returns Current time as unix timestamp number
|
|
13997
16284
|
*/ function unixDateTimeSecondsNumberForNow() {
|
|
13998
16285
|
return unixDateTimeSecondsNumberFromDate(new Date());
|
|
@@ -14014,6 +16301,11 @@ function dateFromDateOrTimeSecondsNumber(input) {
|
|
|
14014
16301
|
/**
|
|
14015
16302
|
* Converts a unix timestamp number to a Date object.
|
|
14016
16303
|
*
|
|
16304
|
+
* @dbxUtil
|
|
16305
|
+
* @dbxUtilCategory date
|
|
16306
|
+
* @dbxUtilTags date, unix, seconds, timestamp, convert, parse
|
|
16307
|
+
* @dbxUtilRelated unix-date-time-seconds-number-from-date, date-from-date-or-time-seconds-number
|
|
16308
|
+
*
|
|
14017
16309
|
* @param dateTimeNumber - Unix timestamp number to convert
|
|
14018
16310
|
* @returns Date object if timestamp is valid, null/undefined if timestamp is null/undefined
|
|
14019
16311
|
*/ function unixDateTimeSecondsNumberToDate(dateTimeNumber) {
|
|
@@ -14021,8 +16313,20 @@ function dateFromDateOrTimeSecondsNumber(input) {
|
|
|
14021
16313
|
}
|
|
14022
16314
|
|
|
14023
16315
|
/**
|
|
14024
|
-
* Returns
|
|
14025
|
-
*
|
|
16316
|
+
* Returns an {@link ExpirationDetails} for the given input configuration.
|
|
16317
|
+
*
|
|
16318
|
+
* Use this when you need to ask whether something has expired or what its expiration date is. See {@link ExpirationDetailsInput} for how the expiration date is resolved (`expires` → `expiresAt` → `expiresFromDate + expiresIn`).
|
|
16319
|
+
*
|
|
16320
|
+
* Common patterns:
|
|
16321
|
+
* - **Direct expiration**: `expirationDetails({ expiresAt }).hasExpired()`
|
|
16322
|
+
* - **Wrap an existing object**: `expirationDetails({ expires: token }).hasExpired()`
|
|
16323
|
+
* - **TTL / throttle**: `expirationDetails({ expiresFromDate: lastRunAt, expiresIn: throttleMs })` — see {@link isThrottled}
|
|
16324
|
+
* - **Pre-emptive refresh**: `expirationDetails({ expiresFromDate: expiresAt, expiresIn: -bufferMs })` — treat as expired `bufferMs` before the real expiration, e.g. to refresh a token before it actually dies
|
|
16325
|
+
*
|
|
16326
|
+
* @dbxUtil
|
|
16327
|
+
* @dbxUtilCategory date
|
|
16328
|
+
* @dbxUtilTags expiration, expires, expiry, ttl, throttle, refresh, time-to-live
|
|
16329
|
+
* @dbxUtilRelated is-expired, is-throttled, calculate-expiration-date, is-under-threshold, check-atleast-one-not-expired, check-any-have-expired
|
|
14026
16330
|
*
|
|
14027
16331
|
* @template T - The type of Expires object
|
|
14028
16332
|
* @param input - Configuration for calculating expiration
|
|
@@ -14052,8 +16356,13 @@ function dateFromDateOrTimeSecondsNumber(input) {
|
|
|
14052
16356
|
}
|
|
14053
16357
|
function getExpirationDateForNow(now) {
|
|
14054
16358
|
var expirationDate = null;
|
|
14055
|
-
|
|
14056
|
-
|
|
16359
|
+
// `expires` (when supplied) wins exclusively over the top-level fields per the documented
|
|
16360
|
+
// contract. If the supplied object has no `expiresAt`, the result is "no expiration" — we do
|
|
16361
|
+
// NOT fall through to top-level expiresAt/expiresIn, otherwise an Expires-typed value with a
|
|
16362
|
+
// null expiresAt would silently inherit unrelated top-level overrides.
|
|
16363
|
+
if (expires != null) {
|
|
16364
|
+
var _expires_expiresAt;
|
|
16365
|
+
expirationDate = (_expires_expiresAt = expires.expiresAt) !== null && _expires_expiresAt !== void 0 ? _expires_expiresAt : null;
|
|
14057
16366
|
} else if (expiresAt != null) {
|
|
14058
16367
|
expirationDate = expiresAt;
|
|
14059
16368
|
} else if (expiresIn != null) {
|
|
@@ -14073,11 +16382,41 @@ function dateFromDateOrTimeSecondsNumber(input) {
|
|
|
14073
16382
|
* Convenience function for calculating and returning the expiration date given the input.
|
|
14074
16383
|
* This is a shorthand for expirationDetails(input).getExpirationDate().
|
|
14075
16384
|
*
|
|
16385
|
+
* @dbxUtil
|
|
16386
|
+
* @dbxUtilCategory date
|
|
16387
|
+
* @dbxUtilTags expiration, expires, expiry, ttl, calculate, date
|
|
16388
|
+
* @dbxUtilRelated expiration-details, is-expired
|
|
16389
|
+
*
|
|
14076
16390
|
* @param input - Input configuration used to calculate the expiration date
|
|
14077
16391
|
* @returns The calculated expiration date, or null if no expiration is defined
|
|
14078
16392
|
*/ function calculateExpirationDate(input) {
|
|
14079
16393
|
return expirationDetails(input).getExpirationDate();
|
|
14080
16394
|
}
|
|
16395
|
+
// MARK: isExpired
|
|
16396
|
+
/**
|
|
16397
|
+
* Convenience wrapper around {@link expirationDetails}().hasExpired() that treats null/undefined input or no expiration date as expired.
|
|
16398
|
+
*
|
|
16399
|
+
* @dbxUtil
|
|
16400
|
+
* @dbxUtilCategory date
|
|
16401
|
+
* @dbxUtilTags expiration, expires, expiry, expired, has-expired, is-expired, ttl
|
|
16402
|
+
* @dbxUtilRelated expiration-details, is-throttled, calculate-expiration-date
|
|
16403
|
+
*
|
|
16404
|
+
* @param input - Expiration configuration. Null/undefined is treated as expired.
|
|
16405
|
+
* @param now - Optional override for the current time. Defaults to the current time. Apply any buffer (e.g. for clock skew or pre-emptive refresh) by shifting this value forward.
|
|
16406
|
+
* @returns True when the input is null/undefined or its expiration date has passed; otherwise false.
|
|
16407
|
+
*
|
|
16408
|
+
* @example
|
|
16409
|
+
* isExpired(null); // true
|
|
16410
|
+
* isExpired({ expiresAt: pastDate }); // true
|
|
16411
|
+
* isExpired({ expiresAt: futureDate }); // false
|
|
16412
|
+
* isExpired({ expiresAt: futureDate }, addMilliseconds(new Date(), 60_000)); // true (when within buffer)
|
|
16413
|
+
*/ function isExpired(input, now) {
|
|
16414
|
+
var result = true;
|
|
16415
|
+
if (input != null) {
|
|
16416
|
+
result = expirationDetails(input).hasExpired(now, true);
|
|
16417
|
+
}
|
|
16418
|
+
return result;
|
|
16419
|
+
}
|
|
14081
16420
|
/**
|
|
14082
16421
|
* Returns true if the threshold has not passed since the next run time, compared to now.
|
|
14083
16422
|
*
|
|
@@ -14086,6 +16425,11 @@ function dateFromDateOrTimeSecondsNumber(input) {
|
|
|
14086
16425
|
* Example:
|
|
14087
16426
|
* - Should send a notification at max every 2 days. The threshold is 2 days in milliseconds, and "nextRunAt" is the previously calculated date that was originally "now" + "threshold".
|
|
14088
16427
|
*
|
|
16428
|
+
* @dbxUtil
|
|
16429
|
+
* @dbxUtilCategory date
|
|
16430
|
+
* @dbxUtilTags threshold, throttle, ttl, time-window, rate-limit
|
|
16431
|
+
* @dbxUtilRelated is-throttled, expiration-details
|
|
16432
|
+
*
|
|
14089
16433
|
* @param threshold The threshold time. Typically this is amount of time that was used to calculate the original "nextRunAt" time.
|
|
14090
16434
|
* @param nextRunAt Time the next run will occur. If null/undefined, then this function will return false.
|
|
14091
16435
|
* @param now Optional override for the current time. Defaults to the current time.
|
|
@@ -14102,6 +16446,11 @@ function dateFromDateOrTimeSecondsNumber(input) {
|
|
|
14102
16446
|
* Returns true if the throttle time has not passed since the last run time, compared to now.
|
|
14103
16447
|
* This is useful for rate limiting operations (e.g., "only allow this action once every X milliseconds").
|
|
14104
16448
|
*
|
|
16449
|
+
* @dbxUtil
|
|
16450
|
+
* @dbxUtilCategory date
|
|
16451
|
+
* @dbxUtilTags throttle, throttled, rate-limit, debounce, ttl, expiration
|
|
16452
|
+
* @dbxUtilRelated expiration-details, is-under-threshold, is-expired
|
|
16453
|
+
*
|
|
14105
16454
|
* @param throttleTime - Minimum time in milliseconds that must pass between operations
|
|
14106
16455
|
* @param lastRunAt - Timestamp when the operation was last performed
|
|
14107
16456
|
* @param now - Optional override for the current time (defaults to the current time)
|
|
@@ -14119,6 +16468,11 @@ function dateFromDateOrTimeSecondsNumber(input) {
|
|
|
14119
16468
|
*
|
|
14120
16469
|
* If the list is empty, returns false.
|
|
14121
16470
|
*
|
|
16471
|
+
* @dbxUtil
|
|
16472
|
+
* @dbxUtilCategory date
|
|
16473
|
+
* @dbxUtilTags expiration, valid, collection, any
|
|
16474
|
+
* @dbxUtilRelated expiration-details, check-any-have-expired
|
|
16475
|
+
*
|
|
14122
16476
|
* @param details - Collection of ExpirationDetails to check
|
|
14123
16477
|
* @returns True if at least one item has not expired, false otherwise
|
|
14124
16478
|
*/ function checkAtleastOneNotExpired(details) {
|
|
@@ -14133,6 +16487,11 @@ function dateFromDateOrTimeSecondsNumber(input) {
|
|
|
14133
16487
|
*
|
|
14134
16488
|
* If the list is empty, returns the value specified by defaultIfEmpty.
|
|
14135
16489
|
*
|
|
16490
|
+
* @dbxUtil
|
|
16491
|
+
* @dbxUtilCategory date
|
|
16492
|
+
* @dbxUtilTags expiration, refresh, collection, any
|
|
16493
|
+
* @dbxUtilRelated expiration-details, check-atleast-one-not-expired
|
|
16494
|
+
*
|
|
14136
16495
|
* @param details - Collection of ExpirationDetails to check
|
|
14137
16496
|
* @param defaultIfEmpty - Default value to return if the list is empty (defaults to true)
|
|
14138
16497
|
* @returns True if any item has expired, or the defaultIfEmpty value for an empty list
|
|
@@ -14603,6 +16962,11 @@ function _type_of$5(obj) {
|
|
|
14603
16962
|
/**
|
|
14604
16963
|
* Checks whether the input value is a native Promise by testing for a `.then` method.
|
|
14605
16964
|
*
|
|
16965
|
+
* @dbxUtil
|
|
16966
|
+
* @dbxUtilCategory promise
|
|
16967
|
+
* @dbxUtilTags promise, type-guard, async, then, check
|
|
16968
|
+
* @dbxUtilRelated is-promise-like, as-promise
|
|
16969
|
+
*
|
|
14606
16970
|
* @param obj - The value to test.
|
|
14607
16971
|
* @returns `true` if the value is a Promise, `false` otherwise.
|
|
14608
16972
|
*/ function isPromise(obj) {
|
|
@@ -14613,6 +16977,11 @@ function _type_of$5(obj) {
|
|
|
14613
16977
|
* Checks whether the input value is PromiseLike (i.e., has a `.then` method), which
|
|
14614
16978
|
* includes both native Promises and custom thenables.
|
|
14615
16979
|
*
|
|
16980
|
+
* @dbxUtil
|
|
16981
|
+
* @dbxUtilCategory promise
|
|
16982
|
+
* @dbxUtilTags promise, type-guard, async, then, thenable, check
|
|
16983
|
+
* @dbxUtilRelated is-promise, as-promise
|
|
16984
|
+
*
|
|
14616
16985
|
* @param obj - The value to test.
|
|
14617
16986
|
* @returns `true` if the value is PromiseLike, `false` otherwise.
|
|
14618
16987
|
*/ function isPromiseLike(obj) {
|
|
@@ -14766,6 +17135,11 @@ function waitForMs(ms, value) {
|
|
|
14766
17135
|
/**
|
|
14767
17136
|
* Polls at a regular interval until a condition is met or the maximum number of attempts is reached.
|
|
14768
17137
|
*
|
|
17138
|
+
* @dbxUtil
|
|
17139
|
+
* @dbxUtilCategory promise
|
|
17140
|
+
* @dbxUtilTags promise, poll, wait, retry, condition, async, interval
|
|
17141
|
+
* @dbxUtilRelated wait-for-ms, perform-task-loop
|
|
17142
|
+
*
|
|
14769
17143
|
* @param config - Polling configuration including check function, wait interval, and max attempts.
|
|
14770
17144
|
* @param config.check - predicate function that returns true when the polling condition has been satisfied
|
|
14771
17145
|
* @param config.wait - milliseconds to wait between polling iterations; defaults to 250
|
|
@@ -14882,6 +17256,10 @@ function _object_spread_props$3(target, source) {
|
|
|
14882
17256
|
/**
|
|
14883
17257
|
* Wraps the input in a resolved Promise if it is not already a Promise.
|
|
14884
17258
|
*
|
|
17259
|
+
* @dbxUtil
|
|
17260
|
+
* @dbxUtilCategory promise
|
|
17261
|
+
* @dbxUtilTags promise, async, normalize, resolve, ensure
|
|
17262
|
+
*
|
|
14885
17263
|
* @param input - A value or Promise to normalize into a Promise.
|
|
14886
17264
|
* @returns A Promise that resolves to the input value.
|
|
14887
17265
|
*/ function asPromise(input) {
|
|
@@ -15143,6 +17521,11 @@ function _ts_generator$4(thisArg, body) {
|
|
|
15143
17521
|
/**
|
|
15144
17522
|
* Runs a single async task and returns the resulting value. Always configured to throw on failure.
|
|
15145
17523
|
*
|
|
17524
|
+
* @dbxUtil
|
|
17525
|
+
* @dbxUtilCategory promise
|
|
17526
|
+
* @dbxUtilTags promise, async, task, retry, run, value
|
|
17527
|
+
* @dbxUtilRelated perform-async-task, run-async-tasks-for-values, perform-async-tasks
|
|
17528
|
+
*
|
|
15146
17529
|
* @param taskFn - The async task to execute.
|
|
15147
17530
|
* @param config - Optional configuration for retries and retry behavior.
|
|
15148
17531
|
* @returns The value produced by the task, or undefined if the task produced no value.
|
|
@@ -15173,6 +17556,11 @@ function _ts_generator$4(thisArg, body) {
|
|
|
15173
17556
|
* Runs an async task for each input value and returns an array of the resulting values.
|
|
15174
17557
|
* Always configured to throw on failure.
|
|
15175
17558
|
*
|
|
17559
|
+
* @dbxUtil
|
|
17560
|
+
* @dbxUtilCategory promise
|
|
17561
|
+
* @dbxUtilTags promise, async, tasks, parallel, batch, retry, run, values
|
|
17562
|
+
* @dbxUtilRelated perform-async-tasks, run-async-task-for-value
|
|
17563
|
+
*
|
|
15176
17564
|
* @param input - The array of input values to process.
|
|
15177
17565
|
* @param taskFn - The async task function to run for each input value.
|
|
15178
17566
|
* @param config - Optional configuration for parallelism and retries.
|
|
@@ -15206,6 +17594,11 @@ function _ts_generator$4(thisArg, body) {
|
|
|
15206
17594
|
* Performs async tasks for each input value with configurable retry and parallelism behavior.
|
|
15207
17595
|
* Useful for operations that may experience optimistic concurrency collisions.
|
|
15208
17596
|
*
|
|
17597
|
+
* @dbxUtil
|
|
17598
|
+
* @dbxUtilCategory promise
|
|
17599
|
+
* @dbxUtilTags async, promise, parallel, retry, task, batch, concurrency, throttle
|
|
17600
|
+
* @dbxUtilRelated perform-tasks-in-parallel, perform-async-task
|
|
17601
|
+
*
|
|
15209
17602
|
* @param input - The array of input values to process.
|
|
15210
17603
|
* @param taskFn - The async function to execute for each input.
|
|
15211
17604
|
* @param config - Configuration for retries, parallelism, and error handling.
|
|
@@ -15275,6 +17668,11 @@ function _ts_generator$4(thisArg, body) {
|
|
|
15275
17668
|
/**
|
|
15276
17669
|
* Performs a single async task with configurable retry behavior and returns the result with success status.
|
|
15277
17670
|
*
|
|
17671
|
+
* @dbxUtil
|
|
17672
|
+
* @dbxUtilCategory promise
|
|
17673
|
+
* @dbxUtilTags promise, async, task, retry, run, success
|
|
17674
|
+
* @dbxUtilRelated perform-async-tasks, run-async-task-for-value
|
|
17675
|
+
*
|
|
15278
17676
|
* @param taskFn - The async task to execute.
|
|
15279
17677
|
* @param config - Optional configuration for retries and error handling.
|
|
15280
17678
|
* @returns A result object containing the value (if successful) and a success flag.
|
|
@@ -17060,6 +19458,11 @@ function _unsupported_iterable_to_array$8(o, minLen) {
|
|
|
17060
19458
|
*
|
|
17061
19459
|
* Recursively compares arrays, objects, Maps, Sets, primitives, and Dates.
|
|
17062
19460
|
*
|
|
19461
|
+
* @dbxUtil
|
|
19462
|
+
* @dbxUtilCategory object
|
|
19463
|
+
* @dbxUtilTags object, equal, equality, deep, compare, recursive, pojo
|
|
19464
|
+
* @dbxUtilRelated are-equal-pojo-values-using-pojo-filter, all-objects-are-equal
|
|
19465
|
+
*
|
|
17063
19466
|
* @param a - First value to compare
|
|
17064
19467
|
* @param b - Second value to compare
|
|
17065
19468
|
* @returns `true` if the values are deeply equal
|
|
@@ -17381,6 +19784,10 @@ function _type_of$2(obj) {
|
|
|
17381
19784
|
* Empty nested objects are omitted from the result (they produce no keys).
|
|
17382
19785
|
* Circular references are detected and treated as leaf values to avoid infinite recursion.
|
|
17383
19786
|
*
|
|
19787
|
+
* @dbxUtil
|
|
19788
|
+
* @dbxUtilCategory object
|
|
19789
|
+
* @dbxUtilTags object, flatten, flat, nested, dot-notation, deep, traverse
|
|
19790
|
+
*
|
|
17384
19791
|
* @example
|
|
17385
19792
|
* ```ts
|
|
17386
19793
|
* flattenObject({ a: 1, b: { c: 2, d: { e: 3 } } });
|
|
@@ -18950,6 +21357,11 @@ function _unsupported_iterable_to_array$3(o, minLen) {
|
|
|
18950
21357
|
*
|
|
18951
21358
|
* Empty segments (e.g. leading underscores in `_USER_ID`) are skipped.
|
|
18952
21359
|
*
|
|
21360
|
+
* @dbxUtil
|
|
21361
|
+
* @dbxUtilCategory string
|
|
21362
|
+
* @dbxUtilTags string, case, camelcase, snakecase, screaming, convert, transform
|
|
21363
|
+
* @dbxUtilRelated camel-or-pascal-to-screaming-snake
|
|
21364
|
+
*
|
|
18953
21365
|
* @param input The SCREAMING_SNAKE_CASE input.
|
|
18954
21366
|
* @returns The camelCase form.
|
|
18955
21367
|
*/ function screamingSnakeToCamelCase(input) {
|
|
@@ -18990,6 +21402,11 @@ function _unsupported_iterable_to_array$3(o, minLen) {
|
|
|
18990
21402
|
* Each upper-case character (other than the first) is preceded by an
|
|
18991
21403
|
* underscore, then the whole result is upper-cased.
|
|
18992
21404
|
*
|
|
21405
|
+
* @dbxUtil
|
|
21406
|
+
* @dbxUtilCategory string
|
|
21407
|
+
* @dbxUtilTags string, case, camelcase, pascalcase, snakecase, screaming, convert, transform
|
|
21408
|
+
* @dbxUtilRelated screaming-snake-to-camel-case
|
|
21409
|
+
*
|
|
18993
21410
|
* @param input The camelCase / PascalCase input.
|
|
18994
21411
|
* @returns The SCREAMING_SNAKE_CASE form.
|
|
18995
21412
|
*/ function camelOrPascalToScreamingSnake(input) {
|
|
@@ -19676,6 +22093,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
19676
22093
|
* and optionally, how to construct the nodes themselves (`makeNode`). If `makeNode` is not provided, a default node structure is used.
|
|
19677
22094
|
* The returned function recursively builds a tree from a root value.
|
|
19678
22095
|
*
|
|
22096
|
+
* @dbxUtil
|
|
22097
|
+
* @dbxUtilCategory tree
|
|
22098
|
+
* @dbxUtilKind factory
|
|
22099
|
+
* @dbxUtilTags tree, expand, build, recursive, factory, hierarchy, traverse, children
|
|
22100
|
+
* @dbxUtilRelated expand-trees, expand-flatten-tree-function, explore-tree-function
|
|
22101
|
+
*
|
|
19679
22102
|
* @template T The type of the value being processed at each node.
|
|
19680
22103
|
* @template N The type of the TreeNode to be created. Defaults to TreeNode<T, any> if not specified by ExpandTreeWithNodeBuilder.
|
|
19681
22104
|
* @param config An ExpandTree<T> or ExpandTreeWithNodeBuilder<T, N> configuration object.
|
|
@@ -19709,6 +22132,11 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
19709
22132
|
* Convenience function for expanding multiple root values into an array of trees.
|
|
19710
22133
|
* Each value in the input array is treated as a root for a new tree.
|
|
19711
22134
|
*
|
|
22135
|
+
* @dbxUtil
|
|
22136
|
+
* @dbxUtilCategory tree
|
|
22137
|
+
* @dbxUtilTags tree, expand, multiple, roots, hierarchy, build, batch
|
|
22138
|
+
* @dbxUtilRelated expand-tree-function, expand-flatten-tree-function
|
|
22139
|
+
*
|
|
19712
22140
|
* @template T The type of the input values.
|
|
19713
22141
|
* @template N The type of the TreeNode in the resulting trees. Must extend TreeNode<T, N>.
|
|
19714
22142
|
* @param values An array of root values of type T to expand.
|
|
@@ -19720,6 +22148,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
19720
22148
|
|
|
19721
22149
|
/**
|
|
19722
22150
|
* Decides how to visit a node during tree exploration.
|
|
22151
|
+
*
|
|
22152
|
+
* @dbxUtil
|
|
22153
|
+
* @dbxUtilCategory tree
|
|
22154
|
+
* @dbxUtilKind const
|
|
22155
|
+
* @dbxUtilTags tree, explore, visit, decision, enum, traversal, control
|
|
22156
|
+
* @dbxUtilRelated explore-tree-function, flatten-tree-add-node-decision
|
|
19723
22157
|
*/ var ExploreTreeVisitNodeDecision = {
|
|
19724
22158
|
/**
|
|
19725
22159
|
* Visits all nodes and children
|
|
@@ -19741,6 +22175,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
19741
22175
|
* By default uses depth-first traversal, identity mapping, and visits all nodes. All options
|
|
19742
22176
|
* can be overridden per-call.
|
|
19743
22177
|
*
|
|
22178
|
+
* @dbxUtil
|
|
22179
|
+
* @dbxUtilCategory tree
|
|
22180
|
+
* @dbxUtilKind factory
|
|
22181
|
+
* @dbxUtilTags tree, explore, traverse, visit, factory, depth-first, breadth-first, walk
|
|
22182
|
+
* @dbxUtilRelated depth-first-explore-tree-traversal-factory-function, breadth-first-explore-tree-traversal-factory-function, flatten-tree-to-array-function
|
|
22183
|
+
*
|
|
19744
22184
|
* @param config - Optional default configuration for mapping, filtering, and traversal strategy.
|
|
19745
22185
|
* @returns A reusable function that explores trees with the configured behavior.
|
|
19746
22186
|
*
|
|
@@ -19790,6 +22230,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
19790
22230
|
* Visits each node before its children (pre-order). This is the default traversal
|
|
19791
22231
|
* strategy used by {@link exploreTreeFunction}.
|
|
19792
22232
|
*
|
|
22233
|
+
* @dbxUtil
|
|
22234
|
+
* @dbxUtilCategory tree
|
|
22235
|
+
* @dbxUtilKind factory
|
|
22236
|
+
* @dbxUtilTags tree, traverse, depth-first, dfs, pre-order, factory, strategy
|
|
22237
|
+
* @dbxUtilRelated breadth-first-explore-tree-traversal-factory-function, explore-tree-function
|
|
22238
|
+
*
|
|
19793
22239
|
* @returns A traversal factory that processes nodes in depth-first order.
|
|
19794
22240
|
*
|
|
19795
22241
|
* @example
|
|
@@ -19822,6 +22268,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
19822
22268
|
* Visits nodes level by level, processing all nodes at depth N before moving to depth N+1.
|
|
19823
22269
|
* Uses an internal queue to defer child processing until the current level is complete.
|
|
19824
22270
|
*
|
|
22271
|
+
* @dbxUtil
|
|
22272
|
+
* @dbxUtilCategory tree
|
|
22273
|
+
* @dbxUtilKind factory
|
|
22274
|
+
* @dbxUtilTags tree, traverse, breadth-first, bfs, level-order, factory, strategy, queue
|
|
22275
|
+
* @dbxUtilRelated depth-first-explore-tree-traversal-factory-function, explore-tree-function
|
|
22276
|
+
*
|
|
19825
22277
|
* @returns A traversal factory that processes nodes in breadth-first order.
|
|
19826
22278
|
*
|
|
19827
22279
|
* @example
|
|
@@ -19915,6 +22367,12 @@ function _object_spread_props(target, source) {
|
|
|
19915
22367
|
}
|
|
19916
22368
|
/**
|
|
19917
22369
|
* Decides how to add a node to the flattened array during flattening.
|
|
22370
|
+
*
|
|
22371
|
+
* @dbxUtil
|
|
22372
|
+
* @dbxUtilCategory tree
|
|
22373
|
+
* @dbxUtilKind const
|
|
22374
|
+
* @dbxUtilTags tree, flatten, decision, enum, traversal, control
|
|
22375
|
+
* @dbxUtilRelated explore-tree-visit-node-decision, flatten-tree
|
|
19918
22376
|
*/ var FlattenTreeAddNodeDecision = {
|
|
19919
22377
|
/**
|
|
19920
22378
|
* Add all nodes and children
|
|
@@ -19932,6 +22390,11 @@ function _object_spread_props(target, source) {
|
|
|
19932
22390
|
/**
|
|
19933
22391
|
* Flattens a tree into an array containing all its nodes using depth-first traversal.
|
|
19934
22392
|
*
|
|
22393
|
+
* @dbxUtil
|
|
22394
|
+
* @dbxUtilCategory tree
|
|
22395
|
+
* @dbxUtilTags tree, flatten, traverse, depth-first, collect, nodes, array
|
|
22396
|
+
* @dbxUtilRelated flatten-tree-to-array, flatten-tree-to-array-function, explore-tree-function
|
|
22397
|
+
*
|
|
19935
22398
|
* @param tree - The root node to flatten.
|
|
19936
22399
|
* @param addNodeFn - Optional filter controlling which nodes and subtrees are included.
|
|
19937
22400
|
* @returns An array of all nodes in the tree that pass the filter.
|
|
@@ -19949,6 +22412,11 @@ function _object_spread_props(target, source) {
|
|
|
19949
22412
|
*
|
|
19950
22413
|
* Useful for accumulating nodes from multiple trees into a single collection.
|
|
19951
22414
|
*
|
|
22415
|
+
* @dbxUtil
|
|
22416
|
+
* @dbxUtilCategory tree
|
|
22417
|
+
* @dbxUtilTags tree, flatten, append, accumulate, collect, mutate, array
|
|
22418
|
+
* @dbxUtilRelated flatten-tree, flatten-tree-to-array-function
|
|
22419
|
+
*
|
|
19952
22420
|
* @param tree - The root node to flatten.
|
|
19953
22421
|
* @param array - The target array to push flattened nodes into.
|
|
19954
22422
|
* @param addNodeFn - Optional filter controlling which nodes and subtrees are included.
|
|
@@ -19969,6 +22437,12 @@ function _object_spread_props(target, source) {
|
|
|
19969
22437
|
* Creates a reusable function that traverses trees and collects either the nodes themselves
|
|
19970
22438
|
* or mapped values into an array. Supports both a simple function signature and a config object.
|
|
19971
22439
|
*
|
|
22440
|
+
* @dbxUtil
|
|
22441
|
+
* @dbxUtilCategory tree
|
|
22442
|
+
* @dbxUtilKind factory
|
|
22443
|
+
* @dbxUtilTags tree, flatten, factory, collect, map, traverse, reusable
|
|
22444
|
+
* @dbxUtilRelated flatten-tree, flatten-tree-to-array, expand-flatten-tree-function
|
|
22445
|
+
*
|
|
19972
22446
|
* @param mapNodeFnOrConfig - Optional mapping function or config object.
|
|
19973
22447
|
* @param defaultAddNodeFn - Optional default filter for node inclusion.
|
|
19974
22448
|
* @returns A reusable flattening function.
|
|
@@ -20007,6 +22481,12 @@ function _object_spread_props(target, source) {
|
|
|
20007
22481
|
* This higher-order function takes a function to expand an array of values `T` into a list of trees (`N[]` where `N` is a TreeNode)
|
|
20008
22482
|
* and another function to flatten these trees into a single array of values `V`.
|
|
20009
22483
|
*
|
|
22484
|
+
* @dbxUtil
|
|
22485
|
+
* @dbxUtilCategory tree
|
|
22486
|
+
* @dbxUtilKind factory
|
|
22487
|
+
* @dbxUtilTags tree, expand, flatten, compose, factory, transform
|
|
22488
|
+
* @dbxUtilRelated expand-tree-function, flatten-tree-to-array-function, expand-trees
|
|
22489
|
+
*
|
|
20010
22490
|
* @template T The type of the initial input values.
|
|
20011
22491
|
* @template V The type of the values in the final flattened output array.
|
|
20012
22492
|
* @template N The type of the intermediate tree nodes. Must extend TreeNode with value T and children of type N.
|
|
@@ -20031,6 +22511,11 @@ function invertMaybeBoolean(x) {
|
|
|
20031
22511
|
* @returns The result of ANDing all boolean values in the array.
|
|
20032
22512
|
* @throws {TypeError} If the array is empty and no emptyArrayValue is provided.
|
|
20033
22513
|
*
|
|
22514
|
+
* @dbxUtil
|
|
22515
|
+
* @dbxUtilCategory boolean
|
|
22516
|
+
* @dbxUtilTags boolean, reduce, and, every, all, conjunction, aggregate
|
|
22517
|
+
* @dbxUtilRelated reduce-booleans-with-or, reduce-booleans-with-and-fn
|
|
22518
|
+
*
|
|
20034
22519
|
* @example
|
|
20035
22520
|
* ```ts
|
|
20036
22521
|
* reduceBooleansWithAnd([true, true, true]); // true
|
|
@@ -20043,6 +22528,11 @@ function invertMaybeBoolean(x) {
|
|
|
20043
22528
|
/**
|
|
20044
22529
|
* Reduces an array of booleans with the logical OR operation.
|
|
20045
22530
|
*
|
|
22531
|
+
* @dbxUtil
|
|
22532
|
+
* @dbxUtilCategory boolean
|
|
22533
|
+
* @dbxUtilTags boolean, reduce, or, some, any, disjunction, aggregate
|
|
22534
|
+
* @dbxUtilRelated reduce-booleans-with-and, reduce-booleans-with-or-fn
|
|
22535
|
+
*
|
|
20046
22536
|
* @param array - Array of boolean values to reduce.
|
|
20047
22537
|
* @param emptyArrayValue - Value to return if the array is empty. If not provided and the array is empty, a TypeError will be thrown.
|
|
20048
22538
|
* @returns The result of ORing all boolean values in the array.
|
|
@@ -20115,6 +22605,12 @@ function invertMaybeBoolean(x) {
|
|
|
20115
22605
|
* @param config - Configuration for the boolean factory, including the chance of returning true.
|
|
20116
22606
|
* @returns A factory function (`BooleanFactory`) that generates random boolean values based on the configured chance.
|
|
20117
22607
|
*
|
|
22608
|
+
* @dbxUtil
|
|
22609
|
+
* @dbxUtilCategory boolean
|
|
22610
|
+
* @dbxUtilKind factory
|
|
22611
|
+
* @dbxUtilTags boolean, factory, random, chance, probability, generate
|
|
22612
|
+
* @dbxUtilRelated random-boolean
|
|
22613
|
+
*
|
|
20118
22614
|
* @example
|
|
20119
22615
|
* ```ts
|
|
20120
22616
|
* const alwaysTrue = booleanFactory({ chance: 100 });
|
|
@@ -20134,6 +22630,11 @@ function invertMaybeBoolean(x) {
|
|
|
20134
22630
|
/**
|
|
20135
22631
|
* Returns a random boolean based on the specified chance.
|
|
20136
22632
|
*
|
|
22633
|
+
* @dbxUtil
|
|
22634
|
+
* @dbxUtilCategory boolean
|
|
22635
|
+
* @dbxUtilTags boolean, random, chance, probability, coin-flip
|
|
22636
|
+
* @dbxUtilRelated boolean-factory
|
|
22637
|
+
*
|
|
20137
22638
|
* @param chance - Number between 0.0 and 100.0 representing the percentage chance of returning true (default: 50, i.e., 50%).
|
|
20138
22639
|
* @returns A random boolean value with the specified probability of being true.
|
|
20139
22640
|
*/ function randomBoolean() {
|
|
@@ -20268,6 +22769,11 @@ function _define_property$1(obj, key, value) {
|
|
|
20268
22769
|
* @param hashFn - A function that takes a string and returns its hashed representation.
|
|
20269
22770
|
* @returns An array of decoded strings. Values that cannot be decoded are filtered out.
|
|
20270
22771
|
*
|
|
22772
|
+
* @dbxUtil
|
|
22773
|
+
* @dbxUtilCategory hash
|
|
22774
|
+
* @dbxUtilTags hash, decode, lookup, reverse, salt
|
|
22775
|
+
* @dbxUtilRelated make-hash-decode-map, decode-hashed-values-with-decode-map
|
|
22776
|
+
*
|
|
20271
22777
|
* @example
|
|
20272
22778
|
* ```ts
|
|
20273
22779
|
* const hashed = [hashFn('apple'), hashFn('banana')];
|
|
@@ -20282,6 +22788,11 @@ function _define_property$1(obj, key, value) {
|
|
|
20282
22788
|
* Creates a `HashDecodeMap` from a list of potential original string values and a hash function.
|
|
20283
22789
|
* The map's keys are the hashed versions of the `decodeValues`, and the values are the original `decodeValues`.
|
|
20284
22790
|
*
|
|
22791
|
+
* @dbxUtil
|
|
22792
|
+
* @dbxUtilCategory hash
|
|
22793
|
+
* @dbxUtilTags hash, decode, map, lookup, reverse, factory
|
|
22794
|
+
* @dbxUtilRelated decode-hashed-values, decode-hashed-values-with-decode-map
|
|
22795
|
+
*
|
|
20285
22796
|
* @param decodeValues - An array of potential original string values.
|
|
20286
22797
|
* @param hashFn - A function that takes a string and returns its hashed representation.
|
|
20287
22798
|
* @returns A {@link HashDecodeMap} for decoding hashed values.
|
|
@@ -20442,6 +22953,11 @@ function _ts_generator$1(thisArg, body) {
|
|
|
20442
22953
|
* @param values - Array of values to iterate over.
|
|
20443
22954
|
* @param useFn - Callback invoked for each value.
|
|
20444
22955
|
*
|
|
22956
|
+
* @dbxUtil
|
|
22957
|
+
* @dbxUtilCategory iterate
|
|
22958
|
+
* @dbxUtilTags iterate, async, sequential, each, await, for-each
|
|
22959
|
+
* @dbxUtilRelated perform-async-tasks
|
|
22960
|
+
*
|
|
20445
22961
|
* @example
|
|
20446
22962
|
* ```ts
|
|
20447
22963
|
* await iterate([1, 2, 3], async (value) => {
|
|
@@ -21054,6 +23570,7 @@ exports.NOOP_MODIFIER = NOOP_MODIFIER;
|
|
|
21054
23570
|
exports.NUMBER_STRING_DENCODER_64 = NUMBER_STRING_DENCODER_64;
|
|
21055
23571
|
exports.NUMBER_STRING_DENCODER_64_DEFAULT_NEGATIVE_PREFIX = NUMBER_STRING_DENCODER_64_DEFAULT_NEGATIVE_PREFIX;
|
|
21056
23572
|
exports.NUMBER_STRING_DENCODER_64_DIGITS = NUMBER_STRING_DENCODER_64_DIGITS;
|
|
23573
|
+
exports.OAUTH_OOB_REDIRECT_URI = OAUTH_OOB_REDIRECT_URI;
|
|
21057
23574
|
exports.PDF_ENCRYPT_MARKER = PDF_ENCRYPT_MARKER;
|
|
21058
23575
|
exports.PDF_EOF_MARKER = PDF_EOF_MARKER;
|
|
21059
23576
|
exports.PDF_HEADER = PDF_HEADER;
|
|
@@ -21366,6 +23883,8 @@ exports.forEachWithArray = forEachWithArray;
|
|
|
21366
23883
|
exports.forwardFunction = forwardFunction;
|
|
21367
23884
|
exports.fractionalHoursToMinutes = fractionalHoursToMinutes;
|
|
21368
23885
|
exports.generateIfDoesNotExist = generateIfDoesNotExist;
|
|
23886
|
+
exports.generatePkceCodeChallenge = generatePkceCodeChallenge;
|
|
23887
|
+
exports.generatePkceCodeVerifier = generatePkceCodeVerifier;
|
|
21369
23888
|
exports.getArrayNextIndex = getArrayNextIndex;
|
|
21370
23889
|
exports.getBaseLog = getBaseLog;
|
|
21371
23890
|
exports.getDayOffset = getDayOffset;
|
|
@@ -21404,6 +23923,8 @@ exports.hoursAndMinutesToString = hoursAndMinutesToString;
|
|
|
21404
23923
|
exports.hoursAndMinutesToTimeUnit = hoursAndMinutesToTimeUnit;
|
|
21405
23924
|
exports.idBatchFactory = idBatchFactory;
|
|
21406
23925
|
exports.imageFileExtensionForMimeType = imageFileExtensionForMimeType;
|
|
23926
|
+
exports.inMemoryAsyncKeyedValueCache = inMemoryAsyncKeyedValueCache;
|
|
23927
|
+
exports.inMemoryAsyncValueCache = inMemoryAsyncValueCache;
|
|
21407
23928
|
exports.incrementingNumberFactory = incrementingNumberFactory;
|
|
21408
23929
|
exports.indexDeltaGroup = indexDeltaGroup;
|
|
21409
23930
|
exports.indexDeltaGroupFunction = indexDeltaGroupFunction;
|
|
@@ -21439,6 +23960,7 @@ exports.isEqualContext = isEqualContext;
|
|
|
21439
23960
|
exports.isEqualDate = isEqualDate;
|
|
21440
23961
|
exports.isEqualToValueDecisionFunction = isEqualToValueDecisionFunction;
|
|
21441
23962
|
exports.isEvenNumber = isEvenNumber;
|
|
23963
|
+
exports.isExpired = isExpired;
|
|
21442
23964
|
exports.isFalseBooleanKeyArray = isFalseBooleanKeyArray;
|
|
21443
23965
|
exports.isFinalPage = isFinalPage;
|
|
21444
23966
|
exports.isGetter = isGetter;
|
|
@@ -21601,8 +24123,12 @@ exports.maybeMergeModelModifiers = maybeMergeModelModifiers;
|
|
|
21601
24123
|
exports.maybeMergeModifiers = maybeMergeModifiers;
|
|
21602
24124
|
exports.maybeModifierMapToFunction = maybeModifierMapToFunction;
|
|
21603
24125
|
exports.maybeSet = maybeSet;
|
|
24126
|
+
exports.memoizeAsyncKeyedValueCache = memoizeAsyncKeyedValueCache;
|
|
24127
|
+
exports.memoizeAsyncValueCache = memoizeAsyncValueCache;
|
|
21604
24128
|
exports.mergeArrays = mergeArrays;
|
|
21605
24129
|
exports.mergeArraysIntoArray = mergeArraysIntoArray;
|
|
24130
|
+
exports.mergeAsyncKeyedValueCaches = mergeAsyncKeyedValueCaches;
|
|
24131
|
+
exports.mergeAsyncValueCaches = mergeAsyncValueCaches;
|
|
21606
24132
|
exports.mergeFilterFunctions = mergeFilterFunctions;
|
|
21607
24133
|
exports.mergeModifiers = mergeModifiers;
|
|
21608
24134
|
exports.mergeObjects = mergeObjects;
|
|
@@ -21639,6 +24165,7 @@ exports.multiKeyValueMapFactory = multiKeyValueMapFactory;
|
|
|
21639
24165
|
exports.multiValueMapBuilder = multiValueMapBuilder;
|
|
21640
24166
|
exports.neMostLatLngPoint = neMostLatLngPoint;
|
|
21641
24167
|
exports.nearestDivisibleValues = nearestDivisibleValues;
|
|
24168
|
+
exports.noop = noop;
|
|
21642
24169
|
exports.numberStringDencoder = numberStringDencoder;
|
|
21643
24170
|
exports.numberStringDencoderDecodedNumberValueFunction = numberStringDencoderDecodedNumberValueFunction;
|
|
21644
24171
|
exports.numberStringDencoderEncodedStringValueFunction = numberStringDencoderEncodedStringValueFunction;
|