@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.
Files changed (64) hide show
  1. package/fetch/package.json +2 -2
  2. package/index.cjs.js +2578 -51
  3. package/index.esm.js +2568 -52
  4. package/package.json +1 -1
  5. package/src/lib/array/array.d.ts +79 -0
  6. package/src/lib/array/array.factory.d.ts +12 -0
  7. package/src/lib/array/array.find.d.ts +11 -0
  8. package/src/lib/array/array.limit.d.ts +5 -0
  9. package/src/lib/array/array.random.d.ts +16 -0
  10. package/src/lib/array/array.set.d.ts +20 -0
  11. package/src/lib/array/array.unique.d.ts +38 -0
  12. package/src/lib/array/array.value.d.ts +10 -0
  13. package/src/lib/auth/index.d.ts +2 -0
  14. package/src/lib/auth/oauth.d.ts +12 -0
  15. package/src/lib/auth/pkce.d.ts +13 -0
  16. package/src/lib/boolean.d.ts +36 -0
  17. package/src/lib/cache/cache.d.ts +48 -0
  18. package/src/lib/cache/cache.memoize.d.ts +59 -0
  19. package/src/lib/cache/cache.memory.d.ts +39 -0
  20. package/src/lib/cache/cache.merge.d.ts +48 -0
  21. package/src/lib/cache/index.d.ts +4 -0
  22. package/src/lib/contact/domain.d.ts +15 -0
  23. package/src/lib/contact/email.d.ts +15 -0
  24. package/src/lib/date/date.unix.d.ts +20 -0
  25. package/src/lib/date/expires.d.ts +85 -16
  26. package/src/lib/function/function.d.ts +5 -0
  27. package/src/lib/getter/getter.d.ts +21 -0
  28. package/src/lib/grouping.d.ts +30 -0
  29. package/src/lib/hash.d.ts +10 -0
  30. package/src/lib/index.d.ts +1 -0
  31. package/src/lib/iterable/iterable.d.ts +20 -0
  32. package/src/lib/iterate.d.ts +5 -0
  33. package/src/lib/number/bound.d.ts +23 -0
  34. package/src/lib/number/number.d.ts +47 -0
  35. package/src/lib/number/random.d.ts +11 -0
  36. package/src/lib/number/round.d.ts +16 -0
  37. package/src/lib/object/object.d.ts +24 -0
  38. package/src/lib/object/object.empty.d.ts +5 -0
  39. package/src/lib/object/object.equal.d.ts +5 -0
  40. package/src/lib/object/object.filter.pojo.d.ts +31 -1
  41. package/src/lib/object/object.flatten.d.ts +4 -0
  42. package/src/lib/path/path.d.ts +191 -0
  43. package/src/lib/promise/is.d.ts +10 -0
  44. package/src/lib/promise/poll.d.ts +5 -0
  45. package/src/lib/promise/promise.d.ts +20 -0
  46. package/src/lib/promise/promise.type.d.ts +4 -0
  47. package/src/lib/promise/wait.d.ts +5 -0
  48. package/src/lib/set/set.d.ts +15 -0
  49. package/src/lib/sort.d.ts +16 -0
  50. package/src/lib/string/case.d.ts +10 -0
  51. package/src/lib/string/string.d.ts +54 -0
  52. package/src/lib/tree/tree.array.d.ts +6 -0
  53. package/src/lib/tree/tree.expand.d.ts +5 -0
  54. package/src/lib/tree/tree.explore.d.ts +24 -0
  55. package/src/lib/tree/tree.flatten.d.ts +16 -0
  56. package/src/lib/type.d.ts +20 -0
  57. package/src/lib/value/build.d.ts +4 -0
  58. package/src/lib/value/comparator.d.ts +11 -0
  59. package/src/lib/value/decision.d.ts +17 -0
  60. package/src/lib/value/equal.d.ts +17 -0
  61. package/src/lib/value/map.d.ts +23 -0
  62. package/src/lib/value/maybe.d.ts +49 -0
  63. package/src/lib/value/modifier.d.ts +5 -0
  64. package/test/package.json +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "13.10.9",
3
+ "version": "13.11.0",
4
4
  "sideEffects": false,
