@dereekb/util 13.11.1 → 13.11.3

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 (102) hide show
  1. package/eslint/index.cjs.default.js +1 -0
  2. package/eslint/index.cjs.js +607 -0
  3. package/eslint/index.cjs.mjs +2 -0
  4. package/eslint/index.d.ts +1 -0
  5. package/eslint/index.esm.js +603 -0
  6. package/eslint/package.json +23 -0
  7. package/eslint/src/index.d.ts +1 -0
  8. package/eslint/src/lib/comments.d.ts +54 -0
  9. package/eslint/src/lib/index.d.ts +3 -0
  10. package/eslint/src/lib/plugin.d.ts +18 -0
  11. package/eslint/src/lib/prefer-no-side-effects-in-jsdoc.rule.d.ts +42 -0
  12. package/eslint/src/lib/require-no-side-effects.rule.d.ts +54 -0
  13. package/fetch/package.json +2 -2
  14. package/index.cjs.js +1203 -23
  15. package/index.esm.js +1203 -23
  16. package/package.json +7 -1
  17. package/src/lib/array/array.factory.d.ts +2 -0
  18. package/src/lib/array/array.filter.d.ts +50 -17
  19. package/src/lib/array/array.find.d.ts +1 -0
  20. package/src/lib/array/array.index.d.ts +7 -0
  21. package/src/lib/array/array.indexed.d.ts +21 -0
  22. package/src/lib/array/array.make.d.ts +7 -0
  23. package/src/lib/array/array.random.d.ts +1 -0
  24. package/src/lib/array/array.unique.d.ts +3 -0
  25. package/src/lib/array/array.value.d.ts +7 -0
  26. package/src/lib/auth/auth.role.claims.d.ts +7 -0
  27. package/src/lib/boolean.d.ts +1 -0
  28. package/src/lib/contact/random.d.ts +14 -0
  29. package/src/lib/date/date.d.ts +6 -0
  30. package/src/lib/date/time.d.ts +7 -0
  31. package/src/lib/date/week.d.ts +7 -0
  32. package/src/lib/error/error.d.ts +7 -0
  33. package/src/lib/filter/filter.d.ts +7 -0
  34. package/src/lib/function/function.boolean.d.ts +7 -0
  35. package/src/lib/function/function.forward.d.ts +14 -0
  36. package/src/lib/getter/getter.cache.d.ts +7 -0
  37. package/src/lib/getter/getter.d.ts +34 -0
  38. package/src/lib/getter/getter.map.d.ts +7 -0
  39. package/src/lib/getter/getter.util.d.ts +7 -0
  40. package/src/lib/grouping.d.ts +8 -0
  41. package/src/lib/hash.d.ts +1 -0
  42. package/src/lib/key.d.ts +16 -0
  43. package/src/lib/map/map.key.d.ts +14 -0
  44. package/src/lib/model/id.batch.d.ts +7 -0
  45. package/src/lib/model/id.factory.d.ts +7 -0
  46. package/src/lib/model/model.conversion.d.ts +35 -0
  47. package/src/lib/model/model.copy.d.ts +7 -0
  48. package/src/lib/model/model.d.ts +19 -0
  49. package/src/lib/model/model.modify.d.ts +14 -0
  50. package/src/lib/nodejs/stream.d.ts +7 -0
  51. package/src/lib/number/bound.d.ts +3 -0
  52. package/src/lib/number/dollar.d.ts +7 -0
  53. package/src/lib/number/factory.d.ts +7 -0
  54. package/src/lib/number/random.d.ts +1 -0
  55. package/src/lib/number/round.d.ts +22 -0
  56. package/src/lib/number/sort.d.ts +7 -0
  57. package/src/lib/number/transform.d.ts +7 -0
  58. package/src/lib/object/object.array.delta.d.ts +7 -0
  59. package/src/lib/object/object.equal.d.ts +7 -0
  60. package/src/lib/object/object.filter.pojo.d.ts +87 -0
  61. package/src/lib/object/object.filter.tuple.d.ts +16 -0
  62. package/src/lib/object/object.key.d.ts +14 -0
  63. package/src/lib/object/object.map.d.ts +14 -0
  64. package/src/lib/path/path.d.ts +9 -0
  65. package/src/lib/promise/promise.d.ts +21 -0
  66. package/src/lib/promise/promise.factory.d.ts +7 -0
  67. package/src/lib/promise/promise.task.d.ts +7 -0
  68. package/src/lib/service/handler.config.d.ts +28 -0
  69. package/src/lib/service/handler.d.ts +14 -0
  70. package/src/lib/set/set.d.ts +21 -0
  71. package/src/lib/set/set.decision.d.ts +7 -0
  72. package/src/lib/set/set.delta.d.ts +7 -0
  73. package/src/lib/set/set.selection.d.ts +7 -0
  74. package/src/lib/sort.d.ts +8 -0
  75. package/src/lib/string/char.d.ts +7 -0
  76. package/src/lib/string/dencoder.d.ts +35 -0
  77. package/src/lib/string/factory.d.ts +22 -1
  78. package/src/lib/string/replace.d.ts +78 -0
  79. package/src/lib/string/search.d.ts +7 -0
  80. package/src/lib/string/sort.d.ts +7 -0
  81. package/src/lib/string/string.d.ts +1 -0
  82. package/src/lib/string/transform.d.ts +53 -0
  83. package/src/lib/string/tree.d.ts +7 -0
  84. package/src/lib/string/url.d.ts +7 -0
  85. package/src/lib/tree/tree.array.d.ts +1 -0
  86. package/src/lib/tree/tree.explore.d.ts +3 -0
  87. package/src/lib/type.d.ts +3 -2
  88. package/src/lib/value/bound.d.ts +28 -0
  89. package/src/lib/value/comparator.d.ts +16 -0
  90. package/src/lib/value/decision.d.ts +5 -0
  91. package/src/lib/value/equal.d.ts +2 -0
  92. package/src/lib/value/indexed.d.ts +127 -0
  93. package/src/lib/value/map.d.ts +22 -0
  94. package/src/lib/value/maybe.type.d.ts +2 -2
  95. package/src/lib/value/modifier.d.ts +13 -0
  96. package/src/lib/value/point.d.ts +56 -0
  97. package/src/lib/value/use.d.ts +37 -0
  98. package/src/lib/value/vector.d.ts +7 -0
  99. package/test/index.cjs.js +17 -4
  100. package/test/index.esm.js +17 -4
  101. package/test/package.json +2 -2
  102. package/test/src/lib/shared/shared.fail.d.ts +24 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "13.11.1",
