@dereekb/util 13.3.1 → 13.4.1

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 (82) hide show
  1. package/fetch/index.cjs.js +191 -109
  2. package/fetch/index.esm.js +191 -109
  3. package/fetch/package.json +2 -2
  4. package/fetch/src/lib/error.d.ts +6 -0
  5. package/fetch/src/lib/fetch.d.ts +37 -0
  6. package/fetch/src/lib/fetch.file.d.ts +7 -5
  7. package/fetch/src/lib/fetch.limit.d.ts +7 -0
  8. package/fetch/src/lib/fetch.url.d.ts +6 -3
  9. package/fetch/src/lib/json.d.ts +12 -1
  10. package/fetch/src/lib/timeout.d.ts +8 -0
  11. package/fetch/src/lib/url.d.ts +33 -0
  12. package/index.cjs.js +1561 -787
  13. package/index.esm.js +1560 -788
  14. package/package.json +1 -1
  15. package/src/lib/array/array.boolean.d.ts +7 -0
  16. package/src/lib/array/array.filter.d.ts +4 -4
  17. package/src/lib/array/array.index.d.ts +3 -1
  18. package/src/lib/array/array.indexed.d.ts +9 -3
  19. package/src/lib/array/array.limit.d.ts +2 -0
  20. package/src/lib/assertion/assert.d.ts +3 -0
  21. package/src/lib/assertion/assert.error.d.ts +6 -0
  22. package/src/lib/boolean.d.ts +3 -0
  23. package/src/lib/date/expires.d.ts +3 -3
  24. package/src/lib/date/minute.d.ts +14 -8
  25. package/src/lib/date/time.d.ts +3 -0
  26. package/src/lib/error/error.server.d.ts +1 -0
  27. package/src/lib/file/pdf.d.ts +1 -1
  28. package/src/lib/getter/getter.cache.d.ts +1 -1
  29. package/src/lib/grouping.d.ts +11 -2
  30. package/src/lib/map/map.key.d.ts +1 -1
  31. package/src/lib/model/model.d.ts +14 -9
  32. package/src/lib/number/dollar.d.ts +8 -0
  33. package/src/lib/number/number.d.ts +4 -0
  34. package/src/lib/object/index.d.ts +1 -0
  35. package/src/lib/object/object.equal.d.ts +2 -2
  36. package/src/lib/object/object.filter.pojo.d.ts +7 -0
  37. package/src/lib/object/object.filter.tuple.d.ts +2 -0
  38. package/src/lib/object/object.flatten.d.ts +43 -0
  39. package/src/lib/object/object.map.d.ts +1 -1
  40. package/src/lib/path/path.d.ts +4 -2
  41. package/src/lib/promise/poll.d.ts +3 -0
  42. package/src/lib/promise/promise.d.ts +19 -7
  43. package/src/lib/promise/promise.loop.d.ts +27 -9
  44. package/src/lib/relation/relation.d.ts +12 -0
  45. package/src/lib/service/handler.config.d.ts +3 -1
  46. package/src/lib/service/handler.d.ts +6 -2
  47. package/src/lib/service/typed.service.d.ts +3 -1
  48. package/src/lib/set/set.d.ts +32 -19
  49. package/src/lib/set/set.hashset.d.ts +3 -1
  50. package/src/lib/sort.d.ts +11 -0
  51. package/src/lib/storage/storage.error.d.ts +3 -0
  52. package/src/lib/storage/storage.memory.d.ts +7 -0
  53. package/src/lib/storage/storage.object.d.ts +5 -0
  54. package/src/lib/string/dencoder.d.ts +4 -1
  55. package/src/lib/string/mimetype.d.ts +57 -19
  56. package/src/lib/string/transform.d.ts +10 -1
  57. package/src/lib/string/tree.d.ts +18 -6
  58. package/src/lib/string/url.d.ts +57 -19
  59. package/src/lib/tree/tree.d.ts +12 -4
  60. package/src/lib/tree/tree.flatten.d.ts +3 -1
  61. package/src/lib/value/address.d.ts +24 -7
  62. package/src/lib/value/bound.d.ts +3 -0
  63. package/src/lib/value/build.d.ts +3 -0
  64. package/src/lib/value/comparator.d.ts +4 -0
  65. package/src/lib/value/cron.d.ts +1 -0
  66. package/src/lib/value/decision.d.ts +3 -0
  67. package/src/lib/value/equal.d.ts +3 -0
  68. package/src/lib/value/indexed.d.ts +4 -0
  69. package/src/lib/value/label.d.ts +1 -0
  70. package/src/lib/value/map.d.ts +9 -0
  71. package/src/lib/value/maybe.d.ts +13 -0
  72. package/src/lib/value/modifier.d.ts +9 -0
  73. package/src/lib/value/point.d.ts +3 -0
  74. package/src/lib/value/url.d.ts +1 -0
  75. package/src/lib/value/vector.d.ts +5 -0
  76. package/test/index.cjs.js +29 -6
  77. package/test/index.esm.js +29 -6
  78. package/test/package.json +2 -2
  79. package/test/src/lib/jest/jest.fail.d.ts +3 -3
  80. package/test/src/lib/shared/shared.d.ts +7 -1
  81. package/test/src/lib/shared/shared.fail.d.ts +8 -2
  82. package/test/src/lib/shared/shared.wrap.d.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "13.3.1",
