@dereekb/util 13.0.6 → 13.1.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 (148) hide show
  1. package/fetch/index.cjs.js +274 -33
  2. package/fetch/index.esm.js +274 -35
  3. package/fetch/package.json +2 -2
  4. package/fetch/src/lib/fetch.file.d.ts +67 -20
  5. package/fetch/src/lib/fetch.page.iterate.d.ts +277 -49
  6. package/index.cjs.js +4107 -1516
  7. package/index.esm.js +4107 -1516
  8. package/package.json +1 -2
  9. package/src/lib/array/array.d.ts +92 -47
  10. package/src/lib/array/array.find.d.ts +14 -18
  11. package/src/lib/array/array.index.d.ts +43 -14
  12. package/src/lib/array/array.indexed.d.ts +66 -17
  13. package/src/lib/array/array.limit.d.ts +11 -0
  14. package/src/lib/array/array.make.d.ts +9 -3
  15. package/src/lib/array/array.map.d.ts +20 -8
  16. package/src/lib/array/array.number.d.ts +63 -5
  17. package/src/lib/array/array.random.d.ts +12 -9
  18. package/src/lib/array/array.set.d.ts +24 -1
  19. package/src/lib/array/array.string.d.ts +104 -0
  20. package/src/lib/array/array.unique.d.ts +60 -8
  21. package/src/lib/array/array.value.d.ts +20 -11
  22. package/src/lib/assertion/assertion.d.ts +30 -2
  23. package/src/lib/assertion/assertion.generic.d.ts +8 -0
  24. package/src/lib/assertion/assertion.number.d.ts +16 -0
  25. package/src/lib/auth/auth.role.claims.d.ts +14 -8
  26. package/src/lib/boolean.d.ts +54 -1
  27. package/src/lib/contact/domain.d.ts +22 -4
  28. package/src/lib/contact/random.d.ts +24 -0
  29. package/src/lib/date/date.d.ts +8 -13
  30. package/src/lib/date/hour.d.ts +51 -32
  31. package/src/lib/date/minute.d.ts +4 -4
  32. package/src/lib/date/time.d.ts +12 -3
  33. package/src/lib/date/week.d.ts +77 -10
  34. package/src/lib/error/error.d.ts +54 -3
  35. package/src/lib/error/error.server.d.ts +25 -2
  36. package/src/lib/file/pdf.d.ts +15 -0
  37. package/src/lib/filter/filter.d.ts +12 -7
  38. package/src/lib/function/function.boolean.d.ts +4 -4
  39. package/src/lib/function/function.d.ts +2 -5
  40. package/src/lib/function/function.forward.d.ts +19 -3
  41. package/src/lib/getter/getter.cache.d.ts +9 -5
  42. package/src/lib/getter/getter.d.ts +39 -22
  43. package/src/lib/getter/getter.map.d.ts +10 -4
  44. package/src/lib/getter/getter.util.d.ts +3 -3
  45. package/src/lib/grouping.d.ts +98 -31
  46. package/src/lib/hash.d.ts +15 -8
  47. package/src/lib/iterable/iterable.d.ts +62 -50
  48. package/src/lib/iterable/iterable.map.d.ts +4 -4
  49. package/src/lib/iterate.d.ts +17 -1
  50. package/src/lib/key.d.ts +32 -10
  51. package/src/lib/lifecycle.d.ts +10 -1
  52. package/src/lib/map/map.d.ts +17 -16
  53. package/src/lib/map/map.intersection.d.ts +5 -4
  54. package/src/lib/map/map.key.d.ts +16 -15
  55. package/src/lib/misc/host.d.ts +6 -3
  56. package/src/lib/model/id.batch.d.ts +7 -3
  57. package/src/lib/model/id.factory.d.ts +16 -1
  58. package/src/lib/model/model.conversion.d.ts +49 -6
  59. package/src/lib/model/model.conversion.field.d.ts +13 -3
  60. package/src/lib/model/model.copy.d.ts +11 -0
  61. package/src/lib/model/model.d.ts +174 -1
  62. package/src/lib/model/model.modify.d.ts +24 -5
  63. package/src/lib/nodejs/stream.d.ts +8 -6
  64. package/src/lib/number/bitwise.dencoder.d.ts +43 -3
  65. package/src/lib/number/bound.d.ts +34 -5
  66. package/src/lib/number/dollar.d.ts +13 -6
  67. package/src/lib/number/factory.d.ts +11 -3
  68. package/src/lib/number/number.d.ts +55 -32
  69. package/src/lib/number/random.d.ts +13 -3
  70. package/src/lib/number/round.d.ts +47 -26
  71. package/src/lib/number/sort.d.ts +7 -1
  72. package/src/lib/number/transform.d.ts +16 -0
  73. package/src/lib/object/object.array.d.ts +16 -2
  74. package/src/lib/object/object.array.delta.d.ts +6 -2
  75. package/src/lib/object/object.d.ts +33 -5
  76. package/src/lib/object/object.empty.d.ts +4 -2
  77. package/src/lib/object/object.equal.d.ts +21 -4
  78. package/src/lib/object/object.filter.tuple.d.ts +105 -3
  79. package/src/lib/object/object.key.d.ts +13 -6
  80. package/src/lib/object/object.map.d.ts +30 -19
  81. package/src/lib/page/page.d.ts +21 -0
  82. package/src/lib/page/page.filter.d.ts +16 -9
  83. package/src/lib/path/path.d.ts +101 -14
  84. package/src/lib/path/path.tree.d.ts +16 -0
  85. package/src/lib/promise/callback.d.ts +18 -0
  86. package/src/lib/promise/is.d.ts +10 -3
  87. package/src/lib/promise/map.d.ts +5 -3
  88. package/src/lib/promise/poll.d.ts +14 -4
  89. package/src/lib/promise/promise.d.ts +84 -18
  90. package/src/lib/promise/promise.factory.d.ts +18 -2
  91. package/src/lib/promise/promise.limit.d.ts +22 -2
  92. package/src/lib/promise/promise.loop.d.ts +69 -1
  93. package/src/lib/promise/promise.ref.d.ts +14 -2
  94. package/src/lib/promise/promise.task.d.ts +8 -4
  95. package/src/lib/promise/promise.type.d.ts +4 -4
  96. package/src/lib/promise/use.d.ts +6 -4
  97. package/src/lib/promise/wait.d.ts +5 -2
  98. package/src/lib/relation/relation.d.ts +98 -0
  99. package/src/lib/service/handler.config.d.ts +47 -9
  100. package/src/lib/service/handler.d.ts +43 -1
  101. package/src/lib/service/typed.service.d.ts +21 -2
  102. package/src/lib/set/set.allowed.d.ts +6 -4
  103. package/src/lib/set/set.d.ts +174 -46
  104. package/src/lib/set/set.decision.d.ts +4 -2
  105. package/src/lib/set/set.delta.d.ts +16 -3
  106. package/src/lib/set/set.hashset.d.ts +43 -0
  107. package/src/lib/set/set.selection.d.ts +7 -3
  108. package/src/lib/sort.d.ts +36 -16
  109. package/src/lib/string/char.d.ts +48 -34
  110. package/src/lib/string/dencoder.d.ts +84 -13
  111. package/src/lib/string/factory.d.ts +13 -4
  112. package/src/lib/string/html.d.ts +7 -6
  113. package/src/lib/string/mimetype.d.ts +65 -1
  114. package/src/lib/string/prefix.d.ts +21 -7
  115. package/src/lib/string/record.d.ts +7 -4
  116. package/src/lib/string/replace.d.ts +77 -33
  117. package/src/lib/string/search.d.ts +19 -9
  118. package/src/lib/string/sort.d.ts +10 -1
  119. package/src/lib/string/string.d.ts +74 -21
  120. package/src/lib/string/transform.d.ts +7 -0
  121. package/src/lib/string/tree.d.ts +91 -29
  122. package/src/lib/string/url.d.ts +148 -63
  123. package/src/lib/tree/tree.explore.d.ts +84 -17
  124. package/src/lib/tree/tree.flatten.d.ts +44 -7
  125. package/src/lib/type.d.ts +15 -12
  126. package/src/lib/value/address.d.ts +66 -17
  127. package/src/lib/value/bound.d.ts +253 -17
  128. package/src/lib/value/build.d.ts +30 -5
  129. package/src/lib/value/comparator.d.ts +53 -25
  130. package/src/lib/value/cron.d.ts +14 -6
  131. package/src/lib/value/decision.d.ts +57 -13
  132. package/src/lib/value/equal.d.ts +44 -13
  133. package/src/lib/value/indexed.d.ts +253 -82
  134. package/src/lib/value/label.d.ts +16 -5
  135. package/src/lib/value/map.d.ts +77 -20
  136. package/src/lib/value/maybe.d.ts +47 -49
  137. package/src/lib/value/modifier.d.ts +82 -27
  138. package/src/lib/value/point.d.ts +248 -54
  139. package/src/lib/value/url.d.ts +10 -3
  140. package/src/lib/value/use.d.ts +99 -8
  141. package/src/lib/value/vector.d.ts +71 -9
  142. package/test/index.cjs.js +86 -23
  143. package/test/index.esm.js +86 -23
  144. package/test/package.json +2 -2
  145. package/test/src/lib/shared/shared.d.ts +31 -5
  146. package/test/src/lib/shared/shared.fail.d.ts +72 -9
  147. package/test/src/lib/shared/shared.function.d.ts +40 -2
  148. package/test/src/lib/shared/shared.wrap.d.ts +20 -1