5
5
  "exports": {
6
6
  "./test": {
@@ -11,6 +11,11 @@ export type ArrayOrValue<T> = T | T[];
11
11
  /**
12
12
  * 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.
13
13
  *
14
+ * @dbxUtil
15
+ * @dbxUtilCategory array
16
+ * @dbxUtilTags array, non-empty, convert, ensure, normalize
17
+ * @dbxUtilRelated convert-maybe-to-array, convert-to-array
18
+ *
14
19
  * @param arrayOrValue - single value or array to convert
15
20
  * @returns an array with at least one element, or undefined if the result would be empty
16
21
  */
@@ -18,6 +23,11 @@ export declare function convertMaybeToNonEmptyArray<T>(arrayOrValue: Maybe<Array
18
23
  /**
19
24
  * 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.
20
25
  *
26
+ * @dbxUtil
27
+ * @dbxUtilCategory array
28
+ * @dbxUtilTags array, convert, ensure, normalize, maybe, nullish
29
+ * @dbxUtilRelated convert-maybe-to-non-empty-array, convert-to-array, as-array
30
+ *
21
31
  * @param arrayOrValue - single value, array, or nullish value to convert
22
32
  * @returns the input wrapped in an array, the input array itself, or an empty array if nullish
23
33
  */
@@ -33,6 +43,11 @@ export declare const asNonEmptyArray: typeof convertMaybeToNonEmptyArray;
33
43
  /**
34
44
  * Converts the input value to an array containing itself, or returns itself if it is already an array.
35
45
  *
46
+ * @dbxUtil
47
+ * @dbxUtilCategory array
48
+ * @dbxUtilTags array, convert, ensure, wrap, normalize
49
+ * @dbxUtilRelated convert-maybe-to-array, convert-maybe-to-non-empty-array
50
+ *
36
51
  * @param arrayOrValue - single value or array to convert
37
52
  * @returns the input array unchanged, or a new single-element array wrapping the input value
38
53
  */
@@ -40,6 +55,11 @@ export declare function convertToArray<T>(arrayOrValue: ArrayOrValue<T>): T[];
40
55
  /**
41
56
  * Returns the first value from the array, or the value itself if not an array.
42
57
  *
58
+ * @dbxUtil
59
+ * @dbxUtilCategory array
60
+ * @dbxUtilTags array, first, head, get, value
61
+ * @dbxUtilRelated last-value, value-at-index, first-and-last-value
62
+ *
43
63
  * @param input - single value or array to retrieve from
44
64
  * @returns the first element of the array, or the input value itself
45
65
  */
@@ -47,6 +67,11 @@ export declare function firstValue<T>(input: ArrayOrValue<T>): T;
47
67
  /**
48
68
  * Returns the last value from the array, or the value itself if not an array.
49
69
  *
70
+ * @dbxUtil
71
+ * @dbxUtilCategory array
72
+ * @dbxUtilTags array, last, tail, get, value
73
+ * @dbxUtilRelated first-value, value-at-index, first-and-last-value
74
+ *
50
75
  * @param input - single value or array to retrieve from
51
76
  * @returns the last element of the array, or the input value itself
52
77
  */
@@ -56,6 +81,11 @@ export declare function lastValue<T>(input: ArrayOrValue<T>): T;
56
81
  *
57
82
  * If the input is not an array, returns that value as both the first and last value.
58
83
  *
84
+ * @dbxUtil
85
+ * @dbxUtilCategory array
86
+ * @dbxUtilTags array, first, last, head, tail, tuple, endpoints
87
+ * @dbxUtilRelated first-value, last-value, value-at-index
88
+ *
59
89
  * @param input - single value or array to retrieve from
60
90
  * @returns a two-element tuple of the first and last values
61
91
  */
@@ -63,6 +93,11 @@ export declare function firstAndLastValue<T>(input: ArrayOrValue<T>): [T, T];
63
93
  /**
64
94
  * Returns the value at the given index from an array, or the value itself if not an array.
65
95
  *
96
+ * @dbxUtil
97
+ * @dbxUtilCategory array
98
+ * @dbxUtilTags array, index, get, value, at
99
+ * @dbxUtilRelated first-value, last-value, first-and-last-value
100
+ *
66
101
  * @param input - single value or array to retrieve from
67
102
  * @param index - zero-based index of the element to retrieve
68
103
  * @returns the element at the specified index, or the input value itself if not an array
@@ -71,6 +106,11 @@ export declare function valueAtIndex<T>(input: ArrayOrValue<T>, index: number):
71
106
  /**
72
107
  * Concatenates the input arrays into a single array, filtering out nullish entries.
73
108
  *
109
+ * @dbxUtil
110
+ * @dbxUtilCategory array
111
+ * @dbxUtilTags array, concat, concatenate, combine, flatten, merge
112
+ * @dbxUtilRelated flatten-array, merge-arrays
113
+ *
74
114
  * @param arrays - arrays to concatenate; nullish entries are ignored
75
115
  * @returns a single flattened array containing all elements from the non-nullish input arrays
76
116
  */
@@ -78,6 +118,11 @@ export declare function concatArrays<T>(...arrays: Maybe<T[]>[]): T[];
78
118
  /**
79
119
  * Flattens a two-dimensional array into a single-dimensional array. Any null/undefined entries in the outer dimension are filtered out.
80
120
  *
121
+ * @dbxUtil
122
+ * @dbxUtilCategory array
123
+ * @dbxUtilTags array, flatten, flat, nested, two-dimensional, concat
124
+ * @dbxUtilRelated concat-arrays, flatten-array-or-value-array, merge-arrays
125
+ *
81
126
  * @param array - two-dimensional array to flatten, may contain nullish entries
82
127
  * @returns a single-dimensional array with all elements from the non-nullish inner arrays
83
128
  */
@@ -92,6 +137,11 @@ export declare function flattenArrayOrValueArray<T>(array: ArrayOrValue<Maybe<T>
92
137
  /**
93
138
  * Creates a shallow copy of the input array. Returns an empty array if the input is nullish.
94
139
  *
140
+ * @dbxUtil
141
+ * @dbxUtilCategory array
142
+ * @dbxUtilTags array, copy, clone, shallow, duplicate
143
+ * @dbxUtilRelated convert-maybe-to-array
144
+ *
95
145
  * @param input - array to copy, or nullish
96
146
  * @returns a new array with the same elements, or an empty array if input is nullish
97
147
  */
@@ -108,6 +158,11 @@ export declare function pushElementOntoArray<T>(target: T[], element: T, times:
108
158
  /**
109
159
  * Merges all input arrays into a single new array. Nullish entries are ignored.
110
160
  *
161
+ * @dbxUtil
162
+ * @dbxUtilCategory array
163
+ * @dbxUtilTags array, merge, concat, flatten, combine
164
+ * @dbxUtilRelated merge-arrays-into-array
165
+ *
111
166
  * @param arrays - arrays to merge; nullish entries are skipped
112
167
  * @returns a new array containing all elements from the provided arrays
113
168
  */
@@ -141,6 +196,11 @@ export declare function pushArrayItemsIntoArray<T>(target: T[], array: T[]): T[]
141
196
  /**
142
197
  * Copies/takes the elements from the front of the array up to the specified maximum.
143
198
  *
199
+ * @dbxUtil
200
+ * @dbxUtilCategory array
201
+ * @dbxUtilTags array, take, front, head, slice, limit
202
+ * @dbxUtilRelated take-last, split-front
203
+ *
144
204
  * @param values - source array to take from
145
205
  * @param maxToTake - maximum number of elements to take from the front
146
206
  * @returns a new array containing at most maxToTake elements from the front
@@ -166,6 +226,11 @@ export interface SplitFrontResult<T> {
166
226
  /**
167
227
  * 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.
168
228
  *
229
+ * @dbxUtil
230
+ * @dbxUtilCategory array
231
+ * @dbxUtilTags array, split, partition, front, slice
232
+ * @dbxUtilRelated take-front, take-last
233
+ *
169
234
  * @param values The array to split.
170
235
  * @param maxToTake The maximum number of values to take from the front of the array.
171
236
  * @returns The front and remaining values.
@@ -174,6 +239,11 @@ export declare function splitFront<T>(values: T[], maxToTake: number): SplitFron
174
239
  /**
175
240
  * Copies/takes as many elements as possible from the end.
176
241
  *
242
+ * @dbxUtil
243
+ * @dbxUtilCategory array
244
+ * @dbxUtilTags array, take, last, tail, end, slice, limit
245
+ * @dbxUtilRelated take-front, split-front
246
+ *
177
247
  * @param values Values to take from.
178
248
  * @param maxToTake Max number of values to take from the end of the input array.
179
249
  * @param keepFromFront Number of values to retain in the front of the array. These are not taken.
@@ -191,6 +261,11 @@ export declare function forEachWithArray<T>(array: Maybe<ArrayOrValue<T>>, forEa
191
261
  /**
192
262
  * Counts the total number of elements across all inner arrays of a nested array.
193
263
  *
264
+ * @dbxUtil
265
+ * @dbxUtilCategory array
266
+ * @dbxUtilTags array, count, nested, total, length, two-dimensional
267
+ * @dbxUtilRelated flatten-array
268
+ *
194
269
  * @param array - two-dimensional array whose elements are counted
195
270
  * @returns the total number of elements across all inner arrays
196
271
  */
@@ -198,6 +273,10 @@ export declare function countAllInNestedArray<T>(array: T[][]): number;
198
273
  /**
199
274
  * Creates a copy of the array with the items at the specified indexes removed.
200
275
  *
276
+ * @dbxUtil
277
+ * @dbxUtilCategory array
278
+ * @dbxUtilTags array, remove, exclude, indexes, filter, copy
279
+ *
201
280
  * @param array - source array to copy from
202
281
  * @param removeIndexes - indexes of elements to exclude from the copy
203
282
  * @returns a new array without the elements at the specified indexes
@@ -21,6 +21,12 @@ export type AsyncArrayInputFactory<I, O> = AsyncMapFunction<ArrayInputFactory<I,
21
21
  /**
22
22
  * Creates a new ArrayFactory that generates multiple values.
23
23
  *
24
+ * @dbxUtil
25
+ * @dbxUtilCategory array
26
+ * @dbxUtilKind factory
27
+ * @dbxUtilTags array, factory, generate, make, build, create
28
+ * @dbxUtilRelated array-input-factory, terminating-factory-from-array
29
+ *
24
30
  * @param factory - The factory function used to generate each item
25
31
  * @returns A function that takes a count parameter and returns an array of generated items
26
32
  */
@@ -28,6 +34,12 @@ export declare function arrayFactory<T>(factory: Factory<T> | FactoryWithIndex<T
28
34
  /**
29
35
  * Creates an ArrayInputFactory that transforms input values into output values.
30
36
  *
37
+ * @dbxUtil
38
+ * @dbxUtilCategory array
39
+ * @dbxUtilKind factory
40
+ * @dbxUtilTags array, factory, transform, map, generate, build
41
+ * @dbxUtilRelated array-factory
42
+ *
31
43
  * @param factory - The factory function used to transform each input value
32
44
  * @returns A function that takes an array of input values and returns an array of output values
33
45
  */
@@ -13,6 +13,12 @@ export type ArrayDecisionFunction<T> = (values: T[]) => boolean;
13
13
  * When mode is `'any'`, the resulting function returns `true` if at least one element satisfies the predicate.
14
14
  * When mode is `'all'`, it returns `true` only if every element satisfies the predicate.
15
15
  *
16
+ * @dbxUtil
17
+ * @dbxUtilCategory array
18
+ * @dbxUtilKind factory
19
+ * @dbxUtilTags array, decision, predicate, find, every, some, all, any, factory
20
+ * @dbxUtilRelated array-decision
21
+ *
16
22
  * @param decision - Predicate used to test individual elements.
17
23
  * @param mode - Whether all or any elements must satisfy the predicate.
18
24
  * @returns A function that evaluates an array against the configured decision criteria.
@@ -21,6 +27,11 @@ export declare function arrayDecisionFunction<T>(decision: ArrayFindDecisionFunc
21
27
  /**
22
28
  * Convenience wrapper that creates and immediately invokes an {@link ArrayDecisionFunction}.
23
29
  *
30
+ * @dbxUtil
31
+ * @dbxUtilCategory array
32
+ * @dbxUtilTags array, decision, predicate, find, every, some, all, any
33
+ * @dbxUtilRelated array-decision-function
34
+ *
24
35
  * @param values - Array to evaluate.
25
36
  * @param decision - Predicate used to test individual elements.
26
37
  * @param mode - Whether all or any elements must satisfy the predicate.
@@ -16,6 +16,11 @@ export interface LimitArrayConfig {
16
16
  * Limits the number of items in an array based on the provided configuration.
17
17
  * Items are taken from the front of the array by default, or from the end if configured.
18
18
  *
19
+ * @dbxUtil
20
+ * @dbxUtilCategory array
21
+ * @dbxUtilTags array, limit, slice, truncate, take, cap
22
+ * @dbxUtilRelated take-front, take-last
23
+ *
19
24
  * @param array - source array to limit
20
25
  * @param inputConfig - configuration controlling the limit count and direction
21
26
  * @param inputConfig.limit - maximum number of items to include in the result
@@ -11,6 +11,12 @@ export type RandomPickFactory<T> = (() => T) & {
11
11
  /**
12
12
  * Creates a {@link RandomPickFactory} from the input values.
13
13
  *
14
+ * @dbxUtil
15
+ * @dbxUtilCategory array
16
+ * @dbxUtilKind factory
17
+ * @dbxUtilTags array, random, pick, sample, choose, factory
18
+ * @dbxUtilRelated pick-one-randomly, random-array-index
19
+ *
14
20
  * @param values - array of values to randomly pick from
15
21
  * @returns a callable factory that returns a random value from the array on each invocation
16
22
  * @throws Error if the input array is empty
@@ -19,6 +25,11 @@ export declare function randomPickFactory<T>(values: T[]): RandomPickFactory<T>;
19
25
  /**
20
26
  * Returns a random index from the input array. Returns 0 if the array is empty.
21
27
  *
28
+ * @dbxUtil
29
+ * @dbxUtilCategory array
30
+ * @dbxUtilTags array, random, index, position
31
+ * @dbxUtilRelated pick-one-randomly, random-pick-factory
32
+ *
22
33
  * @param values - array to generate a random index for
23
34
  * @returns a random valid index within the array, or 0 if the array is empty
24
35
  */
@@ -26,6 +37,11 @@ export declare function randomArrayIndex<T>(values: T[]): IndexNumber;
26
37
  /**
27
38
  * Picks a single item randomly from the input array.
28
39
  *
40
+ * @dbxUtil
41
+ * @dbxUtilCategory array
42
+ * @dbxUtilTags array, random, pick, sample, choose
43
+ * @dbxUtilRelated random-pick-factory, random-array-index
44
+ *
29
45
  * @param values - array to pick a random item from
30
46
  * @returns a randomly selected item from the array
31
47
  * @throws Error if the input array is empty
@@ -1,6 +1,11 @@
1
1
  /**
2
2
  * Returns items that exist in both arrays (intersection).
3
3
  *
4
+ * @dbxUtil
5
+ * @dbxUtilCategory array
6
+ * @dbxUtilTags array, set, intersection, intersect, keep, common, both
7
+ * @dbxUtilRelated exclude-values-from-array
8
+ *
4
9
  * @param values - The source array to filter.
5
10
  * @param secondArray - The array of values to keep.
6
11
  * @returns A new array containing only the values from `values` that also exist in `secondArray`.
@@ -9,6 +14,11 @@ export declare function keepValuesFromArray<T>(values: T[], secondArray: T[]): T
9
14
  /**
10
15
  * Returns items from the first array that do not exist in the second array (difference).
11
16
  *
17
+ * @dbxUtil
18
+ * @dbxUtilCategory array
19
+ * @dbxUtilTags array, set, difference, exclude, subtract, diff
20
+ * @dbxUtilRelated keep-values-from-array
21
+ *
12
22
  * @param values - The source array to filter.
13
23
  * @param secondArray - The array of values to exclude.
14
24
  * @returns A new array containing only the values from `values` that do not exist in `secondArray`.
@@ -17,6 +27,11 @@ export declare function excludeValuesFromArray<T>(values: T[], secondArray: T[])
17
27
  /**
18
28
  * Checks whether the given array contains any duplicate values.
19
29
  *
30
+ * @dbxUtil
31
+ * @dbxUtilCategory array
32
+ * @dbxUtilTags array, duplicate, check, validation, set
33
+ * @dbxUtilRelated find-index-of-first-duplicate-value, unique
34
+ *
20
35
  * @param values - The array to check for duplicates.
21
36
  * @returns `true` if the array contains at least one duplicate value, `false` otherwise.
22
37
  */
@@ -24,6 +39,11 @@ export declare function arrayContainsDuplicateValue<T>(values: T[]): boolean;
24
39
  /**
25
40
  * Finds the index of the first duplicate value in the given array.
26
41
  *
42
+ * @dbxUtil
43
+ * @dbxUtilCategory array
44
+ * @dbxUtilTags array, duplicate, find, index, search
45
+ * @dbxUtilRelated array-contains-duplicate-value, unique
46
+ *
27
47
  * @param values - The array to search for duplicates.
28
48
  * @returns The index of the first value that is a duplicate of an earlier value, or `-1` if no duplicates exist.
29
49
  */
@@ -4,6 +4,11 @@ import { type DecisionFunction } from '../value/decision';
4
4
  /**
5
5
  * Concatenates multiple arrays and returns only unique values.
6
6
  *
7
+ * @dbxUtil
8
+ * @dbxUtilCategory array
9
+ * @dbxUtilTags array, unique, concat, distinct, dedupe, deduplicate
10
+ * @dbxUtilRelated unique, flatten-array-unique, concat-arrays
11
+ *
7
12
  * @param arrays - Arrays to concatenate. Null/undefined arrays are ignored.
8
13
  * @returns Array containing only unique values from all input arrays.
9
14
  */
@@ -11,6 +16,11 @@ export declare function concatArraysUnique<T extends PrimativeKey = PrimativeKey
11
16
  /**
12
17
  * Flattens a 2D array and returns only unique values.
13
18
  *
19
+ * @dbxUtil
20
+ * @dbxUtilCategory array
21
+ * @dbxUtilTags array, flatten, unique, distinct, dedupe, nested
22
+ * @dbxUtilRelated unique, concat-arrays-unique, flatten-array
23
+ *
14
24
  * @param array - Two-dimensional array to flatten and deduplicate.
15
25
  * @returns Array containing only unique values from the flattened input.
16
26
  */
@@ -18,6 +28,11 @@ export declare function flattenArrayUnique<T extends PrimativeKey = PrimativeKey
18
28
  /**
19
29
  * Filters the input values and only returns unique values.
20
30
  *
31
+ * @dbxUtil
32
+ * @dbxUtilCategory array
33
+ * @dbxUtilTags array, unique, distinct, dedupe, deduplicate, set
34
+ * @dbxUtilRelated filter-unique-values, filter-unique-function, concat-arrays-unique
35
+ *
21
36
  * @param values - Array of primitive-key values to deduplicate.
22
37
  * @param excludeInput - Optional keys or values to exclude from the result.
23
38
  * @returns Array containing only unique values with exclusions removed.
@@ -63,6 +78,12 @@ export declare function readKeysFromFilterUniqueFunctionAdditionalKeys<T, K exte
63
78
  /**
64
79
  * Creates a {@link FilterUniqueFunction} that deduplicates items by their computed key.
65
80
  *
81
+ * @dbxUtil
82
+ * @dbxUtilCategory array
83
+ * @dbxUtilKind factory
84
+ * @dbxUtilTags array, unique, distinct, dedupe, factory, key, filter
85
+ * @dbxUtilRelated filter-unique-values, unique, allow-value-once-filter
86
+ *
66
87
  * @param readKey - Function to extract a unique key from each item.
67
88
  * @param additionalKeysInput - Optional keys or values to pre-seed as already seen, causing them to be excluded.
68
89
  * @returns A reusable filter function that removes duplicate items from arrays.
@@ -71,6 +92,11 @@ export declare function filterUniqueFunction<T, K extends PrimativeKey = Primati
71
92
  /**
72
93
  * Filters an array to contain only items with unique keys.
73
94
  *
95
+ * @dbxUtil
96
+ * @dbxUtilCategory array
97
+ * @dbxUtilTags array, unique, filter, dedupe, key, distinct
98
+ * @dbxUtilRelated filter-unique-function, unique, is-unique-keyed-function
99
+ *
74
100
  * @param values - Array of items to deduplicate.
75
101
  * @param readKey - Function to extract a unique key from each item.
76
102
  * @param additionalKeys - Optional keys to pre-seed as already seen, excluding matching items.
@@ -84,6 +110,12 @@ export type IsUniqueKeyedFunction<T> = DecisionFunction<T[]>;
84
110
  /**
85
111
  * Creates an {@link IsUniqueKeyedFunction} that checks whether all items in an array have unique keys.
86
112
  *
113
+ * @dbxUtil
114
+ * @dbxUtilCategory array
115
+ * @dbxUtilKind factory
116
+ * @dbxUtilTags array, unique, validation, distinct, key, decision, factory
117
+ * @dbxUtilRelated filter-unique-function, unique
118
+ *
87
119
  * @param readKey - Function to extract a unique key from each item.
88
120
  * @returns A decision function that returns true if all items have distinct keys.
89
121
  */
@@ -104,6 +136,12 @@ export type AllowValueOnceFilter<T, K extends PrimativeKey = PrimativeKey> = Dec
104
136
  /**
105
137
  * Creates a new {@link AllowValueOnceFilter} that permits each unique key only on its first encounter.
106
138
  *
139
+ * @dbxUtil
140
+ * @dbxUtilCategory array
141
+ * @dbxUtilKind factory
142
+ * @dbxUtilTags array, unique, filter, factory, stateful, once, dedupe
143
+ * @dbxUtilRelated filter-unique-function, unique
144
+ *
107
145
  * @param inputReadKey - Optional function to extract a key from each value. Defaults to identity.
108
146
  * @returns A stateful filter function that returns true only for the first occurrence of each key.
109
147
  */
@@ -17,6 +17,11 @@ export declare function filterMaybeArrayFunction<T>(filterFn: Parameters<Array<M
17
17
  /**
18
18
  * Filters all maybe values from the input array. If a maybe value is input, returns an empty array.
19
19
  *
20
+ * @dbxUtil
21
+ * @dbxUtilCategory array
22
+ * @dbxUtilTags array, filter, maybe, nullish, non-null, defined, compact
23
+ * @dbxUtilRelated filter-empty-array-values, filter-maybe-array-function
24
+ *
20
25
  * @param values - Optional array of optional values to filter.
21
26
  * @returns An array containing only non-null and non-undefined values.
22
27
  */
@@ -24,6 +29,11 @@ export declare const filterMaybeArrayValues: UniversalFilterMaybeArrayFunction;
24
29
  /**
25
30
  * Filters all empty and maybe values from the input array. If a maybe value is input, returns an empty array.
26
31
  *
32
+ * @dbxUtil
33
+ * @dbxUtilCategory array
34
+ * @dbxUtilTags array, filter, empty, maybe, nullish, non-empty, compact
35
+ * @dbxUtilRelated filter-maybe-array-values, filter-maybe-array-function
36
+ *
27
37
  * @param values - Optional array of optional values to filter.
28
38
  * @returns An array containing only non-null, non-undefined, and non-empty values.
29
39
  */
@@ -1,2 +1,4 @@
1
1
  export * from './auth.role';
2
2
  export * from './auth.role.claims';
3
+ export * from './oauth';
4
+ export * from './pkce';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Standard "out-of-band" OAuth 2.0 redirect URI URN.
3
+ *
4
+ * Defined by RFC 6749 §1.3 / draft-ietf-oauth-native-apps. Used by native and CLI clients that
5
+ * have no HTTP server to receive the redirect — the authorization server displays the
6
+ * authorization code on a final page and the user pastes it back into the application.
7
+ *
8
+ * Many providers have deprecated this in favor of loopback redirects (e.g.
9
+ * `http://127.0.0.1:<port>/callback`), but it remains in use as a fallback for tools that cannot
10
+ * bind a local port.
11
+ */
12
+ export declare const OAUTH_OOB_REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generates a random PKCE code verifier string (43 characters, base64url-encoded).
3
+ *
4
+ * @returns A cryptographically random base64url string suitable for use as a PKCE code_verifier.
5
+ */
6
+ export declare function generatePkceCodeVerifier(): string;
7
+ /**
8
+ * Generates a PKCE code challenge from a code verifier using SHA-256.
9
+ *
10
+ * @param verifier - The code verifier string to hash
11
+ * @returns A base64url-encoded SHA-256 hash of the verifier
12
+ */
13
+ export declare function generatePkceCodeChallenge(verifier: string): Promise<string>;
@@ -19,6 +19,11 @@ export type TrueOrFalseString = 'true' | 'false';
19
19
  /**
20
20
  * If a non-null boolean value is provided, returns the opposite.
21
21
  *
22
+ * @dbxUtil
23
+ * @dbxUtilCategory boolean
24
+ * @dbxUtilTags boolean, invert, negate, not, maybe, nullish
25
+ * @dbxUtilRelated reduce-booleans-with-and, reduce-booleans-with-or
26
+ *
22
27
  * @param x - the boolean value to invert, or a nullish value
23
28
  * @returns the inverted boolean, or the original nullish value if input was null/undefined
24
29
  */
@@ -35,6 +40,11 @@ export declare function invertMaybeBoolean(x: Maybe<boolean>): Maybe<boolean>;
35
40
  * @returns The result of ANDing all boolean values in the array.
36
41
  * @throws {TypeError} If the array is empty and no emptyArrayValue is provided.
37
42
  *
43
+ * @dbxUtil
44
+ * @dbxUtilCategory boolean
45
+ * @dbxUtilTags boolean, reduce, and, every, all, conjunction, aggregate
46
+ * @dbxUtilRelated reduce-booleans-with-or, reduce-booleans-with-and-fn
47
+ *
38
48
  * @example
39
49
  * ```ts
40
50
  * reduceBooleansWithAnd([true, true, true]); // true
@@ -46,6 +56,11 @@ export declare function reduceBooleansWithAnd(array: boolean[], emptyArrayValue?
46
56
  /**
47
57
  * Reduces an array of booleans with the logical OR operation.
48
58
  *
59
+ * @dbxUtil
60
+ * @dbxUtilCategory boolean
61
+ * @dbxUtilTags boolean, reduce, or, some, any, disjunction, aggregate
62
+ * @dbxUtilRelated reduce-booleans-with-and, reduce-booleans-with-or-fn
63
+ *
49
64
  * @param array - Array of boolean values to reduce.
50
65
  * @param emptyArrayValue - Value to return if the array is empty. If not provided and the array is empty, a TypeError will be thrown.
51
66
  * @returns The result of ORing all boolean values in the array.
@@ -125,6 +140,12 @@ export interface BooleanFactoryConfig {
125
140
  * @param config - Configuration for the boolean factory, including the chance of returning true.
126
141
  * @returns A factory function (`BooleanFactory`) that generates random boolean values based on the configured chance.
127
142
  *
143
+ * @dbxUtil
144
+ * @dbxUtilCategory boolean
145
+ * @dbxUtilKind factory
146
+ * @dbxUtilTags boolean, factory, random, chance, probability, generate
147
+ * @dbxUtilRelated random-boolean
148
+ *
128
149
  * @example
129
150
  * ```ts
130
151
  * const alwaysTrue = booleanFactory({ chance: 100 });
@@ -138,6 +159,11 @@ export declare function booleanFactory(config: BooleanFactoryConfig): BooleanFac
138
159
  /**
139
160
  * Returns a random boolean based on the specified chance.
140
161
  *
162
+ * @dbxUtil
163
+ * @dbxUtilCategory boolean
164
+ * @dbxUtilTags boolean, random, chance, probability, coin-flip
165
+ * @dbxUtilRelated boolean-factory
166
+ *
141
167
  * @param chance - Number between 0.0 and 100.0 representing the percentage chance of returning true (default: 50, i.e., 50%).
142
168
  * @returns A random boolean value with the specified probability of being true.
143
169
  */
@@ -151,6 +177,11 @@ export declare function randomBoolean(chance?: BooleanTrueChance): boolean;
151
177
  * @param defaultValue - The default value to return if the string cannot be converted to a boolean (default: undefined).
152
178
  * @returns The boolean value corresponding to the string, or the default value if the string cannot be converted.
153
179
  *
180
+ * @dbxUtil
181
+ * @dbxUtilCategory boolean
182
+ * @dbxUtilTags boolean, string, parse, convert, true, false, yes, no
183
+ * @dbxUtilRelated true-or-false-string
184
+ *
154
185
  * @example
155
186
  * ```ts
156
187
  * stringToBoolean('yes'); // true
@@ -166,6 +197,11 @@ export declare function stringToBoolean(value: Maybe<string>, defaultValue?: May
166
197
  * Converts a boolean to its `'true'` or `'false'` string representation.
167
198
  * Returns null/undefined if the input is nullish.
168
199
  *
200
+ * @dbxUtil
201
+ * @dbxUtilCategory boolean
202
+ * @dbxUtilTags boolean, string, convert, serialize, format
203
+ * @dbxUtilRelated string-to-boolean
204
+ *
169
205
  * @param value - The boolean value to convert.
170
206
  * @returns The string `'true'` or `'false'`, or the nullish input unchanged.
171
207
  */
@@ -0,0 +1,48 @@
1
+ import { type Maybe } from '../value/maybe.type';
2
+ /**
3
+ * Async cache for a single value of type T.
4
+ *
5
+ * Implementations may be in-memory, file-backed, network-backed, or composed via
6
+ * {@link memoizeAsyncValueCache} / {@link mergeAsyncValueCaches}.
7
+ */
8
+ export interface AsyncValueCache<T> {
9
+ /**
10
+ * Loads the value from the cache, or returns null/undefined when no value is stored.
11
+ */
12
+ load(): Promise<Maybe<T>>;
13
+ /**
14
+ * Stores the value in the cache, replacing any previously stored value.
15
+ */
16
+ update(value: T): Promise<void>;
17
+ /**
18
+ * Removes the stored value and any persistent backing.
19
+ */
20
+ clear(): Promise<void>;
21
+ }
22
+ /**
23
+ * Async cache for a record of T entries keyed by string.
24
+ *
25
+ * Implementations may be in-memory, file-backed (one file holds all keys), or composed.
26
+ */
27
+ export interface AsyncKeyedValueCache<T> {
28
+ /**
29
+ * Loads the full record from the cache. Returns an empty object when the cache is empty.
30
+ */
31
+ load(): Promise<Record<string, T>>;
32
+ /**
33
+ * Returns the entry for the given key, or null/undefined when no entry is stored.
34
+ */
35
+ get(key: string): Promise<Maybe<T>>;
36
+ /**
37
+ * Stores the entry for the given key, replacing any previous entry at that key.
38
+ */
39
+ set(key: string, value: T): Promise<void>;
40
+ /**
41
+ * Removes the entry for the given key, leaving other keys intact.
42
+ */
43
+ remove(key: string): Promise<void>;
44
+ /**
45
+ * Removes all entries and any persistent backing.
46
+ */
47
+ clear(): Promise<void>;
48
+ }
@@ -0,0 +1,59 @@
1
+ import { type AsyncKeyedValueCache, type AsyncValueCache } from './cache';
2
+ /**
3
+ * Wraps an inner {@link AsyncValueCache} with a single-load in-memory memoization layer.
4
+ *
5
+ * The first {@link AsyncValueCache.load} call delegates to the inner cache and stores the
6
+ * result; subsequent calls return the memoized value without touching the inner cache again.
7
+ * {@link AsyncValueCache.update} writes through to the inner cache and refreshes the memo.
8
+ * {@link AsyncValueCache.clear} clears both layers.
9
+ *
10
+ * Note: the memoized value is per-process. Long-running processes will not observe writes
11
+ * made by other processes to the inner backing once the memo is populated.
12
+ *
13
+ * @dbxUtil
14
+ * @dbxUtilCategory cache
15
+ * @dbxUtilTags memoize, memo, cache, async, single-load, async-value
16
+ * @dbxUtilRelated memoize-async-keyed-value-cache
17
+ *
18
+ * @param inner - The backing cache to memoize. Reads are delegated once and cached; writes are forwarded through and refresh the memo.
19
+ * @returns An {@link AsyncValueCache} that proxies the inner cache with a single-load memoization layer.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const memo = memoizeAsyncValueCache(inMemoryAsyncValueCache<string>('initial'));
24
+ * await memo.load(); // delegates to inner.load() once
25
+ * await memo.load(); // returns memoized value without hitting inner
26
+ * await memo.update('next'); // writes through to inner and refreshes memo
27
+ * ```
28
+ */
29
+ export declare function memoizeAsyncValueCache<T>(inner: AsyncValueCache<T>): AsyncValueCache<T>;
30
+ /**
31
+ * Wraps an inner {@link AsyncKeyedValueCache} with a single-load in-memory memoization layer
32
+ * over the full record.
33
+ *
34
+ * The first call to any read method ({@link AsyncKeyedValueCache.load} or {@link AsyncKeyedValueCache.get})
35
+ * delegates to the inner cache and stores the loaded record; subsequent reads return entries
36
+ * from the memoized record without re-hitting the inner cache. Writes ({@link AsyncKeyedValueCache.set} /
37
+ * {@link AsyncKeyedValueCache.remove}) update the memoized record and write through to the inner cache.
38
+ * {@link AsyncKeyedValueCache.clear} clears both layers.
39
+ *
40
+ * Note: the memoized record is per-process. Long-running processes will not observe writes
41
+ * made by other processes to the inner backing once the memo is populated.
42
+ *
43
+ * @dbxUtil
44
+ * @dbxUtilCategory cache
45
+ * @dbxUtilTags memoize, memo, cache, async, keyed, record
46
+ * @dbxUtilRelated memoize-async-value-cache
47
+ *
48
+ * @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.
49
+ * @returns An {@link AsyncKeyedValueCache} that proxies the inner cache with a record-level memoization layer.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const memo = memoizeAsyncKeyedValueCache(inMemoryAsyncKeyedValueCache<number>({ a: 1 }));
54
+ * await memo.get('a'); // delegates to inner.load() once
55
+ * await memo.get('a'); // returns memoized entry without hitting inner
56
+ * await memo.set('b', 2); // writes through to inner and updates memo
57
+ * ```
58
+ */
59
+ export declare function memoizeAsyncKeyedValueCache<T>(inner: AsyncKeyedValueCache<T>): AsyncKeyedValueCache<T>;