@dereekb/util 11.1.8 → 12.0.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 (49) hide show
  1. package/fetch/index.cjs.js +3051 -2146
  2. package/fetch/index.esm.d.ts +1 -0
  3. package/fetch/index.esm.js +2904 -1888
  4. package/fetch/package.json +4 -3
  5. package/index.cjs.js +3771 -3654
  6. package/index.esm.d.ts +1 -0
  7. package/index.esm.js +3783 -5031
  8. package/package.json +4 -3
  9. package/src/lib/array/array.boolean.d.ts +50 -0
  10. package/src/lib/array/array.factory.d.ts +17 -14
  11. package/src/lib/array/array.filter.d.ts +34 -18
  12. package/src/lib/array/array.find.d.ts +17 -5
  13. package/src/lib/array/array.index.d.ts +2 -1
  14. package/src/lib/array/array.limit.d.ts +3 -2
  15. package/src/lib/assertion/assert.d.ts +9 -1
  16. package/src/lib/assertion/assert.error.d.ts +50 -7
  17. package/src/lib/auth/auth.role.d.ts +7 -0
  18. package/src/lib/boolean.d.ts +51 -6
  19. package/src/lib/contact/email.d.ts +33 -0
  20. package/src/lib/contact/phone.d.ts +48 -14
  21. package/src/lib/date/date.d.ts +109 -27
  22. package/src/lib/date/date.time.d.ts +25 -2
  23. package/src/lib/date/expires.d.ts +27 -21
  24. package/src/lib/date/time.d.ts +15 -24
  25. package/src/lib/grouping.d.ts +3 -0
  26. package/src/lib/nodejs/stream.d.ts +0 -2
  27. package/src/lib/relation/relation.d.ts +15 -11
  28. package/src/lib/set/set.delta.d.ts +1 -1
  29. package/src/lib/string/dencoder.d.ts +1 -1
  30. package/src/lib/string/html.d.ts +14 -1
  31. package/src/lib/string/index.d.ts +1 -0
  32. package/src/lib/string/prefix.d.ts +81 -0
  33. package/src/lib/string/replace.d.ts +2 -2
  34. package/src/lib/value/indexed.d.ts +7 -7
  35. package/src/lib/value/maybe.d.ts +10 -3
  36. package/test/CHANGELOG.md +9 -0
  37. package/test/package.json +3 -2
  38. package/test/src/lib/jest.d.ts +1 -1
  39. package/test/src/lib/jest.fail.d.ts +3 -3
  40. package/test/src/lib/jest.fail.js +15 -15
  41. package/test/src/lib/jest.fail.js.map +1 -1
  42. package/test/src/lib/jest.function.d.ts +1 -1
  43. package/test/src/lib/jest.function.js +2 -3
  44. package/test/src/lib/jest.function.js.map +1 -1
  45. package/test/src/lib/jest.js +3 -3
  46. package/test/src/lib/jest.js.map +1 -1
  47. package/test/src/lib/jest.wrap.d.ts +1 -1
  48. package/test/src/lib/jest.wrap.js +3 -3
  49. package/test/src/lib/jest.wrap.js.map +1 -1
@@ -23,16 +23,19 @@ export type PhoneExtensionNumber = string;
23
23
  */
24
24
  export type E164PhoneNumber = `+${PhoneNumber}`;
25
25
  /**
26
- * E164PhoneNumber regex validator.
26
+ * Regular expression for validating E.164 phone numbers.
27
+ * Validates numbers that start with a + followed by 2-15 digits.
28
+ * The first digit after the + must be 1-9 (not 0).
27
29
  *
28
30
  * Requires the + to be provided.
29
31
  */
30
32
  export declare const E164PHONE_NUMBER_REGEX: RegExp;
31
33
  /**
32
- * Returns true if the input phone number is a valid E164PHONE_NUMBER_REGEX value.
34
+ * Validates if the input string is a valid E.164 phone number.
33
35
  *
34
- * @param input
35
- * @returns
36
+ * @param input - The phone number string to validate
37
+ * @param allowExtension - If true, allows an extension in the format +number#extension
38
+ * @returns True if the input is a valid E.164 phone number
36
39
  */
37
40
  export declare function isE164PhoneNumber(input: string, allowExtension?: boolean): input is E164PhoneNumber;
38
41
  /**
@@ -46,39 +49,70 @@ export type E164PhoneNumberWithExtension = `+${PhoneNumber}#${PhoneExtensionNumb
46
49
  */