3
+ "version": "13.4.1",
4
4
  "exports": {
5
5
  "./test": {
6
6
  "module": "./test/index.esm.js",
@@ -16,24 +16,28 @@ export type BooleanStringKeyArray = BooleanKeyArray<BooleanStringKey>;
16
16
  export type BooleanKeyArray<T = string> = Maybe<T[]>;
17
17
  /**
18
18
  * Wraps a key reading function to ensure that empty string keys are not used in boolean key arrays.
19
+ *
19
20
  * @param readKey - The key reading function to wrap
20
21
  * @returns A wrapped key reading function that throws an error if an empty string is used as a key
21
22
  */
22
23
  export declare function readBooleanKeySafetyWrap<T>(readKey: ReadModelKeyFunction<T>): ReadModelKeyFunction<T>;
23
24
  /**
24
25
  * Checks if a boolean key array evaluates to false (empty or undefined).
26
+ *
25
27
  * @param value - The boolean key array to check
26
28
  * @returns True if the array is empty or undefined, false otherwise
27
29
  */
28
30
  export declare function isFalseBooleanKeyArray(value: BooleanKeyArray): boolean;
29
31
  /**
30
32
  * Checks if a boolean key array evaluates to true (has at least one value).
33
+ *
31
34
  * @param value - The boolean key array to check
32
35
  * @returns True if the array has at least one value, false otherwise
33
36
  */
34
37
  export declare function isTrueBooleanKeyArray(value: BooleanKeyArray): boolean;
35
38
  /**
36
39
  * Inserts a value into a boolean key array, removing any existing values with the same key.
40
+ *
37
41
  * @param array - The boolean key array to insert into
38
42
  * @param value - The value to insert
39
43
  * @param readKey - Function to extract the key from a value
@@ -42,6 +46,7 @@ export declare function isTrueBooleanKeyArray(value: BooleanKeyArray): boolean;
42
46
  export declare function insertIntoBooleanKeyArray<T>(array: BooleanKeyArray<T>, value: T, readKey: ReadModelKeyFunction<T>): BooleanKeyArray<T>;
43
47
  /**
44
48
  * Removes a value from a boolean key array based on its key.
49
+ *
45
50
  * @param array - The boolean key array to remove from
46
51
  * @param value - The value to remove
47
52
  * @param readKey - Function to extract the key from a value
@@ -50,6 +55,7 @@ export declare function insertIntoBooleanKeyArray<T>(array: BooleanKeyArray<T>,
50
55
  export declare function removeFromBooleanKeyArray<T>(array: BooleanKeyArray<T>, value: T, readKey: ReadModelKeyFunction<T>): BooleanKeyArray<T>;
51
56
  /**
52
57
  * Removes values from a boolean key array that match the specified key.
58
+ *
53
59
  * @param array - The boolean key array to remove from
54
60
  * @param key - The key to match for removal
55
61
  * @param readKey - Function to extract the key from a value
@@ -62,6 +68,7 @@ export declare function removeByKeyFromBooleanKeyArray<T>(array: BooleanKeyArray
62
68
  export type BooleanKeyArrayUtility<T> = ReturnType<typeof booleanKeyArrayUtility<T>>;
63
69
  /**
64
70
  * Creates a utility object with functions for working with boolean key arrays.
71
+ *
65
72
  * @param readKey - Function to extract the key from a value
66
73
  * @returns An object with utility functions for boolean key arrays
67
74
  */
@@ -7,12 +7,12 @@ import { type AscendingSortCompareFunction } from '../sort';
7
7
  *
8
8
  * If order is irrelevant, use filterValuesByDistanceNoOrder() instead.
9
9
  *
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
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
13
  * @returns A filtered array with only values that are at least minDistance apart
14
14
  */
15
- export declare function filterValuesByDistance<T>(input: T[], minDistance: number, getValue: (value: T) => number | null): T[];
15
+ export declare function filterValuesByDistance<T>(_input: T[], _minDistance: number, _getValue: (value: T) => number | null): T[];
16
16
  /**
17
17
  * Filters the input values by an arbitrary "distance"/difference from each other and returns the values sorted by their determined distance.
18
18
  *
@@ -15,7 +15,9 @@ export type IndexSetPairSet<T> = IndexSetPair<T>[];
15
15
  * Pairs an array item with its index position.
16
16
  */
17
17
  export interface IndexSetPair<T> extends IndexRef {
18
- /** The item at the index, or undefined if no item exists at that position. */
18
+ /**
19
+ * The item at the index, or undefined if no item exists at that position.
20
+ */
19
21
  item: Maybe<T>;
20
22
  }
21
23
  /**
@@ -73,11 +73,17 @@ export declare function indexedValuesArrayAccessorFactory<T>(readIndexRange: Rea
73
73
  * Contains the match result for a ranged index lookup, including the matched value and its neighbors.
74
74
  */
75
75
  export interface RangedIndexValuesArrayAccessorInfo<T> {
76
- /** The value from the range immediately before the matched or queried range. */
76
+ /**
77
+ * The value from the range immediately before the matched or queried range.
78
+ */
77
79
  readonly prev?: Maybe<T>;
78
- /** The value whose range contains the queried index, or undefined if no range matched. */
80
+ /**
81
+ * The value whose range contains the queried index, or undefined if no range matched.
82
+ */
79
83
  readonly match?: Maybe<T>;
80
- /** The value from the range immediately after the matched or queried range. */
84
+ /**
85
+ * The value from the range immediately after the matched or queried range.
86
+ */
81
87
  readonly next?: Maybe<T>;
82
88
  }
83
89
  /**
@@ -18,6 +18,8 @@ export interface LimitArrayConfig {
18
18
  *
19
19
  * @param array - source array to limit
20
20
  * @param inputConfig - configuration controlling the limit count and direction
21
+ * @param inputConfig.limit - maximum number of items to include in the result
22
+ * @param inputConfig.limitFromEnd - when true, items are taken from the end of the array instead of the front
21
23
  * @returns a new array with at most the configured number of items, or the original array if no limit is specified
22
24
  */
23
25
  export declare function limitArray<T>(array: T[], { limit, limitFromEnd }: Partial<LimitArrayConfig>): T[];
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Interface for configuring a Description Assertion.
3
3
  * Provides options for customizing assertion messages.
4
+ *
4
5
  * @interface
5
6
  */
6
7
  export interface DescriptorAssertionOptions {
@@ -9,6 +10,7 @@ export interface DescriptorAssertionOptions {
9
10
  /**
10
11
  * DescriptorAssertionOptions extension that also maps one value to another.
11
12
  * Extends the base assertion options to include a mapping function.
13
+ *
12
14
  * @interface
13
15
  * @template T - The type of value being mapped
14
16
  */
@@ -16,6 +18,7 @@ export interface MapDescriptorAssertionOptions<T> extends DescriptorAssertionOpt
16
18
  /**
17
19
  * Maps the value after it has been validated.
18
20
  * This function is applied to transform the value after the assertion passes.
21
+ *
19
22
  * @param value - The value to transform after validation
20
23
  * @returns The transformed value
21
24
  */
@@ -4,6 +4,7 @@ import { type DescriptorAssertionOptions } from './assert';
4
4
  /**
5
5
  * Interface representing an assertion issue that occurred.
6
6
  * Contains information about the object and property that failed the assertion.
7
+ *
7
8
  * @interface
8
9
  */
9
10
  export interface AssertionIssue {
@@ -35,11 +36,13 @@ export declare class AssertionError extends BaseError implements ReadableError {
35
36
  }, message: string);
36
37
  /**
37
38
  * Gets the target object that failed the assertion.
39
+ *
38
40
  * @returns The target object
39
41
  */
40
42
  get target(): object;
41
43
  /**
42
44
  * Gets the property key that failed the assertion.
45
+ *
43
46
  * @returns The property key as a string
44
47
  */
45
48
  get propertyKey(): string;
@@ -50,12 +53,14 @@ export declare class AssertionError extends BaseError implements ReadableError {
50
53
  export declare class AssertionIssueHandler {
51
54
  /**
52
55
  * Handles an assertion issue by throwing an appropriate exception.
56
+ *
53
57
  * @param error - The assertion issue to handle
54
58
  * @throws AssertionError
55
59
  */
56
60
  handle(error: AssertionIssue): void;
57
61
  /**
58
62
  * Builds an AssertionError from an AssertionIssue.
63
+ *
59
64
  * @param error - The assertion issue to build an exception from
60
65
  * @returns A new AssertionError instance
61
66
  */
@@ -63,6 +68,7 @@ export declare class AssertionIssueHandler {
63
68
  /**
64
69
  * Builds an error message string from an AssertionIssue.
65
70
  * Uses the custom message if provided, otherwise creates a default message.
71
+ *
66
72
  * @param error - The assertion issue to build a message for
67
73
  * @returns The error message string
68
74
  */
@@ -18,6 +18,9 @@ export type IsModified = boolean;
18
18
  export type TrueOrFalseString = 'true' | 'false';
19
19
  /**
20
20
  * If a non-null boolean value is provided, returns the opposite.
21
+ *
22
+ * @param x - the boolean value to invert, or a nullish value
23
+ * @returns the inverted boolean, or the original nullish value if input was null/undefined
21
24
  */
22
25
  export declare function invertMaybeBoolean(x: true): false;
23
26
  export declare function invertMaybeBoolean(x: false): true;
@@ -84,7 +84,7 @@ export declare function expirationDetails<T extends Expires = Expires>(input: Ex
84
84
  * @param input - Input configuration used to calculate the expiration date
85
85
  * @returns The calculated expiration date, or null if no expiration is defined
86
86
  */
87
- export declare function calculateExpirationDate(input: ExpirationDetailsInput<any>): Maybe<Date>;
87
+ export declare function calculateExpirationDate(input: ExpirationDetailsInput<Expires>): Maybe<Date>;
88
88
  /**
89
89
  * Returns true if the threshold has not passed since the next run time, compared to now.
90
90
  *
@@ -120,7 +120,7 @@ export declare function isThrottled(throttleTime: Maybe<Milliseconds>, lastRunAt
120
120
  * @param details - Collection of ExpirationDetails to check
121
121
  * @returns True if at least one item has not expired, false otherwise
122
122
  */
123
- export declare function checkAtleastOneNotExpired(details: ExpirationDetails<any>[]): boolean;
123
+ export declare function checkAtleastOneNotExpired(details: ExpirationDetails<Expires>[]): boolean;
124
124
  /**
125
125
  * Returns true if any of the input ExpirationDetails have expired.
126
126
  * Useful for checking if any items in a collection need to be refreshed or removed.
@@ -131,4 +131,4 @@ export declare function checkAtleastOneNotExpired(details: ExpirationDetails<any
131
131
  * @param defaultIfEmpty - Default value to return if the list is empty (defaults to true)
132
132
  * @returns True if any item has expired, or the defaultIfEmpty value for an empty list
133
133
  */
134
- export declare function checkAnyHaveExpired(details: ExpirationDetails<any>[], defaultIfEmpty?: boolean): boolean;
134
+ export declare function checkAnyHaveExpired(details: ExpirationDetails<Expires>[], defaultIfEmpty?: boolean): boolean;
@@ -1,4 +1,17 @@
1
- import { type Milliseconds, type Seconds } from './date';
1
+ import { type Milliseconds, type Minutes, type Seconds } from './date';
2
+ /**
3
+ * Converts the input number of milliseconds to whole minutes by flooring the result.
4
+ *
5
+ * @param milliseconds - The number of milliseconds to convert.
6
+ * @returns The equivalent whole minutes, rounded down.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * millisecondsToMinutes(180000); // 3
11
+ * millisecondsToMinutes(90000); // 1
12
+ * ```
13
+ */
14
+ export declare function millisecondsToMinutes(milliseconds: Milliseconds): Minutes;
2
15
  /**
3
16
  * A pair of minutes and seconds.
4
17
  */
@@ -15,13 +28,6 @@ export interface MinutesAndSeconds {
15
28
  * @returns An object with the minute and second components
16
29
  */
17
30
  export declare function millisecondsToMinutesAndSeconds(milliseconds: Milliseconds): MinutesAndSeconds;
18
- /**
19
- * A pair of minutes and seconds.
20
- */
21
- export interface MinutesAndSeconds {
22
- readonly minute: number;
23
- readonly second: number;
24
- }
25
31
  /**
26
32
  * Converts the input number of seconds to the equivalent in minutes and seconds.
27
33
  *
@@ -118,5 +118,8 @@ export declare function makeTimer(duration: Milliseconds, startImmediately?: boo
118
118
  export declare function toggleTimerRunning(timer: Timer, toggleRun?: boolean): void;
119
119
  /**
120
120
  * Returns the approximate end date of the given timer. If a timer is already complete, it returns the time for now.
121
+ *
122
+ * @param timer - the timer whose end date to approximate
123
+ * @returns a Date representing the estimated end time, or null if no duration remains
121
124
  */
122
125
  export declare function approximateTimerEndDate(timer: Timer): Maybe<Date>;
@@ -25,6 +25,7 @@ export type ErrorMessageOrPartialServerError<T = ServerErrorResponseData> = stri
25
25
  * Normalizes a string or partial error into a Partial ServerError object.
26
26
  * If the input is a string, it becomes the message property.
27
27
  *
28
+ * @param message - a plain error message string that becomes the `message` property of the returned object
28
29
  * @param messageOrError - A string message or partial server error object
29
30
  * @returns A partial ServerError object
30
31
  */
@@ -12,4 +12,4 @@
12
12
  * @param buffer - Buffer-like object to check. Only requires the `lastIndexOf` method.
13
13
  * @returns true if both PDF markers are found in the expected positions.
14
14
  */
15
- export declare function bufferHasValidPdfMarkings(buffer: Pick<Buffer<ArrayBuffer>, 'lastIndexOf'>): boolean;
15
+ export declare function bufferHasValidPdfMarkings(buffer: Pick<Buffer<ArrayBuffer>, 'lastIndexOf' | 'includes'>): boolean;
@@ -35,7 +35,7 @@ export type CachedFactoryWithInput<T, A = unknown> = CachedGetter<T> & FactoryWi
35
35
  * The value is retrieved once on first call and cached permanently.
36
36
  * Use `reset()` to clear the cache and `init()` to reload.
37
37
  *
38
- * @param factory - The factory function to cache
38
+ * @param getter - the factory or getter function whose result will be cached
39
39
  * @returns A CachedFactoryWithInput that caches the first result
40
40
  */
41
41
  export declare function cachedGetter<T>(getter: Getter<T>): CachedFactoryWithInput<T>;
@@ -33,9 +33,13 @@ export interface PairsGroupingResult<T> {
33
33
  * Configuration for comparing two arrays to determine if their contents differ.
34
34
  */
35
35
  export interface ArrayContentsDifferentParams<T, K extends PrimativeKey = PrimativeKey> {
36
- /** Extracts a unique key from each item for pairing items across arrays. */
36
+ /**
37
+ * Extracts a unique key from each item for pairing items across arrays.
38
+ */
37
39
  groupKeyFn: ReadKeyFunction<T, K>;
38
- /** Compares two paired items for equality. */
40
+ /**
41
+ * Compares two paired items for equality.
42
+ */
39
43
  isEqual: EqualityComparatorFunction<T>;
40
44
  }
41
45
  /**
@@ -127,6 +131,9 @@ export declare function restoreOrderWithValues<T, K extends PrimativeKey = Prima
127
131
  * @param orderKeys - Keys defining the desired order.
128
132
  * @param values - Values to reorder.
129
133
  * @param params - Configuration including key reader, duplicate handling, and new-item behavior.
134
+ * @param params.readKey - function that extracts the grouping key from each value
135
+ * @param params.chooseRetainedValue - function that selects which value to keep when duplicates share the same key; defaults to keeping the first
136
+ * @param params.excludeNewItems - when true, values whose keys are not in `orderKeys` are omitted from the result; defaults to false
130
137
  * @returns The reordered values array.
131
138
  *
132
139
  * @example
@@ -145,6 +152,8 @@ export declare function restoreOrder<T, K extends PrimativeKey = PrimativeKey>(o
145
152
  * @param a - First array to compare.
146
153
  * @param b - Second array to compare.
147
154
  * @param params - Key extraction and equality functions.
155
+ * @param params.groupKeyFn - function that extracts a grouping key from each element for pairing
156
+ * @param params.isEqual - predicate that returns true when two paired elements are considered equal
148
157
  * @returns `true` if the array contents differ.
149
158
  */
150
159
  export declare function arrayContentsDiffer<T, K extends PrimativeKey = PrimativeKey>(a: T[] | undefined, b: T[] | undefined, { groupKeyFn, isEqual }: ArrayContentsDifferentParams<T, K>): boolean;
@@ -115,4 +115,4 @@ export declare function multiValueMapBuilder<T, K extends PrimativeKey = Primati
115
115
  * @param b - The second map
116
116
  * @returns true if the maps have the same keys, false otherwise
117
117
  */
118
- export declare function mapsHaveSameKeys<K>(a: Map<K, any>, b: Map<K, any>): boolean;
118
+ export declare function mapsHaveSameKeys<K>(a: Map<K, unknown>, b: Map<K, unknown>): boolean;
@@ -68,15 +68,6 @@ export type MultiModelKeyMap<T> = Map<string, T>;
68
68
  * @returns The model's `id` value
69
69
  */
70
70
  export declare const readUniqueModelKey: (model: UniqueModel) => string | undefined;
71
- /**
72
- * Abstract base class for models identified by a unique {@link ModelKey}.
73
- *
74
- * Copies the `id` from the provided template during construction.
75
- */
76
- export declare abstract class AbstractUniqueModel {
77
- id?: ModelKey;
78
- constructor(template: Partial<AbstractUniqueModel>);
79
- }
80
71
  /**
81
72
  * Deduplicates an array of model keys using a Set.
82
73
  *
@@ -167,6 +158,9 @@ export declare function makeMultiModelKeyMap<T>(input: T[], read: ReadRelationKe
167
158
  *
168
159
  * @param input - A model object or a model key string
169
160
  * @param config - Handlers for model and key cases, plus whether input is required
161
+ * @param config.useModel - handler invoked when the input is a model object; if omitted, the model's key is passed to `useKey` instead
162
+ * @param config.useKey - handler invoked when the input is a model key string
163
+ * @param config.required - when true, throws an error if the input is nullish; defaults to false
170
164
  * @returns The result of the matched handler, or undefined if input is nullish and not required
171
165
  * @throws Error if `required` is true and input is nullish
172
166
  */
@@ -272,3 +266,14 @@ export type ModelTypeDataPairFactory<T, M extends ModelTypeString = ModelTypeStr
272
266
  * @returns Factory function that produces ModelTypeDataPair values
273
267
  */
274
268
  export declare function modelTypeDataPairFactory<T, M extends ModelTypeString = ModelTypeString>(typeReader: ReadModelTypeFunction<T, M>, defaultType?: string): ModelTypeDataPairFactory<T, M>;
269
+ /**
270
+ * Abstract base class for models identified by a unique {@link ModelKey}.
271
+ *
272
+ * Copies the `id` from the provided template during construction.
273
+ *
274
+ * @deprecated Use {@link UniqueModel} instead.
275
+ */
276
+ export declare abstract class AbstractUniqueModel {
277
+ id?: ModelKey;
278
+ constructor(template: Partial<UniqueModel>);
279
+ }
@@ -7,6 +7,14 @@ export type WholeDollarAmount = number;
7
7
  * Dollar amount number.
8
8
  */
9
9
  export type DollarAmount = number;
10
+ /**
11
+ * Dollars amount number per hour.
12
+ */
13
+ export type DollarAmountPerHour = number;
14
+ /**
15
+ * Dollars amount number per day.
16
+ */
17
+ export type DollarAmountPerDay = number;
10
18
  export type CentsAmount = number;
11
19
  export interface DollarsPair {
12
20
  dollars: WholeDollarAmount;
@@ -103,6 +103,10 @@ export declare function isOddNumber(value: number): boolean;
103
103
  export declare function sumOfIntegersBetween(from: number, to: number): number;
104
104
  /**
105
105
  * A {@link SortCompareFunction} for numbers that sorts in ascending order.
106
+ *
107
+ * @param a - the first number to compare
108
+ * @param b - the second number to compare
109
+ * @returns a negative value if `a` is less than `b`, zero if equal, or a positive value if `a` is greater
106
110
  */
107
111
  export declare const sortCompareNumberFunction: SortCompareFunction<number>;
108
112
  /**
@@ -5,5 +5,6 @@ export * from './object.equal';
5
5
  export * from './object.key';
6
6
  export * from './object.map';
7
7
  export * from './object';
8
+ export * from './object.flatten';
8
9
  export * from './object.filter.tuple';
9
10
  export * from './object.filter.pojo';
@@ -29,7 +29,7 @@ export interface ObjectFieldEqualityCheckerConfig<T extends object> {
29
29
  /**
30
30
  * Fields to capture as part of the compressor.
31
31
  */
32
- readonly fields: (ObjectFieldEqualityCheckerFieldConfig<T, any> | FieldOfType<T>)[];
32
+ readonly fields: (ObjectFieldEqualityCheckerFieldConfig<T, FieldOfType<T>> | FieldOfType<T>)[];
33
33
  /**
34
34
  * Default equality function to use when a field's equality function is not provided.
35
35
  */
@@ -77,7 +77,7 @@ export interface ObjectFieldEqualityCheckResults<T extends object> {
77
77
  * Function used to check if two objects are considered equal.
78
78
  */
79
79
  export type ObjectFieldEqualityChecker<T extends object> = ((a: Partial<T>, b: Partial<T>) => ObjectFieldEqualityCheckResults<T>) & {
80
- readonly _fields: Map<keyof T, ObjectFieldEqualityCheckerFieldConfig<T, any>>;
80
+ readonly _fields: Map<keyof T, ObjectFieldEqualityCheckerFieldConfig<T, FieldOfType<T>>>;
81
81
  };
82
82
  /**
83
83
  * Creates an {@link ObjectFieldEqualityChecker} that compares two objects field-by-field using configured equality functions.
@@ -78,6 +78,9 @@ export interface OverrideInObjectFunctionFactoryConfig<T extends object> {
78
78
  * By default, `undefined` values in sources are excluded from the template.
79
79
  *
80
80
  * @param config - Configuration controlling filtering, copying, and caching behavior.
81
+ * @param config.filter - filter applied to source object values when building the template; by default, `undefined` values are excluded
82
+ * @param config.copy - when true, the target object is shallow-copied before applying overrides instead of being mutated in place
83
+ * @param config.dynamic - when true, the template is recalculated on each call instead of being cached; useful when source objects may change over time
81
84
  * @returns A factory function that accepts source objects and returns an override function.
82
85
  *
83
86
  * @example
@@ -372,6 +375,8 @@ export type GeneralFilterFromPOJOFunction<X = object> = <T extends X>(input: T)
372
375
  * By default, removes `undefined` values (`KeyValueTypleValueFilter.UNDEFINED`) and does not copy (`copy: false`).
373
376
  *
374
377
  * @param config - Configuration for filtering and copying. Defaults to `{ copy: false, filter: { valueFilter: KeyValueTypleValueFilter.UNDEFINED } }`.
378
+ * @param config.copy - when true, returns a shallow copy with filtered keys removed instead of mutating the input; defaults to false
379
+ * @param config.filter - the filter criteria determining which key/value pairs to remove; defaults to removing `undefined` values
375
380
  * @returns A reusable filter function. The returned function also accepts a `copyOverride` argument to override the copy behavior per-call.
376
381
  *
377
382
  * @example
@@ -613,6 +618,8 @@ export type ForEachKeyValueOnPOJOConfig<T extends object, C = unknown, K extends
613
618
  * When no filter is provided, all key/value pairs are iterated.
614
619
  *
615
620
  * @param config - The filter and forEach callback configuration.
621
+ * @param config.forEach - callback invoked for each key/value pair that passes the filter
622
+ * @param config.filter - optional filter controlling which key/value pairs are iterated; when omitted, all pairs are visited
616
623
  * @returns A function that iterates matching key/value pairs on any input object.
617
624
  *
618
625
  * @example
@@ -16,6 +16,8 @@ export interface ForEachKeyValue<T extends object = object, K extends keyof T =
16
16
  *
17
17
  * @param obj - Object to iterate
18
18
  * @param config - Configuration with a forEach callback and optional filter
19
+ * @param config.forEach - callback invoked for each key/value tuple that passes the filter
20
+ * @param config.filter - optional filter controlling which key/value tuples are iterated; when omitted, all tuples are visited
19
21
  *
20
22
  * @example
21
23
  * ```ts
@@ -0,0 +1,43 @@
1
+ import { type Maybe } from '../value/maybe.type';
2
+ /**
3
+ * Configuration for {@link flattenObject}.
4
+ */
5
+ export interface FlattenObjectConfig {
6
+ /**
7
+ * Separator between key segments.
8
+ *
9
+ * @defaultValue '.'
10
+ */
11
+ readonly separator?: string;
12
+ /**
13
+ * Maximum nesting depth to flatten. A depth of 1 means only the first level of nested objects is flattened.
14
+ *
15
+ * @defaultValue Infinity (unlimited)
16
+ */
17
+ readonly maxDepth?: number;
18
+ }
19
+ /**
20
+ * Flattens a nested object into a single-level object with concatenated keys.
21
+ *
22
+ * Recursively traverses plain objects and joins nested keys with a separator (default `'.'`).
23
+ * Non-plain-object values (arrays, Dates, null, functions, etc.) are treated as leaf values and kept as-is.
24
+ * Empty nested objects are omitted from the result (they produce no keys).
25
+ * Circular references are detected and treated as leaf values to avoid infinite recursion.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * flattenObject({ a: 1, b: { c: 2, d: { e: 3 } } });
30
+ * // { a: 1, 'b.c': 2, 'b.d.e': 3 }
31
+ *
32
+ * flattenObject({ a: { b: 1 } }, { separator: '_' });
33
+ * // { a_b: 1 }
34
+ *
35
+ * flattenObject({ a: { b: { c: 1 } } }, { maxDepth: 1 });
36
+ * // { 'a.b': { c: 1 } }
37
+ * ```
38
+ *
39
+ * @param input - The object to flatten. If nullish, returns an empty object.
40
+ * @param config - Optional configuration for separator and max depth.
41
+ * @returns A new flat object with concatenated key paths.
42
+ */
43
+ export declare function flattenObject(input: Maybe<Record<string, unknown>>, config?: FlattenObjectConfig): Record<string, unknown>;
@@ -60,7 +60,7 @@ export declare function mapObjectToTargetObject<M extends ObjectMap<I>, I = unkn
60
60
  /**
61
61
  * Maps each key of the input object to a new object using the pre-configured function.
62
62
  */
63
- export type MapObjectKeysFunction<M> = (object: M) => any;
63
+ export type MapObjectKeysFunction<M> = (object: M) => unknown;
64
64
  /**
65
65
  * Map function that returns the new POJOKey using the input key/value pair.
66
66
  */
@@ -200,7 +200,9 @@ export declare function slashPathFolderFactory(config?: SlashPathFolderFactoryCo
200
200
  *
201
201
  * If the input is a file, the folder of the file is returned instead.
202
202
  *
203
- * @param input
203
+ * @param input - the string path to convert to a folder path
204
+ * @param config - optional configuration controlling path type inference and invalid-path handling
205
+ * @returns a valid slash path folder string with a trailing slash, or an empty string for relative root
204
206
  */
205
207
  export declare function slashPathFolder(input: string, config?: SlashPathFolderFactoryConfig): InferredSlashPathFolder;
206
208
  /**
@@ -547,7 +549,7 @@ export declare function slashPathPathMatcherConfig<N extends PrimativeValue = Pr
547
549
  /**
548
550
  * Creates a SlashPathPathMatcher.
549
551
  *
550
- * @param config The configuration for the matcher.
552
+ * @param input - the matcher configuration, which may be a target path string, an array of path parts, or a full config object
551
553
  * @returns The matcher.
552
554
  */
553
555
  export declare function slashPathPathMatcher<N extends PrimativeValue = PrimativeValue>(input: SlashPathPathMatcherConfigInput<N>): SlashPathPathMatcher<N>;
@@ -23,6 +23,9 @@ export interface PollConfig {
23
23
  * Polls at a regular interval until a condition is met or the maximum number of attempts is reached.
24
24
  *
25
25
  * @param config - Polling configuration including check function, wait interval, and max attempts.
26
+ * @param config.check - predicate function that returns true when the polling condition has been satisfied
27
+ * @param config.wait - milliseconds to wait between polling iterations; defaults to 250
28
+ * @param config.timesToGiveup - maximum number of polling iterations before giving up; defaults to `Number.MAX_SAFE_INTEGER`
26
29
  * @returns A Promise that resolves when the check condition returns `true` or the max attempts are exhausted.
27
30
  */
28
31
  export declare function poll({ check, wait, timesToGiveup }: PollConfig): Promise<void>;
@@ -44,22 +44,34 @@ export type PerformAsyncTaskFn<T, K = unknown> = (value: T, tryNumber?: number)
44
44
  * The result of executing a single async task via {@link performAsyncTask}.
45
45
  */
46
46
  export interface PerformAsyncTaskResult<O> {
47
- /** The resulting value if the task succeeded, or undefined on failure. */
47
+ /**
48
+ * The resulting value if the task succeeded, or undefined on failure.
49
+ */
48
50
  readonly value: Maybe<O>;
49
- /** Whether the task completed successfully. */
51
+ /**
52
+ * Whether the task completed successfully.
53
+ */
50
54
  readonly success: boolean;
51
55
  }
52
56
  /**
53
57
  * The aggregated result of executing multiple async tasks via {@link performAsyncTasks}.
54
58
  */
55
59
  export interface PerformAsyncTasksResult<I, O> {
56
- /** Input values whose tasks succeeded. */
60
+ /**
61
+ * Input values whose tasks succeeded.
62
+ */
57
63
  readonly succeded: I[];
58
- /** Input values whose tasks failed. */
64
+ /**
65
+ * Input values whose tasks failed.
66
+ */
59
67
  readonly failed: I[];
60
- /** Tuples of [input, output] for each successful task. */
68
+ /**
69
+ * Tuples of [input, output] for each successful task.
70
+ */
61
71
  readonly results: [I, O][];
62
- /** Tuples of [input, error] for each failed task. */
72
+ /**
73
+ * Tuples of [input, error] for each failed task.
74
+ */
63
75
  readonly errors: [I, unknown][];
64
76
  }
65
77
  /**
@@ -193,7 +205,7 @@ export type PerformTaskFactoryTasksInParallelFunction<I> = (taskInputFactory: Pe
193
205
  * with configurable concurrency limits and non-concurrent key constraints.
194
206
  *
195
207
  * @param config - Configuration for the task factory, parallelism, and concurrency behavior.
196
- * @returns A function that accepts a task input factory and returns a Promise resolving when all tasks complete.
208
+ * @returns a function that accepts a task input factory and returns a Promise that resolves when all tasks complete
197
209
  */
198
210
  export declare function performTasksFromFactoryInParallelFunction<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(config: PerformTasksFromFactoryInParallelFunctionConfig<I, K>): PerformTaskFactoryTasksInParallelFunction<I>;
199
211
  /**