@@ -1,11 +1,65 @@
1
1
  import { type IndexRange } from '../value/indexed';
2
+ /**
3
+ * Reduces an array of numbers to its maximum value.
4
+ *
5
+ * @param array - numbers to evaluate
6
+ * @param emptyArrayValue - value to return when the array is empty
7
+ * @returns the maximum number in the array, or the empty array value if the array is empty
8
+ */
2
9
  export declare function reduceNumbersWithMax(array: number[], emptyArrayValue?: number): number | undefined;
10
+ /**
11
+ * Creates a reducer function that finds the maximum value in a number array.
12
+ *
13
+ * @param emptyArrayValue - value to return when the array is empty
14
+ * @returns a function that reduces a number array to its maximum value
15
+ */
3
16
  export declare function reduceNumbersWithMaxFn(emptyArrayValue?: number): (array: number[]) => number | undefined;
17
+ /**
18
+ * Reduces an array of numbers to its minimum value.
19
+ *
20
+ * @param array - numbers to evaluate
21
+ * @param emptyArrayValue - value to return when the array is empty
22
+ * @returns the minimum number in the array, or the empty array value if the array is empty
23
+ */
4
24
  export declare function reduceNumbersWithMin(array: number[], emptyArrayValue?: number): number | undefined;
25
+ /**
26
+ * Creates a reducer function that finds the minimum value in a number array.
27
+ *
28
+ * @param emptyArrayValue - value to return when the array is empty
29
+ * @returns a function that reduces a number array to its minimum value
30
+ */
5
31
  export declare function reduceNumbersWithMinFn(emptyArrayValue?: number): (array: number[]) => number | undefined;