47
50
  export type E164PhoneNumberWithOptionalExtension = E164PhoneNumber | E164PhoneNumberWithExtension;
48
51
  /**
49
- * E164PhoneNumber regex validator with an optional extension.
52
+ * Regular expression for validating E.164 phone numbers with an optional extension.
53
+ * Validates numbers in the format +number or +number#extension.
54
+ * The extension part is 1-6 digits following a # character.
50
55
  *
51
56
  * Requires the + to be provided.
52
57
  */
53
58
  export declare const E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX: RegExp;
54
59
  /**
55
- * E164PhoneNumber regex validator with an extension.
60
+ * Regular expression for validating E.164 phone numbers that must include an extension.
61
+ * Validates numbers strictly in the format +number#extension.
62
+ * The extension part is 1-6 digits following a # character.
56
63
  *
57
- * Requires the + to be provided.
64
+ * Requires the + to be provided and the extension part.
58
65
  */
59
66
  export declare const E164PHONE_NUMBER_WITH_EXTENSION_REGEX: RegExp;
60
67
  /**
61
- * Returns true if the input phone number is a valid E164PHONE_NUMBER_WITH_EXTENSION_REGEX value.
68
+ * Validates if the input string is a valid E.164 phone number with an extension.
69
+ * The phone number must be in the format +number#extension.
62
70
  *
63
- * @param input
64
- * @returns
71
+ * @param input - The phone number string to validate
72
+ * @returns True if the input is a valid E.164 phone number with extension
65
73
  */
66
74
  export declare function isE164PhoneNumberWithExtension(input: string): input is E164PhoneNumberWithExtension;
75
+ /**
76
+ * Regular expression for validating phone extension numbers.
77
+ * Extension must be 1-6 digits with no other characters.
78
+ */
67
79
  export declare const PHONE_EXTENSION_NUMBER_REGEX: RegExp;
68
80
  /**
69
- * Returns true if the input is a valid phone number extension.
81
+ * Validates if the input string is a valid phone extension number.
82
+ * Valid extensions are 1-6 digits with no other characters.
70
83
  *
71
- * @param input
72
- * @returns
84
+ * @param input - The extension string to validate
85
+ * @returns True if the input is a valid phone extension number
73
86
  */
74
87
  export declare function isValidPhoneExtensionNumber(input: string): input is PhoneExtensionNumber;
75
88
  /**
76
- * Removes the extension characters from the input phone number.
89
+ * Removes the extension portion from a phone number.
90
+ * If the phone number contains a # character, everything after it is removed.
91
+ *
92
+ * @param input - The phone number with or without extension
93
+ * @returns The phone number with any extension removed
77
94
  */
78
95
  export declare const removeExtensionFromPhoneNumber: (input: PhoneNumber | E164PhoneNumberWithOptionalExtension) => E164PhoneNumber;
96
+ /**
97
+ * Interface representing a phone number and its optional extension as separate parts.
98
+ */
79
99
  export interface E164PhoneNumberExtensionPair {
80
100
  number: E164PhoneNumber;
81
101
  extension?: Maybe<PhoneExtensionNumber>;
82
102
  }
103
+ /**
104
+ * Splits a phone number into its main number and extension components.
105
+ * If the input contains a # character, everything before is the number and everything after is the extension.
106
+ *
107
+ * @param input - The phone number string to split
108
+ * @returns An object containing the number and optional extension
109
+ */
83
110
  export declare function e164PhoneNumberExtensionPair(input: PhoneNumber | E164PhoneNumberWithOptionalExtension): E164PhoneNumberExtensionPair;
111
+ /**
112
+ * Combines a phone number and optional extension into a single string.
113
+ * If an extension is provided, it will be appended with a # separator.
114
+ *
115
+ * @param input - An object containing the phone number and optional extension
116
+ * @returns A formatted phone number string with optional extension
117
+ */
84
118
  export declare function e164PhoneNumberFromE164PhoneNumberExtensionPair(input: E164PhoneNumberExtensionPair): E164PhoneNumberWithOptionalExtension;
@@ -7,6 +7,14 @@ export type DateRelativeDirection = 'past' | 'future';
7
7
  * Hour, minute, or second as a string.
8
8
  */
9
9
  export type DateHourMinuteOrSecond = 'hour' | 'minute' | 'second';