3
+ "version": "13.11.3",
4
4
  "sideEffects": false,
5
5
  "exports": {
6
6
  "./test": {
@@ -15,6 +15,12 @@
15
15
  "import": "./fetch/index.cjs.mjs",
16
16
  "default": "./fetch/index.cjs.js"
17
17
  },
18
+ "./eslint": {
19
+ "module": "./eslint/index.esm.js",
20
+ "types": "./eslint/index.d.ts",
21
+ "import": "./eslint/index.cjs.mjs",
22
+ "default": "./eslint/index.cjs.js"
23
+ },
18
24
  "./package.json": "./package.json",
19
25
  ".": {
20
26
  "module": "./index.esm.js",
@@ -29,6 +29,7 @@ export type AsyncArrayInputFactory<I, O> = AsyncMapFunction<ArrayInputFactory<I,
29
29
  *
30
30
  * @param factory - The factory function used to generate each item
31
31
  * @returns A function that takes a count parameter and returns an array of generated items
32
+ * @__NO_SIDE_EFFECTS__
32
33
  */
33
34
  export declare function arrayFactory<T>(factory: Factory<T> | FactoryWithIndex<T>): ArrayFactory<T>;
34
35
  /**
@@ -42,6 +43,7 @@ export declare function arrayFactory<T>(factory: Factory<T> | FactoryWithIndex<T
42
43
  *
43
44
  * @param factory - The factory function used to transform each input value
44
45
  * @returns A function that takes an array of input values and returns an array of output values
46
+ * @__NO_SIDE_EFFECTS__
45
47
  */
46
48
  export declare function arrayInputFactory<O, I>(factory: FactoryWithRequiredInput<O, I>): ArrayInputFactory<I, O>;
47
49
  /**
@@ -5,14 +5,16 @@ import { type AscendingSortCompareFunction } from '../sort';
5
5
  * Filters the input values by distance while maintaining the original order of elements.
6
6
  * Values that are too close to each other (based on the minDistance parameter) will be filtered out.
7
7
  *
8
+ * Items whose extracted value is null are excluded from the result.
9
+ *
8
10
  * If order is irrelevant, use filterValuesByDistanceNoOrder() instead.
9
11
  *
10
- * @param _input - The array of values to filter
11
- * @param _minDistance - The minimum distance required between values
12
- * @param _getValue - Function that extracts a numeric value from each item for distance comparison
13
- * @returns A filtered array with only values that are at least minDistance apart
12
+ * @param input - The array of values to filter
13
+ * @param minDistance - The minimum distance required between values (inclusive)
14
+ * @param getValue - Function that extracts a numeric value from each item for distance comparison
15
+ * @returns A filtered array with only values that are at least minDistance apart, in their original input order
14
16
  */
15
- export declare function filterValuesByDistance<T>(_input: T[], _minDistance: number, _getValue: (value: T) => number | null): T[];
17
+ export declare function filterValuesByDistance<T>(input: T[], minDistance: number, getValue: (value: T) => number | null): T[];
16
18
  /**
17
19
  * Filters the input values by an arbitrary "distance"/difference from each other and returns the values sorted by their determined distance.
18
20
  *
@@ -25,29 +27,53 @@ export declare function filterValuesByDistance<T>(_input: T[], _minDistance: num
25
27
  * @returns A filtered array with only values that are at least minDistance apart, sorted by the extracted value
26
28
  */
27
29
  export declare function filterValuesByDistanceNoOrder<T>(input: T[], minDistance: number, getValue: (value: T) => number | null): T[];
30
+ /**
31
+ * Strategy used by {@link applyBestFit} and {@link makeBestFit} to pick the best-fit item and transform the rest.
32
+ */
33
+ export interface BestFitConfig<T> {
34
+ /**
35
+ * Function that determines which items are candidates for the best fit.
36
+ */
37
+ readonly filter: (value: T) => boolean;
38
+ /**
39
+ * AscendingSortCompareFunction to compare two values to determine which is the best fit.
40
+ */
41
+ readonly compare: AscendingSortCompareFunction<T>;
42
+ /**
43
+ * Function that transforms non-best-fit items.
44
+ */
45
+ readonly updateNonBestFit: (value: T) => T;
46
+ }
28
47
  /**
29
48
  * Same as applyBestFit, but returns a new array, rather than modifying the existing array.
30
49
  *
31
- * @param input - The array to filter for the best fit
32
- * @param filter - Function that determines which items are candidates for the best fit
33
- * @param compare - AscendingSortCompareFunction to compare two values to determine which is the best fit
34
- * @param updateNonBestFit - Function that transforms non-best-fit items
35
- * @returns A new array with only the best fit item and transformed non-best-fit items
50
+ * @dbxUtil
51
+ * @dbxUtilCategory array
52
+ * @dbxUtilTags array, best-fit, filter, sort, immutable
53
+ * @dbxUtilRelated apply-best-fit, find-best-index-set-pair
54
+ *
55
+ * @param input - The array to filter for the best fit.
56
+ * @param config - The best-fit strategy ({@link BestFitConfig}).
57
+ * @returns A new array with only the best fit item and transformed non-best-fit items.
58
+ * @__NO_SIDE_EFFECTS__
36
59
  */
37
- export declare function makeBestFit<T>(input: T[], filter: (value: T) => boolean, compare: AscendingSortCompareFunction<T>, updateNonBestFit: (value: T) => T): T[];
60
+ export declare function makeBestFit<T>(input: T[], config: BestFitConfig<T>): T[];
38
61
  /**
39
62
  * Used for updating an array so that a single element becomes the "best fit" in whatever context is provided.
40
63
  *
41
64
  * For instance, if two items are selected but only one can be selected by design, this function can be used to
42
65
  * pick the best fit, and update the input array.
43
66
  *
44
- * @param input - The array to modify in-place
45
- * @param filter - Function that determines which items are candidates for the best fit
46
- * @param compare - AscendingSortCompareFunction to compare two values to determine which is the best fit
47
- * @param updateNonBestFit - Function that transforms non-best-fit items
48
- * @returns The modified input array with only the best fit item and transformed non-best-fit items
67
+ * @dbxUtil
68
+ * @dbxUtilCategory array
69
+ * @dbxUtilTags array, best-fit, filter, sort, mutable, in-place
70
+ * @dbxUtilRelated make-best-fit, find-best-index-set-pair
71
+ *
72
+ * @param input - The array to modify in-place.
73
+ * @param config - The best-fit strategy ({@link BestFitConfig}).
74
+ * @returns The modified input array with only the best fit item and transformed non-best-fit items.
49
75
  */
50
- export declare function applyBestFit<T>(input: T[], filter: (value: T) => boolean, compare: AscendingSortCompareFunction<T>, updateNonBestFit: (value: T) => T): T[];
76
+ export declare function applyBestFit<T>(input: T[], config: BestFitConfig<T>): T[];
51
77
  /**
52
78
  * Filters and maps the input values to an array.
53
79
  * Combines filtering and mapping operations into a single pass over the data.
@@ -57,8 +83,15 @@ export type FilterAndMapFunction<I, O> = MapFunction<Iterable<I>, O[]>;
57
83
  * Creates a function that filters the input values and maps all matching values to a new value.
58
84
  * This is a higher-order function that combines filtering and mapping operations.
59
85
  *
86
+ * @dbxUtil
87
+ * @dbxUtilCategory array
88
+ * @dbxUtilKind factory
89
+ * @dbxUtilTags array, filter, map, transform, factory, iterable
90
+ * @dbxUtilRelated array-decision-function
91
+ *
60
92
  * @param decisionFunction - Function that determines which items to include in the result
61
93
  * @param mapFunction - Function that transforms each included item
62
94
  * @returns A function that takes an iterable of input values and returns an array of transformed values
95
+ * @__NO_SIDE_EFFECTS__
63
96
  */
64
97
  export declare function filterAndMapFunction<I, O>(decisionFunction: DecisionFunction<I>, mapFunction: MapFunction<I, O>): FilterAndMapFunction<I, O>;
@@ -22,6 +22,7 @@ export type ArrayDecisionFunction<T> = (values: T[]) => boolean;
22
22
  * @param decision - Predicate used to test individual elements.
23
23
  * @param mode - Whether all or any elements must satisfy the predicate.
24
24
  * @returns A function that evaluates an array against the configured decision criteria.
25
+ * @__NO_SIDE_EFFECTS__
25
26
  */
26
27
  export declare function arrayDecisionFunction<T>(decision: ArrayFindDecisionFunction<T>, mode: SetIncludesMode): ArrayDecisionFunction<T>;
27
28
  /**
@@ -67,7 +67,14 @@ export type SliceIndexRangeFunction<T> = (input: T[]) => T[];
67
67
  /**
68
68
  * Creates a {@link SliceIndexRangeFunction} that slices the specified index range from any input array.
69
69
  *
70
+ * @dbxUtil
71
+ * @dbxUtilCategory array
72
+ * @dbxUtilKind factory
73
+ * @dbxUtilTags array, slice, index, range, factory
74
+ * @dbxUtilRelated index-range, find-to-index-set
75
+ *
70
76
  * @param inputRange - the index range configuration to use for slicing
71
77
  * @returns a function that slices the configured range from an input array
78
+ * @__NO_SIDE_EFFECTS__
72
79
  */
73
80
  export declare function sliceIndexRangeFunction<T>(inputRange: IndexRangeInput): SliceIndexRangeFunction<T>;
@@ -46,8 +46,15 @@ export type RangedIndexedValuesArrayAccessorFactory<T> = (values: T[]) => Ranged
46
46
  *
47
47
  * Each accessor maps an index to the value whose range contains that index, or undefined if no range matches.
48
48
  *
49
+ * @dbxUtil
50
+ * @dbxUtilCategory array
51
+ * @dbxUtilKind factory
52
+ * @dbxUtilTags array, indexed, range, accessor, factory, lookup
53
+ * @dbxUtilRelated indexed-values-array-accessor-factory, ranged-indexed-values-array-accessor-info-factory
54
+ *
49
55
  * @param readIndexRange - Function that reads the index range from each value.
50
56
  * @returns A factory that creates ranged accessors from arrays of values.
57
+ * @__NO_SIDE_EFFECTS__
51
58
  */
52
59
  export declare function rangedIndexedValuesArrayAccessorFactory<T>(readIndexRange: ReadIndexRangeFunction<T>): RangedIndexedValuesArrayAccessorFactory<T>;
53
60
  /**
@@ -64,9 +71,16 @@ export type IndexedValuesArrayAccessorFactory<T> = (values: T[]) => IndexedValue
64
71
  * Each accessor maps an index to the matching value, falling back to the previous value, then the next value.
65
72
  * This guarantees a value is always returned.
66
73
  *
74
+ * @dbxUtil
75
+ * @dbxUtilCategory array
76
+ * @dbxUtilKind factory
77
+ * @dbxUtilTags array, indexed, range, accessor, factory, fallback
78
+ * @dbxUtilRelated ranged-indexed-values-array-accessor-factory, ranged-indexed-values-array-accessor-info-factory
79
+ *
67
80
  * @param readIndexRange - Function that reads the index range from each value.
68
81
  * @returns A factory that creates indexed accessors from arrays of values.
69
82
  * @throws Error if the provided values array is empty.
83
+ * @__NO_SIDE_EFFECTS__
70
84
  */
71
85
  export declare function indexedValuesArrayAccessorFactory<T>(readIndexRange: ReadIndexRangeFunction<T>): IndexedValuesArrayAccessorFactory<T>;
72
86
  /**
@@ -109,7 +123,14 @@ export interface RangedIndexedValuesArrayInfoAccessorFactoryConfig<T> {
109
123
  * Each accessor sorts the values by their index ranges in ascending order, then for a given index
110
124
  * returns the matching value along with its previous and next neighbors.
111
125
  *
126
+ * @dbxUtil
127
+ * @dbxUtilCategory array
128
+ * @dbxUtilKind factory
129
+ * @dbxUtilTags array, indexed, range, accessor, info, factory, neighbors
130
+ * @dbxUtilRelated ranged-indexed-values-array-accessor-factory, indexed-values-array-accessor-factory
131
+ *
112
132
  * @param config - Configuration containing the index range reader function.
113
133
  * @returns A factory that creates ranged info accessors from arrays of values.
134
+ * @__NO_SIDE_EFFECTS__
114
135
  */
115
136
  export declare function rangedIndexedValuesArrayAccessorInfoFactory<T>(config: RangedIndexedValuesArrayInfoAccessorFactoryConfig<T>): RangedIndexedValuesArrayInfoAccessorFactory<T>;
@@ -23,7 +23,14 @@ export type RandomArrayFactory<T> = FactoryWithInput<T[], number>;
23
23
  /**
24
24
  * Creates a factory function that generates arrays of a random length populated with items from a make function.
25
25
  *
26
+ * @dbxUtil
27
+ * @dbxUtilCategory array
28
+ * @dbxUtilKind factory
29
+ * @dbxUtilTags array, random, factory, generate, make
30
+ * @dbxUtilRelated array-factory, random-number-factory
31
+ *
26
32
  * @param config - configuration containing the make function and random number source
27
33
  * @returns a factory that produces arrays of random length, optionally accepting a specific count override
34
+ * @__NO_SIDE_EFFECTS__
28
35
  */
29
36
  export declare function randomArrayFactory<T>(config: RandomArrayFactoryConfig<T>): RandomArrayFactory<T>;
@@ -20,6 +20,7 @@ export type RandomPickFactory<T> = (() => T) & {
20
20
  * @param values - array of values to randomly pick from
21
21
  * @returns a callable factory that returns a random value from the array on each invocation
22
22
  * @throws Error if the input array is empty
23
+ * @__NO_SIDE_EFFECTS__
23
24
  */
24
25
  export declare function randomPickFactory<T>(values: T[]): RandomPickFactory<T>;
25
26
  /**
@@ -87,6 +87,7 @@ export declare function readKeysFromFilterUniqueFunctionAdditionalKeys<T, K exte
87
87
  * @param readKey - Function to extract a unique key from each item.
88
88
  * @param additionalKeysInput - Optional keys or values to pre-seed as already seen, causing them to be excluded.
89
89
  * @returns A reusable filter function that removes duplicate items from arrays.
90
+ * @__NO_SIDE_EFFECTS__
90
91
  */
91
92
  export declare function filterUniqueFunction<T, K extends PrimativeKey = PrimativeKey>(readKey: ReadKeyFunction<T, K>, additionalKeysInput?: FilterUniqueFunctionAdditionalKeysInput<T, K>): FilterUniqueFunction<T, K>;
92
93
  /**
@@ -118,6 +119,7 @@ export type IsUniqueKeyedFunction<T> = DecisionFunction<T[]>;
118
119
  *
119
120
  * @param readKey - Function to extract a unique key from each item.
120
121
  * @returns A decision function that returns true if all items have distinct keys.
122
+ * @__NO_SIDE_EFFECTS__
121
123
  */
122
124
  export declare function isUniqueKeyedFunction<T, K extends PrimativeKey = PrimativeKey>(readKey: ReadKeyFunction<T, K>): IsUniqueKeyedFunction<T>;
123
125
  /**
@@ -144,6 +146,7 @@ export type AllowValueOnceFilter<T, K extends PrimativeKey = PrimativeKey> = Dec
144
146
  *
145
147
  * @param inputReadKey - Optional function to extract a key from each value. Defaults to identity.
146
148
  * @returns A stateful filter function that returns true only for the first occurrence of each key.
149
+ * @__NO_SIDE_EFFECTS__
147
150
  */
148
151
  export declare function allowValueOnceFilter<T extends PrimativeKey = PrimativeKey>(): AllowValueOnceFilter<T, T>;
149
152
  export declare function allowValueOnceFilter<T, K extends PrimativeKey = PrimativeKey>(readKey?: ReadKeyFunction<T, K>): AllowValueOnceFilter<T, K>;
@@ -10,8 +10,15 @@ export type UniversalFilterMaybeArrayFunction = <T>(values: Maybe<Maybe<T>[]>) =
10
10
  /**
11
11
  * Creates a {@link FilterMaybeArrayFunction} that filters maybe values from an array using the provided filter function.
12
12
  *
13
+ * @dbxUtil
14
+ * @dbxUtilCategory array
15
+ * @dbxUtilKind factory
16
+ * @dbxUtilTags array, filter, maybe, factory, predicate
17
+ * @dbxUtilRelated filter-maybe-array-values
18
+ *
13
19
  * @param filterFn - Filter predicate used to determine which values to keep.
14
20
  * @returns A function that filters maybe values from an optional input array.
21
+ * @__NO_SIDE_EFFECTS__
15
22
  */
16
23
  export declare function filterMaybeArrayFunction<T>(filterFn: Parameters<Array<Maybe<T>>['filter']>[0]): FilterMaybeArrayFunction<T>;
17
24
  /**
@@ -127,9 +127,16 @@ export declare const AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE: null;
127
127
  * Each key in the config maps a claim key to role(s). Simple entries map a claim value to one or more roles,
128
128
  * while encode/decode entries allow custom bidirectional conversion logic.
129
129
  *
130
+ * @dbxUtil
131
+ * @dbxUtilCategory auth
132
+ * @dbxUtilKind factory
133
+ * @dbxUtilTags auth, role, claims, jwt, factory, bidirectional
134
+ * @dbxUtilRelated auth-role
135
+ *
130
136
  * @param config - Mapping of claim keys to their role configuration entries (or null to ignore)
131
137
  * @param defaults - Optional default values for claim presence and absence
132
138
  * @returns A service with `toClaims` and `toRoles` conversion functions
139
+ * @__NO_SIDE_EFFECTS__
133
140
  */
134
141
  export declare function authRoleClaimsService<T extends AuthClaimsObject>(config: AuthRoleClaimsFactoryConfig<T>, defaults?: AuthRoleClaimsFactoryDefaults): AuthRoleClaimsService<T>;
135
142
  /**
@@ -154,6 +154,7 @@ export interface BooleanFactoryConfig {
154
154
  * const coinFlip = booleanFactory({ chance: 50 });
155
155
  * coinFlip(); // true or false with equal probability
156
156
  * ```
157
+ * @__NO_SIDE_EFFECTS__
157
158
  */
158
159
  export declare function booleanFactory(config: BooleanFactoryConfig): BooleanFactory;
159
160
  /**
@@ -29,8 +29,15 @@ export type RandomEmailFactory = Factory<EmailAddress>;
29
29
  /**
30
30
  * Creates a factory that generates random email addresses using configurable prefixes, domains, and number generators.
31
31
  *
32
+ * @dbxUtil
33
+ * @dbxUtilCategory contact
34
+ * @dbxUtilKind factory
35
+ * @dbxUtilTags contact, email, random, factory, generate
36
+ * @dbxUtilRelated random-phone-number-factory, incrementing-number-factory
37
+ *
32
38
  * @param inputConfig - Optional configuration overrides
33
39
  * @returns A factory function that produces random email address strings
40
+ * @__NO_SIDE_EFFECTS__
34
41
  */
35
42
  export declare function randomEmailFactory(inputConfig?: RandomEmailFactoryConfig): RandomEmailFactory;
36
43
  /**
@@ -54,7 +61,14 @@ export type RandomPhoneNumberFactory = Factory<E164PhoneNumber>;
54
61
  /**
55
62
  * Creates a factory that generates random E.164 phone numbers using configurable area codes and number generators.
56
63
  *
64
+ * @dbxUtil
65
+ * @dbxUtilCategory contact
66
+ * @dbxUtilKind factory
67
+ * @dbxUtilTags contact, phone, e164, random, factory, generate
68
+ * @dbxUtilRelated random-email-factory, random-number-factory
69
+ *
57
70
  * @param inputConfig - Optional configuration overrides
58
71
  * @returns A factory function that produces random E.164 phone number strings
72
+ * @__NO_SIDE_EFFECTS__
59
73
  */
60
74
  export declare function randomPhoneNumberFactory(inputConfig?: RandomPhoneNumberFactoryConfig): RandomPhoneNumberFactory;
@@ -419,8 +419,14 @@ export declare function monthOfYearFromDateMonth(dateMonth: DateMonth): MonthOfY
419
419
  /**
420
420
  * Converts a MonthOfYear (1-12) to a JavaScript Date month (0-11).
421
421
  *
422
+ * @dbxUtil
423
+ * @dbxUtilCategory date
424
+ * @dbxUtilTags date, month, convert, javascript
425
+ * @dbxUtilRelated month-of-year-from-date-month
426
+ *
422
427
  * @param monthOfYear - Month of year (1-12)
423
428
  * @returns JavaScript Date month (0-11)
429
+ * @__NO_SIDE_EFFECTS__
424
430
  */
425
431
  export declare function makeDateMonthForMonthOfYear(monthOfYear: MonthOfYear): DateMonth;
426
432
  /**
@@ -104,9 +104,16 @@ export declare class TimerCancelledError extends BaseError {
104
104
  /**
105
105
  * Creates a new Timer from the input duration.
106
106
  *
107
+ * @dbxUtil
108
+ * @dbxUtilCategory date
109
+ * @dbxUtilKind factory
110
+ * @dbxUtilTags date, time, timer, factory, duration
111
+ * @dbxUtilRelated timer
112
+ *
107
113
  * @param duration - The duration of the timer.
108
114
  * @param startImmediately - Whether the timer should start immediately. Defaults to true.
109
115
  * @returns The new Timer.
116
+ * @__NO_SIDE_EFFECTS__
110
117
  */
111
118
  export declare function makeTimer(duration: Milliseconds, startImmediately?: boolean): Timer;
112
119
  /**
@@ -118,8 +118,15 @@ export type DayOfWeekNameFunction = (dayOfWeek: DayOfWeek) => string;
118
118
  /**
119
119
  * Creates a function that returns the name for a given DayOfWeek.
120
120
  *
121
+ * @dbxUtil
122
+ * @dbxUtilCategory date
123
+ * @dbxUtilKind factory
124
+ * @dbxUtilTags date, week, day-of-week, name, factory, format
125
+ * @dbxUtilRelated days-of-week-name-map
126
+ *
121
127
  * @param transform - Optional configuration for abbreviation and casing
122
128
  * @returns A function that maps DayOfWeek values to name strings
129
+ * @__NO_SIDE_EFFECTS__
123
130
  */
124
131
  export declare function daysOfWeekNameFunction(transform?: DayOfWeekNamesTransformConfig): DayOfWeekNameFunction;
125
132
  /**
@@ -90,8 +90,15 @@ export type ErrorMessageContainsStringFunction = (input: Maybe<ErrorInput | stri
90
90
  /**
91
91
  * Creates a function that checks if an error's message contains the target string.
92
92
  *
93
+ * @dbxUtil
94
+ * @dbxUtilCategory error
95
+ * @dbxUtilKind factory
96
+ * @dbxUtilTags error, message, contains, factory, predicate, regex
97
+ * @dbxUtilRelated escape-string-for-regex
98
+ *
93
99
  * @param target - The string to search for
94
100
  * @returns A function that checks error messages for the target string
101
+ * @__NO_SIDE_EFFECTS__
95
102
  */
96
103
  export declare function errorMessageContainsStringFunction(target: string): ErrorMessageContainsStringFunction;
97
104
  /**
@@ -18,8 +18,15 @@ export type FilterFunction<T = unknown> = (value: T, index: number) => boolean;
18
18
  * The merged function returns true only if all individual filters pass (AND logic).
19
19
  * Null/undefined filters are ignored.
20
20
  *
21
+ * @dbxUtil
22
+ * @dbxUtilCategory value
23
+ * @dbxUtilKind factory
24
+ * @dbxUtilTags filter, merge, compose, factory, and
25
+ * @dbxUtilRelated invert-filter, invert-boolean-return-function
26
+ *
21
27
  * @param inputFilters - The filter functions to merge
22
28
  * @returns A single FilterFunction that applies all filters
29
+ * @__NO_SIDE_EFFECTS__
23
30
  */
24
31
  export declare function mergeFilterFunctions<T>(...inputFilters: Maybe<FilterFunction<T>>[]): FilterFunction<T>;
25
32
  /**
@@ -5,8 +5,15 @@ export type BooleanReturnFunction = (...args: any[]) => boolean;
5
5
  /**
6
6
  * Inverts the output of an arbitrary boolean-returning function.
7
7
  *
8
+ * @dbxUtil
9
+ * @dbxUtilCategory function
10
+ * @dbxUtilKind factory
11
+ * @dbxUtilTags function, boolean, invert, predicate, factory
12
+ * @dbxUtilRelated decision-function, filter-function
13
+ *
8
14
  * @param decisionFn - The function whose boolean return value to invert
9
15
  * @param invert - Whether to apply the inversion (defaults to true)
10
16
  * @returns The inverted function, or the original if invert is false
17
+ * @__NO_SIDE_EFFECTS__
11
18
  */
12
19
  export declare function invertBooleanReturnFunction<F extends BooleanReturnFunction>(decisionFn: F, invert?: boolean): F;
@@ -10,8 +10,15 @@ export type ForwardFunction<I extends (...args: any[]) => O, O = unknown> = I;
10
10
  *
11
11
  * Useful for late-binding or circular dependency resolution.
12
12
  *
13
+ * @dbxUtil
14
+ * @dbxUtilCategory function
15
+ * @dbxUtilKind factory
16
+ * @dbxUtilTags function, forward, late-binding, factory, lazy
17
+ * @dbxUtilRelated default-forward-function-factory
18
+ *
13
19
  * @param getter - A Getter that provides the target function
14
20
  * @returns A forwarding function with the same signature as the target
21
+ * @__NO_SIDE_EFFECTS__
15
22
  */
16
23
  export declare function forwardFunction<I extends (...args: any[]) => O, O = unknown>(getter: Getter<I>): ForwardFunction<I>;
17
24
  /**
@@ -22,7 +29,14 @@ export type DefaultForwardFunctionFactory<I extends (...args: any[]) => O, O = u
22
29
  * Creates a factory that produces forwarding functions which use the provided function
23
30
  * or fall back to the default function when not provided.
24
31
  *
32
+ * @dbxUtil
33
+ * @dbxUtilCategory function
34
+ * @dbxUtilKind factory
35
+ * @dbxUtilTags function, forward, factory, default, fallback
36
+ * @dbxUtilRelated forward-function
37
+ *
25
38
  * @param defaultFn - The default function to use as fallback
26
39
  * @returns A factory that wraps optional functions with a default fallback
40
+ * @__NO_SIDE_EFFECTS__
27
41
  */
28
42
  export declare function defaultForwardFunctionFactory<I extends (...args: any[]) => O, O = unknown>(defaultFn: I): DefaultForwardFunctionFactory<I, O>;
@@ -39,8 +39,15 @@ export type CachedFactoryWithInput<T, A = unknown> = CachedGetter<T> & FactoryWi
39
39
  * The value is retrieved once on first call and cached permanently.
40
40
  * Use `reset()` to clear the cache and `init()` to reload.
41
41
  *
42
+ * @dbxUtil
43
+ * @dbxUtilCategory getter
44
+ * @dbxUtilKind factory
45
+ * @dbxUtilTags getter, cache, memoize, lazy, factory
46
+ * @dbxUtilRelated as-getter, make-getter
47
+ *
42
48
  * @param getter - the factory or getter function whose result will be cached
43
49
  * @returns A CachedFactoryWithInput that caches the first result
50
+ * @__NO_SIDE_EFFECTS__
44
51
  */
45
52
  export declare function cachedGetter<T>(getter: Getter<T>): CachedFactoryWithInput<T>;
46
53
  export declare function cachedGetter<T, A = unknown>(factory: FactoryWithInput<T, A>): CachedFactoryWithInput<T, A>;
@@ -100,22 +100,37 @@ export type ObjectCopyFactory<T> = Factory<T>;
100
100
  * @param value - The object to copy
101
101
  * @param copyFunction - Optional custom copy function (defaults to copyObject)
102
102
  * @returns A factory that produces copies of the value
103
+ * @__NO_SIDE_EFFECTS__
103
104
  */
104
105
  export declare function objectCopyFactory<T extends object>(value: T, copyFunction?: CopyObjectFunction<T>): ObjectCopyFactory<T>;
105
106
  /**
106
107
  * Converts the input to an ObjectCopyFactory. If the input is an object, wraps it with objectCopyFactory.
107
108
  * If it's already a function (Getter), it's returned directly.
108
109
  *
110
+ * @dbxUtil
111
+ * @dbxUtilCategory getter
112
+ * @dbxUtilKind factory
113
+ * @dbxUtilTags getter, factory, copy, clone, object, normalize
114
+ * @dbxUtilRelated object-copy-factory, as-getter
115
+ *
109
116
  * @param input - An object value or a getter function
110
117
  * @param copyFunction - Optional custom copy function
111
118
  * @returns An ObjectCopyFactory for the input
119
+ * @__NO_SIDE_EFFECTS__
112
120
  */
113
121
  export declare function asObjectCopyFactory<T>(input: T | ObjectCopyFactory<T>, copyFunction?: CopyObjectFunction<T>): ObjectCopyFactory<T>;
114
122
  /**
115
123
  * Wraps the input value in a Getter function that always returns it.
116
124
  *
125
+ * @dbxUtil
126
+ * @dbxUtilCategory getter
127
+ * @dbxUtilKind factory
128
+ * @dbxUtilTags getter, factory, wrap, constant
129
+ * @dbxUtilRelated as-getter, get-value-from-getter
130
+ *
117
131
  * @param input - The value to wrap
118
132
  * @returns A Getter that returns the input value
133
+ * @__NO_SIDE_EFFECTS__
119
134
  */
120
135
  export declare function makeGetter<T>(input: T): Getter<T>;
121
136
  /**
@@ -125,17 +140,29 @@ export type FactoryWithIndex<T> = FactoryWithInput<T, number> | FactoryWithRequi
125
140
  /**
126
141
  * Calls a factory function the specified number of times and returns the results as an array.
127
142
  *
143
+ * @dbxUtil
144
+ * @dbxUtilCategory getter
145
+ * @dbxUtilTags getter, factory, generate, array, count
146
+ * @dbxUtilRelated make-with-factory-input, array-factory
147
+ *
128
148
  * @param factory - The factory function to call (receives the current index as argument)
129
149
  * @param count - The number of items to create
130
150
  * @returns An array of produced values
151
+ * @__NO_SIDE_EFFECTS__
131
152
  */
132
153
  export declare function makeWithFactory<T>(factory: Factory<T> | FactoryWithIndex<T>, count: number): T[];
133
154
  /**
134
155
  * Maps an array of inputs through a factory function to produce an array of outputs.
135
156
  *
157
+ * @dbxUtil
158
+ * @dbxUtilCategory getter
159
+ * @dbxUtilTags getter, factory, map, array, transform
160
+ * @dbxUtilRelated make-with-factory
161
+ *
136
162
  * @param factory - The factory function to call with each input
137
163
  * @param input - The array of inputs to pass to the factory
138
164
  * @returns An array of produced values
165
+ * @__NO_SIDE_EFFECTS__
139
166
  */
140
167
  export declare function makeWithFactoryInput<T, A>(factory: FactoryWithInput<T, A>, input: Maybe<A>[]): T[];
141
168
  export declare function makeWithFactoryInput<T, A>(factory: FactoryWithRequiredInput<T, A>, input: A[]): T[];
@@ -143,7 +170,14 @@ export declare function makeWithFactoryInput<T, A>(factory: FactoryWithRequiredI
143
170
  * Wraps a factory so that no arguments are forwarded when it's called.
144
171
  * Useful for protecting a factory from accidentally receiving arguments.
145
172
  *
173
+ * @dbxUtil
174
+ * @dbxUtilCategory getter
175
+ * @dbxUtilKind factory
176
+ * @dbxUtilTags getter, factory, protect, wrap, no-args
177
+ * @dbxUtilRelated as-getter, make-getter
178
+ *
146
179
  * @param factory - The factory to wrap
147
180
  * @returns A new factory that calls the original with no arguments
181
+ * @__NO_SIDE_EFFECTS__
148
182
  */
149
183
  export declare function protectedFactory<T>(factory: Factory<T>): Factory<T>;
@@ -15,7 +15,14 @@ export declare function mapGetter<I, O>(input: Getter<I>, mapFn: MapFunction<I,
15
15
  /**
16
16
  * Creates a factory that wraps Getters with a mapping function.
17
17
  *
18
+ * @dbxUtil
19
+ * @dbxUtilCategory getter
20
+ * @dbxUtilKind factory
21
+ * @dbxUtilTags getter, map, transform, factory
22
+ * @dbxUtilRelated map-getter
23
+ *
18
24
  * @param mapFn - The mapping function to apply
19
25
  * @returns A factory that transforms Getters of type I to Getters of type O
26
+ * @__NO_SIDE_EFFECTS__
20
27
  */
21
28
  export declare function mapGetterFactory<I, O>(mapFn: MapFunction<I, O>): MapGetterFactory<I, O>;
@@ -6,7 +6,14 @@ export type RandomFromArrayFactory<T> = Factory<T>;
6
6
  /**
7
7
  * Creates a factory that returns a random element from the given array on each call.
8
8
  *
9
+ * @dbxUtil
10
+ * @dbxUtilCategory getter
11
+ * @dbxUtilKind factory
12
+ * @dbxUtilTags getter, factory, random, array, sample
13
+ * @dbxUtilRelated random-number-factory, random-array-factory
14
+ *
9
15
  * @param values - The array of values to randomly select from
10
16
  * @returns A factory that returns a random element from the array
17
+ * @__NO_SIDE_EFFECTS__
11
18
  */
12
19
  export declare function randomFromArrayFactory<T>(values: T[]): RandomFromArrayFactory<T>;
@@ -183,9 +183,15 @@ export declare function pairGroupValues<T, K extends PrimativeKey = PrimativeKey
183
183
  /**
184
184
  * Creates an array of `[key, value]` tuples by extracting a key from each value.
185
185
  *
186
+ * @dbxUtil
187
+ * @dbxUtilCategory grouping
188
+ * @dbxUtilTags grouping, key, pairs, tuple, array
189
+ * @dbxUtilRelated group-values, make-values-group-map
190
+ *
186
191
  * @param values - Values to create key pairs from.
187
192
  * @param keyFn - Extracts the key from each value.
188
193
  * @returns An array of `[key, value]` tuples.
194
+ * @__NO_SIDE_EFFECTS__
189
195
  */
190
196
  export declare function makeKeyPairs<T, K extends string | number = string | number>(values: T[], keyFn: ReadKeyFunction<T, K>): [Maybe<K>, T][];
191
197
  /**
@@ -235,6 +241,8 @@ export declare function groupValues<T, K extends PrimativeKey = PrimativeKey>(va
235
241
  * const map = makeValuesGroupMap(items, (x) => x.type);
236
242
  * // Map { 'a' => [{ type: 'a', v: 1 }, { type: 'a', v: 3 }], 'b' => [{ type: 'b', v: 2 }] }
237
243
  * ```
244
+ *
245
+ * @__NO_SIDE_EFFECTS__
238
246
  */
239
247
  export declare function makeValuesGroupMap<T, K extends PrimativeKey = PrimativeKey>(values: T[], groupKeyFn: ReadKeyFunction<T, K>): Map<Maybe<K>, T[]>;
240
248
  export declare function makeValuesGroupMap<T, K extends PrimativeKey = PrimativeKey>(values: Maybe<T[]>, groupKeyFn: ReadKeyFunction<T, K>): Map<Maybe<K>, T[]>;
package/src/lib/hash.d.ts CHANGED
@@ -46,6 +46,7 @@ export declare function decodeHashedValues(hashedValues: string[], decodeValues:
46
46
  * @param decodeValues - An array of potential original string values.
47
47
  * @param hashFn - A function that takes a string and returns its hashed representation.
48
48
  * @returns A {@link HashDecodeMap} for decoding hashed values.
49
+ * @__NO_SIDE_EFFECTS__
49
50
  */
50
51
  export declare function makeHashDecodeMap(decodeValues: string[], hashFn: (value: string) => string): HashDecodeMap;
51
52
  /**