32
+ /**
33
+ * Reduces an array of numbers by summing all values.
34
+ *
35
+ * @param array - numbers to sum
36
+ * @param emptyArrayValue - value to return when the array is empty; defaults to 0
37
+ * @returns the sum of all numbers in the array
38
+ */
6
39
  export declare function reduceNumbersWithAdd(array: number[], emptyArrayValue?: number): number;
40
+ /**
41
+ * Creates a reducer function that sums all values in a number array.
42
+ *
43
+ * @param emptyArrayValue - value to return when the array is empty; defaults to 0
44
+ * @returns a function that reduces a number array to the sum of its values
45
+ */
7
46
  export declare function reduceNumbersWithAddFn(emptyArrayValue?: number): (array: number[]) => number;
47
+ /**
48
+ * Reduces an array of numbers using a custom reducer function.
49
+ *
50
+ * @param reduceFn - binary function applied to successive pairs of numbers
51
+ * @param array - numbers to reduce
52
+ * @param emptyArrayValue - value to return when the array is empty
53
+ * @returns the reduced result, or the empty array value if the array is empty
54
+ */
8
55
  export declare function reduceNumbers(reduceFn: (a: number, b: number) => number, array: number[], emptyArrayValue?: number): number | undefined;
56
+ /**
57
+ * Creates a reusable reducer function that reduces a number array using a custom binary function.
58
+ *
59
+ * @param reduceFn - binary function applied to successive pairs of numbers
60
+ * @param emptyArrayValue - value to return when the array is empty
61
+ * @returns a function that reduces a number array to a single value
62
+ */
9
63
  export declare function reduceNumbersFn(reduceFn: (a: number, b: number) => number): (array: number[]) => number | undefined;
10
64
  export declare function reduceNumbersFn<D extends number>(reduceFn: (a: number, b: number) => number, emptyArrayValue?: D): (array: number[]) => number | D;
11
65
  /**
@@ -25,13 +79,17 @@ export interface RangeInputObject {
25
79
  */
26
80
  readonly end: RangeInputEndValue;
27
81
  }
82
+ /**
83
+ * Input for the {@link range} function. Accepts a plain number (treated as the exclusive end with start at 0),
84
+ * a {@link RangeInputObject}, or an {@link IndexRange}.
85
+ */
28
86
  export type RangeInput = number | RangeInputObject | IndexRange;
29
87
  /**
30
- * Generates an array containing the range of numbers specified.
31
- *
32
- * The end value is excluded.
88
+ * Generates an array containing the range of numbers specified. The end value is excluded.
89
+ * Supports ascending and descending ranges.
33
90
  *
34
- * @param param0
35
- * @returns
91
+ * @param input - range specification as a number, {@link RangeInputObject}, or {@link IndexRange}; when a number and `inputEnd` is provided, acts as the start value
92
+ * @param inputEnd - optional exclusive end value when `input` is a number
93
+ * @returns an array of sequential numbers within the specified range
36
94
  */
37
95
  export declare function range(input: RangeInput, inputEnd?: RangeInputEndValue): number[];
@@ -1,6 +1,6 @@
1
1
  import { type IndexNumber } from '../value/index';
2
2
  /**
3
- * Returns a random value from the pre-configured values array.
3
+ * A callable factory that returns a random value from its pre-configured values array on each invocation.
4
4
  */