10
+ /**
11
+ * A valid RFC3339 formatted date string.
12
+ *
13
+ * I.E. "2020-04-30 00:00:00.000Z" and "2020-04-30T00:00:00.000Z"
14
+ *
15
+ * The only difference between this and an ISO8601DateString is the spacing between the date and time is allowed, while in ISO8601DateString it is not.
16
+ */
17
+ export type RFC3339DateString = string;
10
18
  /**
11
19
  * A valid ISO8601 formatted date string.
12
20
  *
@@ -14,9 +22,17 @@ export type DateHourMinuteOrSecond = 'hour' | 'minute' | 'second';
14
22
  */
15
23
  export type ISO8601DateString = string;
16
24
  /**
25
+ * Regular expression for validating ISO8601 date strings.
26
+ *
17
27
  * TODO(FUTURE): Need to improve to support negative years.
18
28
  */
19
29
  export declare const ISO_8601_DATE_STRING_REGEX: RegExp;
30
+ /**
31
+ * Determines if a string is a valid ISO8601 date string.
32
+ *
33
+ * @param input - The string to test
34
+ * @returns True if the input is a valid ISO8601 date string
35
+ */
20
36
  export declare function isISO8601DateString(input: string): input is ISO8601DateString;
21
37
  /**
22
38
  * A UTC date string.
@@ -32,6 +48,12 @@ export type UTCDateString = string;
32
48
  * Wed, 25 May 2024 20:45:07 EST
33
49
  */
34
50
  export declare const UTC_DATE_STRING_REGEX: RegExp;
51
+ /**
52
+ * Determines if a string is a valid UTC date string.
53
+ *
54
+ * @param input - The string to test
55
+ * @returns True if the input is a valid UTC date string
56
+ */
35
57
  export declare function isUTCDateString(input: string): boolean;
36
58
  /**
37
59
  * A full ISO8601 date string that is in UTC.
@@ -58,9 +80,9 @@ export interface TimezoneStringRef {
58
80
  /**
59
81
  * Returns true only if the inputs have the same timezone, or both do not have a timezone set.
60
82
  *
61
- * @param a
62
- * @param b
63
- * @returns
83
+ * @param a - First object that may contain a timezone reference
84
+ * @param b - Second object that may contain a timezone reference
85
+ * @returns True if both objects have the same timezone or neither has a timezone set
64
86
  */
65
87
  export declare function hasSameTimezone(a: Maybe<Partial<TimezoneStringRef>>, b: Maybe<Partial<TimezoneStringRef>>): boolean;
66
88
  /**
@@ -72,10 +94,11 @@ export declare const UTC_TIMEZONE_STRING = "UTC";
72
94
  */
73
95
  export type UTCTimezoneAbbreviation = typeof UTC_TIMEZONE_STRING;
74
96
  /**
75
- * Whether or not the input timezone string is considered UTC.
97
+ * Determines whether the input timezone string is considered UTC.
98
+ * Returns true for null, undefined, or the string 'UTC'.
76
99
  *
77
- * @param timezone
78
- * @returns
100
+ * @param timezone - The timezone string to check
101
+ * @returns True if the timezone is considered UTC
79
102
  */
80
103
  export declare function isConsideredUtcTimezoneString(timezone: Maybe<TimezoneString>): boolean;
81
104
  export declare function isConsideredUtcTimezoneString(timezone: TimezoneString): boolean;
@@ -138,7 +161,19 @@ export declare function parseISO8601DayStringToUTCDate(inputDateString: ISO8601D
138
161
  * @param input
139
162
  * @returns
140
163
  */
164
+ /**
165
+ * Determines if a string is a valid ISO8601 day string (YYYY-MM-DD format).
166
+ *
167
+ * @param input - The string to test
168
+ * @returns True if the input is a valid ISO8601 day string
169
+ */
141
170
  export declare function isISO8601DayString(input: string): input is ISO8601DayString;
171
+ /**
172
+ * Determines if a string starts with a valid ISO8601 day string pattern (YYYY-MM-DD).
173
+ *
174
+ * @param input - The string to test
175
+ * @returns True if the input starts with a valid ISO8601 day string pattern
176
+ */
142
177
  export declare function isISO8601DayStringStart(input: string): input is ISO8601DayString;
143
178
  /**
144
179
  * Date that is represented by slashes. Is considered in the Month/Day/Year format.
@@ -148,12 +183,20 @@ export type MonthDaySlashDate = string;
148
183
  * Regex for a MonthDaySlashDate.
149
184
  */
150
185
  export declare const MONTH_DAY_SLASH_DATE_STRING_REGEX: RegExp;
186
+ /**
187
+ * Determines if a string is a valid Month/Day/Year slash date format.
188
+ *
189
+ * @param input - The string to test
190
+ * @returns True if the input is a valid Month/Day/Year slash date
191
+ */
151
192
  export declare function isMonthDaySlashDate(input: string): input is MonthDaySlashDate;
152
193
  /**
153
- * Converts the input MonthDaySlashDate to an ISO8601DayString.
194
+ * Converts the input MonthDaySlashDate (MM/DD/YYYY) to an ISO8601DayString (YYYY-MM-DD).
195
+ * Handles single digit months and days by adding leading zeros.
196
+ * If year is only 2 digits, prepends '20' to make a 4-digit year.
154
197
  *
155
- * @param slashDate
156
- * @returns
198
+ * @param slashDate - The slash date string to convert (e.g., '1/1/20' or '11/15/2022')
199
+ * @returns An ISO8601 formatted day string (YYYY-MM-DD)
157
200
  */
158
201
  export declare function monthDaySlashDateToDateString(slashDate: MonthDaySlashDate): ISO8601DayString;
159
202
  /**
@@ -171,13 +214,37 @@ export type Seconds = number;
171
214
  export type Minutes = number;
172
215
  export type Hours = number;
173
216
  export type Days = number;
217
+ /**
218
+ * Number of hours in a day.
219
+ */
174
220
  export declare const HOURS_IN_DAY = 24;
221
+ /**
222
+ * Number of seconds in a minute.
223
+ */
175
224
  export declare const SECONDS_IN_MINUTE = 60;
225
+ /**
226
+ * Number of minutes in a day.
227
+ */
176
228
  export declare const MINUTES_IN_DAY = 1440;
229
+ /**
230
+ * Number of minutes in an hour.
231
+ */
177
232
  export declare const MINUTES_IN_HOUR = 60;
233
+ /**
234
+ * Number of milliseconds in a second.
235
+ */
178
236
  export declare const MS_IN_SECOND = 1000;
237
+ /**
238
+ * Number of milliseconds in a minute.
239
+ */
179
240
  export declare const MS_IN_MINUTE: number;
241
+ /**
242
+ * Number of milliseconds in an hour.
243
+ */
180
244
  export declare const MS_IN_HOUR: number;
245
+ /**
246
+ * Number of milliseconds in a day.
247
+ */
181
248
  export declare const MS_IN_DAY: number;
182
249
  /**
183
250
  * Day of the month, 1-31
@@ -194,13 +261,26 @@ export type MonthOfYear = number;
194
261
  */
195
262
  export type DateMonth = number;
196
263
  /**
197
- * Retrieves the MonthOfYear value from the input Date.
264
+ * Retrieves the MonthOfYear value (1-12) from the input Date.
265
+ * Converts JavaScript's 0-based month (0-11) to a 1-based month (1-12).
198
266
  *
199
- * @param date
200
- * @returns
267
+ * @param date - The date to extract the month from
268
+ * @returns The month of year as a number from 1-12
201
269
  */
202
270
  export declare function monthOfYearFromDate(date: Date): MonthOfYear;
271
+ /**
272
+ * Converts a JavaScript Date month (0-11) to a MonthOfYear (1-12).
273
+ *
274
+ * @param dateMonth - JavaScript Date month (0-11)
275
+ * @returns The month of year as a number from 1-12
276
+ */
203
277
  export declare function monthOfYearFromDateMonth(dateMonth: DateMonth): MonthOfYear;
278
+ /**
279
+ * Converts a MonthOfYear (1-12) to a JavaScript Date month (0-11).
280
+ *
281
+ * @param monthOfYear - Month of year (1-12)
282
+ * @returns JavaScript Date month (0-11)
283
+ */
204
284
  export declare function makeDateMonthForMonthOfYear(monthOfYear: MonthOfYear): DateMonth;
205
285
  /**
206
286
  * Year number. I.E. 2022
@@ -211,34 +291,36 @@ export type YearNumber = number;
211
291
  */
212
292
  export type DateRelativeState = DateRelativeDirection | 'present';
213
293
  /**
214
- * Returns true if the value is a date.
294
+ * Returns true if the value is a Date object.
295
+ * Uses both instanceof and Object.prototype.toString for reliable type checking.
215
296
  *
216
- * @param value
217
- * @returns
297
+ * @param value - The value to check
298
+ * @returns True if the value is a Date object
218
299
  */
219
300
  export declare function isDate(value: unknown): value is Date;
220
301
  /**
221
- * Returns true if the two input dates are equal.
302
+ * Returns true if the two input dates represent the same point in time.
303
+ * Compares the timestamp values rather than the object references.
222
304
  *
223
- * @param a
224
- * @param b
225
- * @returns
305
+ * @param a - First date to compare
306
+ * @param b - Second date to compare
307
+ * @returns True if the dates represent the same point in time
226
308
  */
227
309
  export declare function isEqualDate(a: Date, b: Date): boolean;
228
310
  /**
229
- * Returns true if the input date is in the past.
311
+ * Returns true if the input date is in the past relative to the current time.
230
312
  *
231
- * @param input
232
- * @returns
313
+ * @param input - The date to check
314
+ * @returns True if the date is in the past
233
315
  */
234
316
  export declare function isPast(input: Date): boolean;
235
317
  /**
236
- * Adds milliseconds to the input date.
237
- *
238
- * If no date is input, then returns the input.
318
+ * Adds milliseconds to the input date, returning a new Date object.
319
+ * If no date is input, then returns the input unchanged.
239
320
  *
240
- * @param input
241
- * @param ms
321
+ * @param input - The date to add milliseconds to
322
+ * @param ms - The number of milliseconds to add (defaults to 0 if null or undefined)
323
+ * @returns A new Date with the added milliseconds, or the original input if not a Date
242
324
  */
243
325
  export declare function addMilliseconds(input: Date, ms: Maybe<Milliseconds>): Date;
244
326
  export declare function addMilliseconds(input: MaybeNot, ms: Maybe<Milliseconds>): MaybeNot;
@@ -10,22 +10,45 @@ import { type Maybe } from '../value/maybe.type';
10
10
  * - 120
11
11
  */
12
12
  export type ReadableTimeString = string;
13
+ /**
14
+ * Enumeration of AM/PM time indicators.
15
+ */
13
16
  export declare enum TimeAM {
14
17
  AM = "AM",
15
18
  PM = "PM"
16
19
  }
20
+ /**
21
+ * Constant representing the current time/date.
22
+ * Used in logical date calculations to indicate "now".
23
+ */
17
24
  export declare const DATE_NOW_VALUE = "now";
25
+ /**
26
+ * Type representing the current date/time value.
27
+ */
18
28
  export type DateNow = typeof DATE_NOW_VALUE;
29
+ /**
30
+ * String codes that represent logical dates, such as 'now'.
31
+ */
19
32
  export type LogicalDateStringCode = DateNow;
20
33
  /**
21
34
  * A date that is characterized by either a known string value, or a Date.
22
35
  */
23
36
  export type LogicalDate = Date | LogicalDateStringCode;
24
37
  /**
25
- * Returns a Date value from the input LogicalDate.
38
+ * Converts a LogicalDate into an actual Date object.
39
+ * If the LogicalDate is already a Date, it's returned as is.
40
+ * If it's a string code like 'now', it's converted to the appropriate Date value.
26
41
  *
27
- * @param logicalDate
42
+ * @param logicalDate - A LogicalDate value to convert (Date object or string code)
43
+ * @returns A Date object representing the logical date, or null/undefined if input was null/undefined
28
44
  */
29
45
  export declare function dateFromLogicalDate(logicalDate: LogicalDate): Date;
30
46
  export declare function dateFromLogicalDate(logicalDate: Maybe<LogicalDate>): Maybe<Date>;
47
+ /**
48
+ * Determines if the input value is a recognized LogicalDateStringCode.
49
+ * Currently, only the 'now' value is recognized as a LogicalDateStringCode.
50
+ *
51
+ * @param logicalDate - The value to check
52
+ * @returns True if the value is a recognized LogicalDateStringCode
53
+ */
31
54
  export declare function isLogicalDateStringCode(logicalDate: Maybe<string | LogicalDate>): logicalDate is LogicalDateStringCode;
@@ -10,12 +10,12 @@ export interface Expires {
10
10
  expiresAt?: Maybe<Date>;
11
11
  }
12
12
  /**
13
- * expirationDetails() input.
13
+ * Input configuration for the expirationDetails() function.
14
14
  *
15
15
  * The priority that the expiration calculation uses takes the following order:
16
- * 1. expires
17
- * 2. expiresAt
18
- * 3. date + expiresIn
16
+ * 1. expires - An existing Expires object
17
+ * 2. expiresAt - A specific date when something expires
18
+ * 3. expiresFromDate + expiresIn - A base date plus a duration
19
19
  */
20
20
  export interface ExpirationDetailsInput<T extends Expires = Expires> extends Expires {
21
21
  /**
@@ -69,17 +69,20 @@ export interface ExpirationDetails<T extends Expires = Expires> {
69
69
  getExpirationDate(nowOverride?: Maybe<Date>): Maybe<Date>;
70
70
  }
71
71
  /**
72
- * Returns expiration details for the input.
72
+ * Returns expiration details for the input configuration.
73
+ * Creates an object that can determine when something expires based on various inputs.
73
74
  *
74
- * @param input
75
- * @returns
75
+ * @template T - The type of Expires object
76
+ * @param input - Configuration for calculating expiration
77
+ * @returns An ExpirationDetails object that can determine expiration state
76
78
  */
77
79
  export declare function expirationDetails<T extends Expires = Expires>(input: ExpirationDetailsInput<T>): ExpirationDetails<T>;
78
80
  /**
79
81
  * Convenience function for calculating and returning the expiration date given the input.
82
+ * This is a shorthand for expirationDetails(input).getExpirationDate().
80
83
  *
81
- * @param input Input used to calculate the expiration date.
82
- * @returns The expiration date, if applicable.
84
+ * @param input - Input configuration used to calculate the expiration date
85
+ * @returns The calculated expiration date, or null if no expiration is defined
83
86
  */
84
87
  export declare function calculateExpirationDate(input: ExpirationDetailsInput<any>): Maybe<Date>;
85
88
  /**
@@ -100,29 +103,32 @@ export declare function isUnderThreshold(threshold: Milliseconds, nextRunAt: May
100
103
  * Convenience function for quickly calculating throttling given a throttle time and last run time.
101
104
  *
102
105
  * Returns true if the throttle time has not passed since the last run time, compared to now.
103
-
104
- * @param throttleTime Time after "now" that expiration will occur.
105
- * @param lastRunAt Time the last run occurred. If the run has never occured then this function will return false.
106
- * @param now Optional override for the current time. Defaults to the current time.
107
- * @returns True if the throttle time has not passed since the last run time, compared to now.
106
+ * This is useful for rate limiting operations (e.g., "only allow this action once every X milliseconds").
107
+ *
108
+ * @param throttleTime - Minimum time in milliseconds that must pass between operations
109
+ * @param lastRunAt - Timestamp when the operation was last performed
110
+ * @param now - Optional override for the current time (defaults to the current time)
111
+ * @returns True if the operation should be throttled (not enough time has passed), false otherwise
108
112
  */
109
113
  export declare function isThrottled(throttleTime: Maybe<Milliseconds>, lastRunAt: Maybe<DateOrUnixDateTimeNumber>, now?: Maybe<Date>): boolean;
110
114
  /**
111
- * Returns true if any of the input ExpirationDetails have not expired.
115
+ * Returns true if at least one of the input ExpirationDetails has not expired.
116
+ * Useful for checking if any items in a collection are still valid.
112
117
  *
113
118
  * If the list is empty, returns false.
114
119
  *
115
- * @param details List of ExpirationDetails to check.
116
- * @returns True if any of the input ExpirationDetails have not expired.
120
+ * @param details - Collection of ExpirationDetails to check
121
+ * @returns True if at least one item has not expired, false otherwise
117
122
  */
118
123
  export declare function checkAtleastOneNotExpired(details: ExpirationDetails<any>[]): boolean;
119
124
  /**
120
125
  * Returns true if any of the input ExpirationDetails have expired.
126
+ * Useful for checking if any items in a collection need to be refreshed or removed.
121
127
  *
122
- * If the list is empty, returns the value of the second argument.
128
+ * If the list is empty, returns the value specified by defaultIfEmpty.
123
129
  *
124
- * @param details List of ExpirationDetails to check.
125
- * @param defaultIfEmpty Default value to return if the list is empty. True by default.
126
- * @returns True if any of the input ExpirationDetails have expired.
130
+ * @param details - Collection of ExpirationDetails to check
131
+ * @param defaultIfEmpty - Default value to return if the list is empty (defaults to true)
132
+ * @returns True if any item has expired, or the defaultIfEmpty value for an empty list
127
133
  */
128
134
  export declare function checkAnyHaveExpired(details: ExpirationDetails<any>[], defaultIfEmpty?: boolean): boolean;
@@ -82,33 +82,20 @@ export interface Timer extends Destroyable {
82
82
  */
83
83
  setDuration(duration: Milliseconds): void;
84
84
  }
85
+ /**
86
+ * Error thrown when the timer is destroyed before it was completed.
87
+ */
85
88
  export declare class TimerCancelledError extends BaseError {
86
89
  constructor();
87
90
  }
88
- export declare class TimerInstance implements Timer {
89
- private _createdAt;
90
- private _startedAt;
91
- private _pausedAt?;
92
- private _state;
93
- private _duration;
94
- private _promiseRef;
95
- constructor(duration: Milliseconds, startImmediately?: boolean);
96
- get state(): TimerState;
97
- get createdAt(): Date;
98
- get pausedAt(): Maybe<Date>;
99
- get startedAt(): Date;
100
- get promise(): Promise<void>;
101
- get duration(): Milliseconds;
102
- get durationRemaining(): Maybe<Milliseconds>;
103
- start(): void;
104
- stop(): void;
105
- reset(): void;
106
- setDuration(duration: Milliseconds): void;
107
- destroy(): void;
108
- private _checkComplete;
109
- private _enqueueCheck;
110
- }
111
- export declare function timer(duration: Milliseconds, startNow?: boolean): Timer;
91
+ /**
92
+ * Creates a new Timer from the input duration.
93
+ *
94
+ * @param duration - The duration of the timer.
95
+ * @param startImmediately - Whether the timer should start immediately. Defaults to true.
96
+ * @returns The new Timer.
97
+ */
98
+ export declare function makeTimer(duration: Milliseconds, startImmediately?: boolean): Timer;
112
99
  /**
113
100
  * Toggles the input Timer's running state.
114
101
  *
@@ -120,3 +107,7 @@ export declare function toggleTimerRunning(timer: Timer, toggleRun?: boolean): v
120
107
  * Returns the approximate end date of the given timer. If a timer is already complete, it returns the time for now.
121
108
  */
122
109
  export declare function approximateTimerEndDate(timer: Timer): Maybe<Date>;
110
+ /**
111
+ * @deprecated use makeTimer instead of timer.
112
+ */
113
+ export declare const timer: typeof makeTimer;
@@ -121,6 +121,8 @@ export declare function separateValues<T>(values: T[], checkInclusion: DecisionF
121
121
  */
122
122
  export declare function groupValues<T, R, K extends PrimativeKey & keyof R>(values: T[], groupKeyFn: ReadKeyFunction<T, K>): KeyedGroupingResult<T, R>;
123
123
  export declare function groupValues<T, K extends PrimativeKey = PrimativeKey>(values: T[], groupKeyFn: ReadKeyFunction<T, K>): GroupingResult<T>;
124
+ export declare function groupValues<T, R, K extends PrimativeKey & keyof R>(values: Maybe<T[]>, groupKeyFn: ReadKeyFunction<T, K>): KeyedGroupingResult<T, R>;
125
+ export declare function groupValues<T, K extends PrimativeKey = PrimativeKey>(values: Maybe<T[]>, groupKeyFn: ReadKeyFunction<T, K>): GroupingResult<T>;
124
126
  /**
125
127
  * Reads keys from the values in the arrays, and groups them together into a Map.
126
128
  *
@@ -129,3 +131,4 @@ export declare function groupValues<T, K extends PrimativeKey = PrimativeKey>(va
129
131
  * @returns
130
132
  */
131
133
  export declare function makeValuesGroupMap<T, K extends PrimativeKey = PrimativeKey>(values: T[], groupKeyFn: ReadKeyFunction<T, K>): Map<Maybe<K>, T[]>;
134
+ export declare function makeValuesGroupMap<T, K extends PrimativeKey = PrimativeKey>(values: Maybe<T[]>, groupKeyFn: ReadKeyFunction<T, K>): Map<Maybe<K>, T[]>;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  /**
4
2
  * Reads the input stream and encodes the data to a string.
5
3
  */
@@ -1,36 +1,40 @@
1
1
  import { type Maybe } from '../value/maybe.type';
2
- export declare enum RelationChange {
2
+ /**
3
+ * Type of relation change to perform on a collection of models.
4
+ */
5
+ export declare const RelationChange: {
3
6
  /**
4
7
  * Adds a model to the relation. If the model already exists in
5
8
  * the relation, the new one is used.
6
9
  *
7
10
  * Use INSERT to merge the two values together.
8
11
  */
9
- ADD = "add",
12
+ readonly ADD: "add";
10
13
  /**
11
14
  * Sets the relation to be equal to the input.
12
15
  */
13
- SET = "set",
16
+ readonly SET: "set";
14
17
  /**
15
18
  * Variation of SET that performs REMOVE on the collection, and then follows it up with INSERT.
16
19
  *
17
20
  * This can allow the modification function to behave selectively with the items targeted for removal.
18
21
  */
19
- REMOVE_AND_INSERT = "remove_and_insert",
22
+ readonly REMOVE_AND_INSERT: "remove_and_insert";
20
23
  /**
21
24
  * Removes a model from the relation.
22
25
  */
23
- REMOVE = "remove",
26
+ readonly REMOVE: "remove";
24
27
  /**
25
28
  * Updates an existing relation, if it exists.
26
29
  * The existing object is merged with the update object.
27
30
  */
28
- UPDATE = "update",
31
+ readonly UPDATE: "update";
29
32
  /**
30
33
  * Updates an existing relation, if it exists, or creates a new one.
31
34
  */
32
- INSERT = "insert"
33
- }
35
+ readonly INSERT: "insert";
36
+ };
37
+ export type RelationChangeType = (typeof RelationChange)[keyof typeof RelationChange];
34
38
  export type RelationString = string;
35
39
  export type RelationObject = RelationString | object;
36
40
  export type RelationModelType = string;
@@ -69,9 +73,9 @@ export interface UpdateMiltiTypeRelationConfig<T> extends UpdateRelationConfig<T
69
73
  * For instance, a string collection of keys.
70
74
  */
71
75
  export declare class ModelRelationUtility {
72
- static modifyStringCollection(current: Maybe<RelationString[]>, change: RelationChange, mods: RelationString[]): RelationString[];
73
- static modifyCollection<T extends RelationObject>(current: Maybe<T[]>, change: RelationChange, mods: T[], config: UpdateRelationConfig<T>): T[];
74
- static modifyCollection<T extends RelationObject>(current: Maybe<T[]>, change: RelationChange, mods: T[], config: UpdateMiltiTypeRelationConfig<T>): T[];
76
+ static modifyStringCollection(current: Maybe<RelationString[]>, change: RelationChangeType, mods: RelationString[]): RelationString[];
77
+ static modifyCollection<T extends RelationObject>(current: Maybe<T[]>, change: RelationChangeType, mods: T[], config: UpdateRelationConfig<T>): T[];
78
+ static modifyCollection<T extends RelationObject>(current: Maybe<T[]>, change: RelationChangeType, mods: T[], config: UpdateMiltiTypeRelationConfig<T>): T[];
75
79
  /**
76
80
  * The mask results are merged together.
77
81
  *
@@ -4,7 +4,7 @@ import { type PrimativeKey, type ReadKeyFunction } from '../key';
4
4
  */
5
5
  export declare enum SetDeltaChange {
6
6
  REMOVED = -1,
7
- NONE = 0,
7
+ NONE = 0,// No change
8
8
  ADDED = 1
9
9
  }
10
10
  /**
@@ -59,7 +59,7 @@ export interface PrimativeKeyStringDencoderConfig<D extends PrimativeKey, E exte
59
59
  *
60
60
  * If a single value is input that produces a nullish value, an error is thrown.
61
61
  */
62
- export type PrimativeKeyStringDencoderFunction<D extends PrimativeKey, E extends PrimativeKey> = ((encodedValues: string) => (E | D)[]) & ((decodedValues: (E | D)[]) => string);
62
+ export type PrimativeKeyStringDencoderFunction<D extends PrimativeKey, E extends PrimativeKey, S extends string = string> = ((encodedValues: S) => (E | D)[]) & ((decodedValues: (E | D)[]) => S);
63
63
  /**
64
64
  * Creates a new PrimativeKeyStringDencoderFunction.
65
65
  *
@@ -1,13 +1,26 @@
1
1
  import { type ArrayOrValue } from './../array/array';
2
2
  import { type Maybe } from '../value/maybe.type';
3
+ import { type PrimativeValue } from '../type';
3
4
  /**
4
- * Represents a single CSS class
5
+ * Represents a single CSS Class
5
6
  */
6
7
  export type CssClass = string;
8
+ /**
9
+ * Represents a single CSS Style
10
+ */
11
+ export type CssStyle = string;
7
12
  /**
8
13
  * Represents one or more CssClasses that are space separated.
9
14
  */
10
15
  export type SpaceSeparatedCssClasses = string;
16
+ /**
17
+ * Key-value object of CSS style values.
18
+ */
19
+ export type CssStyleObject = Record<string, Maybe<PrimativeValue>>;
20
+ /**
21
+ * Represents one or more CssStyles that are space separated.
22
+ */
23
+ export type SpaceSeparatedCssStyles = string;
11
24
  /**
12
25
  * One or more arrays of one or more CSS classes/arrays of classes.
13
26
  */