5
5
  export type RandomPickFactory<T> = (() => T) & {
6
6
  /**
@@ -9,22 +9,25 @@ export type RandomPickFactory<T> = (() => T) & {
9
9
  readonly _values: T[];
10
10
  };
11
11
  /**
12
- * Creates a RandomPickFactory<T> from the input values.
12
+ * Creates a {@link RandomPickFactory} from the input values.
13
13
  *
14
- * @param values
15
- * @returns
14
+ * @param values - array of values to randomly pick from
15
+ * @returns a callable factory that returns a random value from the array on each invocation
16
+ * @throws Error if the input array is empty
16
17
  */
17
18
  export declare function randomPickFactory<T>(values: T[]): RandomPickFactory<T>;
18
19
  /**
19
- * Returns a random index from the input values.
20
+ * Returns a random index from the input array. Returns 0 if the array is empty.
20
21
  *
21
- * @param values
22
- * @returns
22
+ * @param values - array to generate a random index for
23
+ * @returns a random valid index within the array, or 0 if the array is empty
23
24
  */
24
25
  export declare function randomArrayIndex<T>(values: T[]): IndexNumber;
25
26
  /**
26
- * Picks an item randomly from the input array. If the array is empty, returns undefined.
27
+ * Picks a single item randomly from the input array.
27
28
  *
28
- * @param values
29
+ * @param values - array to pick a random item from
30
+ * @returns a randomly selected item from the array
31
+ * @throws Error if the input array is empty
29
32
  */
30
33
  export declare function pickOneRandomly<T>(values: T[]): T;
@@ -1,7 +1,30 @@
1
1
  /**
2
- * Returns items that exist in both arrays.
2
+ * Returns items that exist in both arrays (intersection).
3
+ *
4
+ * @param values - The source array to filter.
5
+ * @param secondArray - The array of values to keep.
6
+ * @returns A new array containing only the values from `values` that also exist in `secondArray`.
3
7
  */
4
8
  export declare function keepValuesFromArray<T>(values: T[], secondArray: T[]): T[];
9
+ /**
10
+ * Returns items from the first array that do not exist in the second array (difference).
11
+ *
12
+ * @param values - The source array to filter.
13
+ * @param secondArray - The array of values to exclude.
14
+ * @returns A new array containing only the values from `values` that do not exist in `secondArray`.
15
+ */
5
16
  export declare function excludeValuesFromArray<T>(values: T[], secondArray: T[]): T[];
17
+ /**
18
+ * Checks whether the given array contains any duplicate values.
19
+ *
20
+ * @param values - The array to check for duplicates.
21
+ * @returns `true` if the array contains at least one duplicate value, `false` otherwise.
22
+ */
6
23
  export declare function arrayContainsDuplicateValue<T>(values: T[]): boolean;
24
+ /**
25
+ * Finds the index of the first duplicate value in the given array.
26
+ *
27
+ * @param values - The array to search for duplicates.
28
+ * @returns The index of the first value that is a duplicate of an earlier value, or `-1` if no duplicates exist.
29
+ */
7
30
  export declare function findIndexOfFirstDuplicateValue<T>(values: T[]): number;
@@ -2,20 +2,116 @@ import { type ArrayOrValue } from './array';
2
2
  import { type ReadKeyFunction } from '../key';
3
3
  import { type MapFunction } from '../value/map';
4
4
  import { type TransformStringFunctionConfig } from '../string/transform';
5
+ /**
6
+ * Compares two string arrays and returns whether they contain different values, ignoring case.
7
+ *
8
+ * @param a - first array of strings to compare
9
+ * @param b - second array of strings to compare
10
+ * @returns `true` if the arrays contain different values when compared case-insensitively
11
+ */
5
12
  export declare function hasDifferentStringsNoCase(a: string[], b: string[]): boolean;
13
+ /**
14
+ * Maps an array of strings to their trimmed equivalents.
15
+ *
16
+ * @param input - array of strings to trim
17
+ * @returns a new array with each string trimmed of leading and trailing whitespace
18
+ */
6
19
  export declare const trimArray: MapFunction<string[], string[]>;
20
+ /**
21
+ * Maps an array of strings to their uppercase equivalents.
22
+ *
23
+ * @param input - array of strings to convert
24
+ * @returns a new array with each string converted to uppercase
25
+ */
7
26
  export declare const arrayToUppercase: MapFunction<string[], string[]>;
27
+ /**
28
+ * Maps an array of strings to their lowercase equivalents.
29
+ *
30
+ * @param input - array of strings to convert
31
+ * @returns a new array with each string converted to lowercase
32
+ */
8
33
  export declare const arrayToLowercase: MapFunction<string[], string[]>;
34
+ /**
35
+ * A function that transforms an array of strings into another array of strings.
36
+ */
9
37
  export type TransformStringsFunction = MapFunction<string[], string[]>;
38
+ /**
39
+ * Creates a {@link TransformStringsFunction} from the given configuration. If the configuration results
40
+ * in an identity transform, the returned function will be an identity function.
41
+ *
42
+ * @param config - configuration describing the string transformations to apply
43
+ * @returns a function that applies the configured transformations to an array of strings
44
+ */
10
45
  export declare function transformStrings(config: TransformStringFunctionConfig): TransformStringsFunction;
46
+ /**
47
+ * Converts an iterable of strings to a lowercase string array for case-insensitive operations.
48
+ *
49
+ * @param values - iterable of strings to convert
50
+ * @returns an array of lowercase strings
51
+ */
11
52
  export declare function toCaseInsensitiveStringArray(values: Iterable<string>): string[];
53
+ /**
54
+ * Returns an array of unique strings from the input, compared case-insensitively. All returned strings are lowercase.
55
+ *
56
+ * @param values - iterable of strings to deduplicate
57
+ * @returns an array of unique lowercase strings
58
+ */
12
59
  export declare function uniqueCaseInsensitiveStrings(values: Iterable<string>): string[];
60
+ /**
61
+ * Returns a {@link Set} of unique lowercase strings from the input, compared case-insensitively.
62
+ *
63
+ * @param values - iterable of strings to deduplicate
64
+ * @returns a set of unique lowercase strings
65
+ */
13
66
  export declare function uniqueCaseInsensitiveStringsSet(values: Iterable<string>): Set<string>;
67
+ /**
68
+ * Flattens a two-dimensional array of strings into a single array of unique lowercase strings, compared case-insensitively.
69
+ *
70
+ * @param array - two-dimensional array of strings to flatten and deduplicate
71
+ * @returns a flat array of unique lowercase strings
72
+ */
14
73
  export declare function flattenArrayUniqueCaseInsensitiveStrings(array: string[][]): string[];
74
+ /**
75
+ * Filters an array of models to only include items with unique keys when compared case-insensitively.
76
+ * Items whose keys match the additional keys are also excluded.
77
+ *
78
+ * @param models - array of models to filter
79
+ * @param readKey - function that extracts the string key from each model
80
+ * @param additionalKeys - optional keys to treat as already seen, excluding models with matching keys
81
+ * @returns the filtered array of models with unique case-insensitive keys
82
+ */
15
83
  export declare function filterUniqueCaseInsensitiveStrings<T, K extends string = string>(models: T[], readKey: ReadKeyFunction<T, K>, additionalKeys?: K[]): T[];
84
+ /**
85
+ * Checks whether the given iterable contains the specified string, ignoring case.
86
+ *
87
+ * @param values - iterable of strings to search
88
+ * @param valueToFind - the string to search for
89
+ * @param mustContainAtleastOneItem - if `true`, returns `false` when the values iterable is empty
90
+ * @returns `true` if the string is found case-insensitively
91
+ */
16
92
  export declare function containsStringAnyCase(values: Iterable<string>, valueToFind: string, mustContainAtleastOneItem?: boolean): boolean;
93
+ /**
94
+ * Checks whether the given iterable contains any of the specified strings, ignoring case.
95
+ *
96
+ * @param values - iterable of strings to search
97
+ * @param valuesToFind - iterable of strings to search for
98
+ * @param mustContainAtleastOneItem - if `true`, returns `false` when the values iterable is empty
99
+ * @returns `true` if at least one of the strings is found case-insensitively
100
+ */
17
101
  export declare function containsAnyStringAnyCase(values: Iterable<string>, valuesToFind: Iterable<string>, mustContainAtleastOneItem?: boolean): boolean;
102
+ /**
103
+ * Checks whether the given iterable contains all of the specified strings, ignoring case.
104
+ * Returns `true` if there are no strings to find.
105
+ *
106
+ * @param values - iterable of strings to search
107
+ * @param valuesToFind - iterable of strings that must all be present
108
+ * @param mustContainAtleastOneItem - if `true`, returns `false` when the values iterable is empty
109
+ * @returns `true` if all of the strings are found case-insensitively
110
+ */
18
111
  export declare function containsAllStringsAnyCase(values: Iterable<string>, valuesToFind: Iterable<string>, mustContainAtleastOneItem?: boolean): boolean;
112
+ /**
113
+ * Configuration for creating a {@link FilterUniqueTransform} that transforms and deduplicates an array of strings.
114
+ */
19
115
  export interface FilterUniqueStringsTransformConfig extends TransformStringFunctionConfig {
20
116
  /**
21
117
  * Whether or not to compare values as lowercase when finding uniqueness.
@@ -32,4 +128,12 @@ export interface FilterUniqueStringsTransformConfig extends TransformStringFunct
32
128
  * Transforms an array of strings into an array of unique strings.
33
129
  */
34
130
  export type FilterUniqueTransform = TransformStringsFunction;
131
+ /**
132
+ * Creates a function that transforms an array of strings and removes duplicates based on the given configuration.
133
+ * When `caseInsensitive` is enabled, uniqueness is determined before transformation; otherwise, transformation
134
+ * is applied first and then duplicates are removed.
135
+ *
136
+ * @param config - configuration describing transformation, uniqueness comparison, and exclusions
137
+ * @returns a function that transforms and deduplicates an input array of strings
138
+ */
35
139
  export declare function filterUniqueTransform(config: FilterUniqueStringsTransformConfig): FilterUniqueTransform;
@@ -1,14 +1,26 @@
1
1
  import { type PrimativeKey, type ReadKeyFunction } from '../key';
2
2
  import { type Maybe } from '../value/maybe.type';
3
3
  import { type DecisionFunction } from '../value/decision';
4
+ /**
5
+ * Concatenates multiple arrays and returns only unique values.
6
+ *
7
+ * @param arrays - Arrays to concatenate. Null/undefined arrays are ignored.
8
+ * @returns Array containing only unique values from all input arrays.
9
+ */
4
10
  export declare function concatArraysUnique<T extends PrimativeKey = PrimativeKey>(...arrays: Maybe<T[]>[]): T[];
11
+ /**
12
+ * Flattens a 2D array and returns only unique values.
13
+ *
14
+ * @param array - Two-dimensional array to flatten and deduplicate.
15
+ * @returns Array containing only unique values from the flattened input.
16
+ */
5
17
  export declare function flattenArrayUnique<T extends PrimativeKey = PrimativeKey>(array: T[][]): T[];
6
18
  /**
7
19
  * Filters the input values and only returns unique values.
8
20
  *
9
- * @param values
10
- * @param exclude
11
- * @returns
21
+ * @param values - Array of primitive-key values to deduplicate.
22
+ * @param excludeInput - Optional keys or values to exclude from the result.
23
+ * @returns Array containing only unique values with exclusions removed.
12
24
  */
13
25
  export declare function unique<T extends PrimativeKey = PrimativeKey>(values: T[], excludeInput?: FilterUniqueFunctionExcludeKeysInput<T, T>): T[];
14
26
  /**
@@ -17,27 +29,64 @@ export declare function unique<T extends PrimativeKey = PrimativeKey>(values: T[
17
29
  * Can also specify additional values to exclude.
18
30
  */
19
31
  export type FilterUniqueFunction<T, K extends PrimativeKey = PrimativeKey> = (input: T[], exclude?: FilterUniqueFunctionExcludeKeysInput<T, K>) => T[];
32
+ /**
33
+ * Input for specifying additional keys to include in uniqueness checks. Accepts either a raw array of keys or a {@link FilterUniqueFunctionAdditionalKeys} object.
34
+ */
20
35
  export type FilterUniqueFunctionAdditionalKeysInput<T, K extends PrimativeKey = PrimativeKey> = K[] | FilterUniqueFunctionAdditionalKeys<T, K>;
36
+ /**
37
+ * Input for specifying keys or values to exclude from unique filtering. Accepts either a raw array of values or a {@link FilterUniqueFunctionAdditionalKeys} object.
38
+ */
21
39
  export type FilterUniqueFunctionExcludeKeysInput<T, K extends PrimativeKey = PrimativeKey> = T[] | FilterUniqueFunctionAdditionalKeys<T, K>;
40
+ /**
41
+ * Provides additional keys and/or values to seed the uniqueness filter, causing those entries to be treated as already seen.
42
+ */
22
43
  export interface FilterUniqueFunctionAdditionalKeys<T, K extends PrimativeKey = PrimativeKey> {
23
44
  readonly keys?: Maybe<K[]>;
24
45
  readonly values?: Maybe<T[]>;
25
46
  }
47
+ /**
48
+ * Reads and resolves keys from a {@link FilterUniqueFunctionAdditionalKeysInput}, handling both raw key arrays and structured input objects.
49
+ *
50
+ * @param additionalKeysInput - Input containing keys to resolve.
51
+ * @param readKey - Function to extract a key from a value.
52
+ * @returns Flat array of resolved non-null keys.
53
+ */
26
54
  export declare function readKeysFromFilterUniqueFunctionAdditionalKeysInput<T, K extends PrimativeKey = PrimativeKey>(additionalKeysInput: Maybe<FilterUniqueFunctionAdditionalKeysInput<T, K>>, readKey: ReadKeyFunction<T, K>): K[];
55
+ /**
56
+ * Reads keys from a {@link FilterUniqueFunctionAdditionalKeys} object by combining explicit keys with keys derived from values.
57
+ *
58
+ * @param input - Object containing explicit keys and/or values to derive keys from.
59
+ * @param readKey - Function to extract a key from a value.
60
+ * @returns Array of keys, which may include null/undefined entries.
61
+ */
27
62
  export declare function readKeysFromFilterUniqueFunctionAdditionalKeys<T, K extends PrimativeKey = PrimativeKey>(input: FilterUniqueFunctionAdditionalKeys<T, K>, readKey: ReadKeyFunction<T, K>): Maybe<K>[];
28
63
  /**
29
- * Creates a FilterUniqueFunction.
64
+ * Creates a {@link FilterUniqueFunction} that deduplicates items by their computed key.
30
65
  *
31
- * @param readKey
32
- * @param additionalKeys
33
- * @returns
66
+ * @param readKey - Function to extract a unique key from each item.
67
+ * @param additionalKeysInput - Optional keys or values to pre-seed as already seen, causing them to be excluded.
68
+ * @returns A reusable filter function that removes duplicate items from arrays.
34
69
  */
35
70
  export declare function filterUniqueFunction<T, K extends PrimativeKey = PrimativeKey>(readKey: ReadKeyFunction<T, K>, additionalKeysInput?: FilterUniqueFunctionAdditionalKeysInput<T, K>): FilterUniqueFunction<T, K>;
71
+ /**
72
+ * Filters an array to contain only items with unique keys.
73
+ *
74
+ * @param values - Array of items to deduplicate.
75
+ * @param readKey - Function to extract a unique key from each item.
76
+ * @param additionalKeys - Optional keys to pre-seed as already seen, excluding matching items.
77
+ * @returns Array containing only the first occurrence of each uniquely-keyed item.
78
+ */
36
79
  export declare function filterUniqueValues<T, K extends PrimativeKey = PrimativeKey>(values: T[], readKey: ReadKeyFunction<T, K>, additionalKeys?: K[]): T[];
37
80
  /**
38
81
  * Returns true if all input values have unique keys.
39
82
  */
40
83
  export type IsUniqueKeyedFunction<T> = DecisionFunction<T[]>;
84
+ /**
85
+ * Creates an {@link IsUniqueKeyedFunction} that checks whether all items in an array have unique keys.
86
+ *
87
+ * @param readKey - Function to extract a unique key from each item.
88
+ * @returns A decision function that returns true if all items have distinct keys.
89
+ */
41
90
  export declare function isUniqueKeyedFunction<T, K extends PrimativeKey = PrimativeKey>(readKey: ReadKeyFunction<T, K>): IsUniqueKeyedFunction<T>;
42
91
  /**
43
92
  * Function that returns true for a value the first time that value's key is visited. Will return false for all visits after that.
@@ -53,7 +102,10 @@ export type AllowValueOnceFilter<T, K extends PrimativeKey = PrimativeKey> = Dec
53
102
  readonly _visitedKeys: Set<Maybe<K>>;
54
103
  };
55
104
  /**
56
- * Creates a new AllowValueOnceFilter.
105
+ * Creates a new {@link AllowValueOnceFilter} that permits each unique key only on its first encounter.
106
+ *
107
+ * @param inputReadKey - Optional function to extract a key from each value. Defaults to identity.
108
+ * @returns A stateful filter function that returns true only for the first occurrence of each key.
57
109
  */
58
110
  export declare function allowValueOnceFilter<T extends PrimativeKey = PrimativeKey>(): AllowValueOnceFilter<T, T>;
59
111
  export declare function allowValueOnceFilter<T, K extends PrimativeKey = PrimativeKey>(readKey?: ReadKeyFunction<T, K>): AllowValueOnceFilter<T, K>;
@@ -1,35 +1,44 @@
1
1
  import { type Maybe, type MaybeNot } from '../value/maybe.type';
2
2
  /**
3
- * Function that takes the input and returns an array with no Maybe values.
3
+ * Function that takes an optional array of optional values and returns a filtered array with no Maybe values.
4
4
  */
5
5
  export type FilterMaybeArrayFunction<T> = (value: Maybe<Maybe<T[]>>) => T[];
6
+ /**
7
+ * A generic variant of {@link FilterMaybeArrayFunction} that works with any element type.
8
+ */
6
9
  export type UniversalFilterMaybeArrayFunction = <T>(values: Maybe<Maybe<T>[]>) => T[];
10
+ /**
11
+ * Creates a {@link FilterMaybeArrayFunction} that filters maybe values from an array using the provided filter function.
12
+ *
13
+ * @param filterFn - Filter predicate used to determine which values to keep.
14
+ * @returns A function that filters maybe values from an optional input array.
15
+ */
7
16
  export declare function filterMaybeArrayFunction<T>(filterFn: Parameters<Array<Maybe<T>>['filter']>[0]): FilterMaybeArrayFunction<T>;
8
17
  /**
9
18
  * Filters all maybe values from the input array. If a maybe value is input, returns an empty array.
10
19
  *
11
- * @param values
12
- * @returns
20
+ * @param values - Optional array of optional values to filter.
21
+ * @returns An array containing only non-null and non-undefined values.
13
22
  */
14
23
  export declare const filterMaybeArrayValues: UniversalFilterMaybeArrayFunction;
15
24
  /**
16
25
  * Filters all empty and maybe values from the input array. If a maybe value is input, returns an empty array.
17
26
  *
18
- * @param values
19
- * @returns
27
+ * @param values - Optional array of optional values to filter.
28
+ * @returns An array containing only non-null, non-undefined, and non-empty values.
20
29
  */
21
30
  export declare const filterEmptyArrayValues: UniversalFilterMaybeArrayFunction;
22
31
  /**
23
- * Checks whether or not all values are MaybeNot values.
32
+ * Checks whether or not all values in the array are {@link MaybeNot} (null or undefined).
24
33
  *
25
- * @param values
26
- * @returns
34
+ * @param values - Array of optional values to check.
35
+ * @returns `true` if every value in the array is null or undefined.
27
36
  */
28
37
  export declare function allValuesAreMaybeNot<T>(values: Maybe<T>[]): values is MaybeNot[];
29
38
  /**
30
- * Checks whether or not all values are non-MaybeNot values.
39
+ * Checks whether or not all values in the array are defined (non-null and non-undefined).
31
40
  *
32
- * @param values
33
- * @returns
41
+ * @param values - Array of optional values to check.
42
+ * @returns `true` if every value in the array is non-null and non-undefined.
34
43
  */
35
44
  export declare function allValuesAreNotMaybe<T>(values: Maybe<T>[]): values is T[];
@@ -1,18 +1,46 @@
1
1
  import { type MapDescriptorAssertionOptions } from './assert';
2
2
  /**
3
- * Assertion function type.
3
+ * Assertion function type that validates a value.
4
4
  *
5
- * Returns true if the assertion passes.
5
+ * Returns true if the assertion passes, false otherwise.
6
6
  */
7
7
  export type AccessorValueAssertion<T> = (value: T) => boolean;
8
+ /**
9
+ * Input provided to a set-value interceptor factory function.
10
+ */
8
11
  export interface SetValueInterceptorFunctionInput<T> {
9
12
  target: object;
10
13
  propertyKey: string;
11
14
  descriptor: TypedPropertyDescriptor<T>;
12
15
  setValue: (value: T) => void;
13
16
  }
17
+ /**
18
+ * Factory function that creates a setter interceptor from the provided input.
19
+ */
14
20
  export type SetValueInterceptorFunctionFactory<T> = (input: SetValueInterceptorFunctionInput<T>) => (value: T) => void;
21
+ /**
22
+ * Utility class for creating property descriptor interceptors that validate
23
+ * values before allowing them to be set on a property.
24
+ *
25
+ * Used to build TypeScript decorator functions that enforce assertions on property setters.
26
+ */
15
27
  export declare class PropertyDescriptorUtility {
28
+ /**
29
+ * Creates a property descriptor interceptor that validates values using an assertion function
30
+ * before allowing them to be set. Optionally maps the value after validation.
31
+ *
32
+ * @param assertValueFn - Function that returns true if the value is valid
33
+ * @param options - Custom assertion options (message, map function)
34
+ * @param defaultOptions - Default options merged under the custom options
35
+ * @returns A property descriptor interceptor function
36
+ */
16
37
  static makePropertyDescriptorAssertion<T>(assertValueFn: AccessorValueAssertion<T>, options?: MapDescriptorAssertionOptions<T>, defaultOptions?: MapDescriptorAssertionOptions<T>): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => void;
38
+ /**
39
+ * Creates a low-level property descriptor interceptor that replaces the setter
40
+ * of a property with a custom function produced by the given factory.
41
+ *
42
+ * @param makeSetValueInterceptorFn - Factory that produces the replacement setter function
43
+ * @returns A property descriptor interceptor function
44
+ */
17
45
  static makeSetPropertyDescriptorInterceptor<T>(makeSetValueInterceptorFn: SetValueInterceptorFunctionFactory<T>): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => void;
18
46
  }
@@ -1,3 +1,11 @@
1
1
  import { type MapDescriptorAssertionOptions } from './assert';
2
2
  import { type AccessorValueAssertion } from './assertion';
3
+ /**
4
+ * Creates a property decorator that validates values using a custom assertion function
5
+ * before allowing them to be set on the property.
6
+ *
7
+ * @param assertion - Function that returns true if the value is valid
8
+ * @param options - Optional assertion options including custom error message and value mapping
9
+ * @returns A property descriptor interceptor that enforces the assertion on the setter
10
+ */
3
11
  export declare function Assert<T>(assertion: AccessorValueAssertion<T>, options?: MapDescriptorAssertionOptions<T>): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => void;
@@ -1,3 +1,19 @@
1
1
  import { type DescriptorAssertionOptions } from './assert';
2
+ /**
3
+ * Creates a property decorator that asserts the numeric value is greater than or equal to a minimum.
4
+ *
5
+ * @param min - The minimum allowed value (inclusive)
6
+ * @param options - Optional assertion options including custom error message
7
+ * @returns A property descriptor interceptor that enforces the minimum value constraint
8
+ * @throws {@link AssertionError} when the assigned value is less than `min`
9
+ */
2
10
  export declare function AssertMin(min: number, options?: DescriptorAssertionOptions): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<number>) => void;
11
+ /**
12
+ * Creates a property decorator that asserts the numeric value is less than or equal to a maximum.
13
+ *
14
+ * @param max - The maximum allowed value (inclusive)
15
+ * @param options - Optional assertion options including custom error message
16
+ * @returns A property descriptor interceptor that enforces the maximum value constraint
17
+ * @throws {@link AssertionError} when the assigned value is greater than `max`
18
+ */
3
19
  export declare function AssertMax(max: number, options?: DescriptorAssertionOptions): (target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<number>) => void;
@@ -44,7 +44,7 @@ export type AuthClaimsUpdate<T extends AuthClaimsObject = AuthClaimsObject> = Pa
44
44
  */
45
45
  export type AuthRoleClaimsFactoryConfigEntry<V extends AuthClaimValue = AuthClaimValue> = V extends SimpleAuthClaimValue ? AuthRoleClaimsFactoryConfigEntryEncodeOptions<V> | AuthRoleClaimsFactoryConfigEntrySimpleOptions<V> : AuthRoleClaimsFactoryConfigEntryEncodeOptions<V>;
46
46
  /**
47
- *
47
+ * Simple configuration for a claims key that maps a claim value directly to one or more roles.
48
48
  */
49
49
  export interface AuthRoleClaimsFactoryConfigEntrySimpleOptions<V extends SimpleAuthClaimValue = SimpleAuthClaimValue> {
50
50
  /**
@@ -117,17 +117,23 @@ export interface AuthRoleClaimsService<T extends AuthClaimsObject> {
117
117
  export declare const AUTH_ROLE_CLAIMS_DEFAULT_CLAIM_VALUE = 1;
118
118
  export declare const AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE: null;
119
119
  /**
120
- * Creates a AuthRoleClaimsService using the input configuration.
120
+ * Creates an {@link AuthRoleClaimsService} that converts between {@link AuthRoleSet} and JWT-style claims objects.
121
+ *
122
+ * Each key in the config maps a claim key to role(s). Simple entries map a claim value to one or more roles,
123
+ * while encode/decode entries allow custom bidirectional conversion logic.
121
124
  *
122
- * @param config
123
- * @param defaults
124
- * @returns
125
+ * @param config - Mapping of claim keys to their role configuration entries (or null to ignore)
126
+ * @param defaults - Optional default values for claim presence and absence
127
+ * @returns A service with `toClaims` and `toRoles` conversion functions
125
128
  */
126
129
  export declare function authRoleClaimsService<T extends AuthClaimsObject>(config: AuthRoleClaimsFactoryConfig<T>, defaults?: AuthRoleClaimsFactoryDefaults): AuthRoleClaimsService<T>;
127
130
  /**
128
- * Converts an AuthClaimsUpdate to AuthClaims by removing all null keys.
131
+ * Converts an {@link AuthClaimsUpdate} to {@link AuthClaims} by stripping all null-valued keys.
132
+ *
133
+ * Useful for cleaning up a claims update before persisting or comparing, since update objects
134
+ * use `null` to indicate claim removal.
129
135
  *
130
- * @param authClaimsUpdate
131
- * @returns
136
+ * @param authClaimsUpdate - The claims update object potentially containing null values
137
+ * @returns A clean claims object with all null entries removed
132
138
  */
133
139
  export declare function authClaims<T extends AuthClaimsObject = AuthClaimsObject>(authClaimsUpdate: AuthClaimsUpdate<T>): AuthClaims<T>;