@dereekb/util 13.11.14 → 13.11.15
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.
- package/eslint/index.cjs.js +10008 -394
- package/eslint/index.esm.js +9982 -392
- package/eslint/package.json +4 -4
- package/eslint/src/lib/comments.d.ts +14 -3
- package/eslint/src/lib/dbx-tag-families.d.ts +280 -0
- package/eslint/src/lib/index.d.ts +26 -3
- package/eslint/src/lib/jsdoc-parser.d.ts +116 -0
- package/eslint/src/lib/no-inline-string-empty-object-intersection.rule.d.ts +44 -0
- package/eslint/src/lib/no-inline-type-import.rule.d.ts +38 -0
- package/eslint/src/lib/no-sister-re-export.rule.d.ts +69 -0
- package/eslint/src/lib/plugin.d.ts +52 -1
- package/eslint/src/lib/prefer-canonical-jsdoc.rule.d.ts +68 -0
- package/eslint/src/lib/prefer-config-object.rule.d.ts +61 -0
- package/eslint/src/lib/prefer-maybe-type.rule.d.ts +72 -0
- package/eslint/src/lib/prefer-no-side-effects-in-jsdoc.rule.d.ts +1 -1
- package/eslint/src/lib/prefer-suggested-string.rule.d.ts +51 -0
- package/eslint/src/lib/require-constant-naming.rule.d.ts +63 -0
- package/eslint/src/lib/require-dbx-action-companion-tags.rule.d.ts +46 -0
- package/eslint/src/lib/require-dbx-auth-companion-tags.rule.d.ts +45 -0
- package/eslint/src/lib/require-dbx-docs-ui-example-companion-tags.rule.d.ts +42 -0
- package/eslint/src/lib/require-dbx-filter-companion-tags.rule.d.ts +43 -0
- package/eslint/src/lib/require-dbx-form-field-companion-tags.rule.d.ts +46 -0
- package/eslint/src/lib/require-dbx-model-companion-tags.rule.d.ts +46 -0
- package/eslint/src/lib/require-dbx-model-firebase-index-companion-tags.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-model-snapshot-field-companion-tags.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-pipe-companion-tags.rule.d.ts +43 -0
- package/eslint/src/lib/require-dbx-rule-companion-tags.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-util-companion-tags.rule.d.ts +74 -0
- package/eslint/src/lib/require-dbx-web-companion-tags.rule.d.ts +43 -0
- package/eslint/src/lib/require-default-prefix-naming.rule.d.ts +60 -0
- package/eslint/src/lib/require-deprecated-alias-placement.rule.d.ts +75 -0
- package/eslint/src/lib/require-exported-jsdoc-example.rule.d.ts +61 -0
- package/eslint/src/lib/require-no-side-effects.rule.d.ts +1 -1
- package/eslint/src/lib/require-readonly-config-params.rule.d.ts +57 -0
- package/eslint/src/lib/require-single-return.rule.d.ts +42 -0
- package/fetch/index.cjs.js +95 -80
- package/fetch/index.esm.js +95 -80
- package/fetch/package.json +2 -2
- package/fetch/src/lib/error.d.ts +2 -2
- package/fetch/src/lib/fetch.d.ts +15 -15
- package/fetch/src/lib/fetch.file.d.ts +5 -5
- package/fetch/src/lib/fetch.limit.d.ts +2 -2
- package/fetch/src/lib/fetch.page.d.ts +1 -1
- package/fetch/src/lib/fetch.page.iterate.d.ts +4 -4
- package/fetch/src/lib/fetch.type.d.ts +3 -2
- package/fetch/src/lib/fetch.url.d.ts +13 -13
- package/fetch/src/lib/json.d.ts +12 -12
- package/fetch/src/lib/timeout.d.ts +2 -2
- package/fetch/src/lib/url.d.ts +11 -11
- package/index.cjs.js +2592 -2329
- package/index.esm.js +2590 -2327
- package/package.json +1 -1
- package/src/lib/array/array.boolean.d.ts +20 -20
- package/src/lib/array/array.d.ts +73 -72
- package/src/lib/array/array.factory.d.ts +8 -5
- package/src/lib/array/array.filter.d.ts +23 -20
- package/src/lib/array/array.find.d.ts +9 -8
- package/src/lib/array/array.index.d.ts +15 -14
- package/src/lib/array/array.indexed.d.ts +22 -19
- package/src/lib/array/array.make.d.ts +3 -2
- package/src/lib/array/array.map.d.ts +5 -5
- package/src/lib/array/array.number.d.ts +27 -27
- package/src/lib/array/array.random.d.ts +11 -10
- package/src/lib/array/array.set.d.ts +14 -14
- package/src/lib/array/array.string.d.ts +31 -31
- package/src/lib/array/array.unique.d.ts +22 -20
- package/src/lib/array/array.value.d.ts +3 -2
- package/src/lib/assertion/assert.error.d.ts +8 -8
- package/src/lib/assertion/assertion.d.ts +5 -5
- package/src/lib/assertion/assertion.generic.d.ts +3 -3
- package/src/lib/assertion/assertion.number.d.ts +6 -6
- package/src/lib/auth/auth.role.claims.d.ts +12 -11
- package/src/lib/auth/auth.role.d.ts +3 -3
- package/src/lib/auth/pkce.d.ts +2 -2
- package/src/lib/boolean.d.ts +11 -11
- package/src/lib/cache/cache.memoize.d.ts +6 -6
- package/src/lib/contact/domain.d.ts +9 -9
- package/src/lib/contact/email.d.ts +11 -11
- package/src/lib/contact/phone.d.ts +12 -12
- package/src/lib/contact/random.d.ts +11 -9
- package/src/lib/date/date.d.ts +60 -59
- package/src/lib/date/date.time.d.ts +2 -2
- package/src/lib/date/date.unix.d.ts +8 -8
- package/src/lib/date/duration.d.ts +17 -17
- package/src/lib/date/expires.d.ts +29 -27
- package/src/lib/date/hour.d.ts +23 -23
- package/src/lib/date/minute.d.ts +6 -6
- package/src/lib/date/time.d.ts +10 -9
- package/src/lib/date/week.d.ts +32 -31
- package/src/lib/encryption/encryption.object.d.ts +3 -3
- package/src/lib/error/error.d.ts +13 -12
- package/src/lib/error/error.server.d.ts +4 -4
- package/src/lib/file/pdf.d.ts +4 -4
- package/src/lib/filter/filter.d.ts +3 -2
- package/src/lib/function/function.boolean.d.ts +4 -3
- package/src/lib/function/function.forward.d.ts +6 -4
- package/src/lib/getter/getter.d.ts +24 -19
- package/src/lib/getter/getter.map.d.ts +6 -5
- package/src/lib/getter/getter.util.d.ts +3 -2
- package/src/lib/grouping.d.ts +25 -24
- package/src/lib/hash.d.ts +11 -10
- package/src/lib/iterable/iterable.d.ts +39 -39
- package/src/lib/iterable/iterable.map.d.ts +3 -3
- package/src/lib/key.d.ts +16 -16
- package/src/lib/map/map.d.ts +12 -12
- package/src/lib/map/map.intersection.d.ts +3 -3
- package/src/lib/map/map.key.d.ts +16 -14
- package/src/lib/misc/host.d.ts +2 -2
- package/src/lib/model/id.batch.d.ts +4 -3
- package/src/lib/model/id.factory.d.ts +4 -3
- package/src/lib/model/model.conversion.d.ts +19 -14
- package/src/lib/model/model.conversion.field.d.ts +2 -2
- package/src/lib/model/model.copy.d.ts +5 -4
- package/src/lib/model/model.d.ts +48 -46
- package/src/lib/model/model.modify.d.ts +10 -8
- package/src/lib/nodejs/stream.d.ts +6 -5
- package/src/lib/number/bitwise.dencoder.d.ts +12 -12
- package/src/lib/number/bound.d.ts +16 -13
- package/src/lib/number/dollar.d.ts +6 -5
- package/src/lib/number/encoded.d.ts +7 -7
- package/src/lib/number/factory.d.ts +4 -3
- package/src/lib/number/number.d.ts +37 -37
- package/src/lib/number/random.d.ts +11 -10
- package/src/lib/number/round.d.ts +34 -30
- package/src/lib/number/sort.d.ts +3 -2
- package/src/lib/number/transform.d.ts +5 -4
- package/src/lib/object/object.array.d.ts +6 -6
- package/src/lib/object/object.array.delta.d.ts +3 -2
- package/src/lib/object/object.d.ts +12 -12
- package/src/lib/object/object.empty.d.ts +3 -3
- package/src/lib/object/object.equal.d.ts +11 -10
- package/src/lib/object/object.filter.pojo.d.ts +74 -74
- package/src/lib/object/object.filter.tuple.d.ts +26 -26
- package/src/lib/object/object.flatten.d.ts +4 -4
- package/src/lib/object/object.key.d.ts +6 -4
- package/src/lib/object/object.map.d.ts +15 -13
- package/src/lib/page/page.d.ts +5 -5
- package/src/lib/page/page.filter.d.ts +8 -8
- package/src/lib/path/path.d.ts +98 -88
- package/src/lib/promise/callback.d.ts +2 -2
- package/src/lib/promise/is.d.ts +6 -6
- package/src/lib/promise/poll.d.ts +9 -9
- package/src/lib/promise/promise.d.ts +33 -30
- package/src/lib/promise/promise.factory.d.ts +4 -3
- package/src/lib/promise/promise.loop.d.ts +11 -11
- package/src/lib/promise/promise.task.d.ts +6 -5
- package/src/lib/promise/promise.type.d.ts +3 -3
- package/src/lib/promise/use.d.ts +3 -3
- package/src/lib/relation/relation.d.ts +15 -15
- package/src/lib/service/handler.config.d.ts +20 -16
- package/src/lib/service/handler.d.ts +3 -2
- package/src/lib/service/typed.service.d.ts +2 -2
- package/src/lib/set/set.d.ts +62 -59
- package/src/lib/set/set.delta.d.ts +5 -4
- package/src/lib/set/set.hashset.d.ts +5 -5
- package/src/lib/set/set.selection.d.ts +5 -4
- package/src/lib/sort.d.ts +11 -11
- package/src/lib/storage/storage.d.ts +2 -1
- package/src/lib/storage/storage.error.d.ts +4 -4
- package/src/lib/storage/storage.memory.d.ts +7 -7
- package/src/lib/storage/storage.object.d.ts +5 -5
- package/src/lib/string/case.d.ts +6 -6
- package/src/lib/string/char.d.ts +30 -29
- package/src/lib/string/dencoder.d.ts +25 -20
- package/src/lib/string/factory.d.ts +11 -8
- package/src/lib/string/html.d.ts +19 -19
- package/src/lib/string/mimetype.d.ts +9 -8
- package/src/lib/string/prefix.d.ts +8 -8
- package/src/lib/string/replace.d.ts +45 -39
- package/src/lib/string/search.d.ts +5 -4
- package/src/lib/string/sort.d.ts +13 -4
- package/src/lib/string/string.d.ts +44 -43
- package/src/lib/string/transform.d.ts +32 -23
- package/src/lib/string/tree.d.ts +5 -4
- package/src/lib/string/url.d.ts +5 -4
- package/src/lib/tree/tree.array.d.ts +5 -4
- package/src/lib/tree/tree.expand.d.ts +6 -6
- package/src/lib/tree/tree.explore.d.ts +13 -10
- package/src/lib/tree/tree.flatten.d.ts +10 -10
- package/src/lib/type.d.ts +42 -12
- package/src/lib/value/address.d.ts +7 -7
- package/src/lib/value/bound.d.ts +70 -66
- package/src/lib/value/build.d.ts +6 -6
- package/src/lib/value/comparator.d.ts +19 -17
- package/src/lib/value/cron.d.ts +2 -2
- package/src/lib/value/decision.d.ts +6 -5
- package/src/lib/value/equal.d.ts +11 -9
- package/src/lib/value/indexed.d.ts +101 -85
- package/src/lib/value/label.d.ts +2 -2
- package/src/lib/value/map.d.ts +20 -16
- package/src/lib/value/maybe.d.ts +36 -36
- package/src/lib/value/modifier.d.ts +24 -23
- package/src/lib/value/point.d.ts +85 -77
- package/src/lib/value/url.d.ts +2 -2
- package/src/lib/value/use.d.ts +36 -33
- package/src/lib/value/vector.d.ts +15 -14
- package/test/index.cjs.js +41 -36
- package/test/index.esm.js +41 -36
- package/test/package.json +2 -2
- package/test/src/lib/jest/jest.fail.d.ts +2 -2
- package/test/src/lib/shared/shared.d.ts +20 -20
- package/test/src/lib/shared/shared.fail.d.ts +21 -16
- package/test/src/lib/shared/shared.function.d.ts +4 -4
- package/test/src/lib/shared/shared.wrap.d.ts +10 -10
|
@@ -11,15 +11,15 @@ export interface RandomEmailFactoryConfig {
|
|
|
11
11
|
/**
|
|
12
12
|
* Set of email prefixes to use
|
|
13
13
|
*/
|
|
14
|
-
prefixes?: ArrayOrValue<string>;
|
|
14
|
+
readonly prefixes?: ArrayOrValue<string>;
|
|
15
15
|
/**
|
|
16
16
|
* domains to use
|
|
17
17
|
*/
|
|
18
|
-
domains?: ArrayOrValue<EmailAddressDomain>;
|
|
18
|
+
readonly domains?: ArrayOrValue<EmailAddressDomain>;
|
|
19
19
|
/**
|
|
20
20
|
* Random number generator. Negative numbers are treated as an "ignored" value.
|
|
21
21
|
*/
|
|
22
|
-
numberFactory?: NumberFactory;
|
|
22
|
+
readonly numberFactory?: NumberFactory;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Default configuration that uses incrementing numbers and a test domain for safety in tests.
|
|
@@ -29,14 +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
|
+
* @param inputConfig - Optional configuration overrides.
|
|
33
|
+
* @returns A factory function that produces random email address strings.
|
|
34
|
+
*
|
|
32
35
|
* @dbxUtil
|
|
33
36
|
* @dbxUtilCategory contact
|
|
34
37
|
* @dbxUtilKind factory
|
|
35
38
|
* @dbxUtilTags contact, email, random, factory, generate
|
|
36
39
|
* @dbxUtilRelated random-phone-number-factory, incrementing-number-factory
|
|
37
40
|
*
|
|
38
|
-
* @param inputConfig - Optional configuration overrides
|
|
39
|
-
* @returns A factory function that produces random email address strings
|
|
40
41
|
* @__NO_SIDE_EFFECTS__
|
|
41
42
|
*/
|
|
42
43
|
export declare function randomEmailFactory(inputConfig?: RandomEmailFactoryConfig): RandomEmailFactory;
|
|
@@ -47,11 +48,11 @@ export interface RandomPhoneNumberFactoryConfig {
|
|
|
47
48
|
/**
|
|
48
49
|
* Set of interntional numbers to use.
|
|
49
50
|
*/
|
|
50
|
-
internationalAreaCodes?: ArrayOrValue<number>;
|
|
51
|
+
readonly internationalAreaCodes?: ArrayOrValue<number>;
|
|
51
52
|
/**
|
|
52
53
|
* Random number generator. Should generate a 10-digit number. Generated numbers are not validated.
|
|
53
54
|
*/
|
|
54
|
-
numberFactory?: NumberFactory;
|
|
55
|
+
readonly numberFactory?: NumberFactory;
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
58
|
* Default configuration using US area codes and random 7-digit number generation.
|
|
@@ -61,14 +62,15 @@ export type RandomPhoneNumberFactory = Factory<E164PhoneNumber>;
|
|
|
61
62
|
/**
|
|
62
63
|
* Creates a factory that generates random E.164 phone numbers using configurable area codes and number generators.
|
|
63
64
|
*
|
|
65
|
+
* @param inputConfig - Optional configuration overrides.
|
|
66
|
+
* @returns A factory function that produces random E.164 phone number strings.
|
|
67
|
+
*
|
|
64
68
|
* @dbxUtil
|
|
65
69
|
* @dbxUtilCategory contact
|
|
66
70
|
* @dbxUtilKind factory
|
|
67
71
|
* @dbxUtilTags contact, phone, e164, random, factory, generate
|
|
68
72
|
* @dbxUtilRelated random-email-factory, random-number-factory
|
|
69
73
|
*
|
|
70
|
-
* @param inputConfig - Optional configuration overrides
|
|
71
|
-
* @returns A factory function that produces random E.164 phone number strings
|
|
72
74
|
* @__NO_SIDE_EFFECTS__
|
|
73
75
|
*/
|
|
74
76
|
export declare function randomPhoneNumberFactory(inputConfig?: RandomPhoneNumberFactoryConfig): RandomPhoneNumberFactory;
|
package/src/lib/date/date.d.ts
CHANGED
|
@@ -44,13 +44,13 @@ export declare const ISO_8601_DATE_STRING_REGEX: RegExp;
|
|
|
44
44
|
/**
|
|
45
45
|
* Determines if a string is a valid ISO8601 date string.
|
|
46
46
|
*
|
|
47
|
+
* @param input - Value to test against the ISO8601 date string pattern.
|
|
48
|
+
* @returns True when the input matches the canonical ISO8601 date layout.
|
|
49
|
+
*
|
|
47
50
|
* @dbxUtil
|
|
48
51
|
* @dbxUtilCategory date
|
|
49
52
|
* @dbxUtilTags date, iso8601, string, predicate, validate
|
|
50
53
|
* @dbxUtilRelated is-iso8601-day-string, is-utc-date-string, iso-8601-date-string-regex
|
|
51
|
-
*
|
|
52
|
-
* @param input - The string to test
|
|
53
|
-
* @returns True if the input is a valid ISO8601 date string
|
|
54
54
|
*/
|
|
55
55
|
export declare function isISO8601DateString(input: string): input is ISO8601DateString;
|
|
56
56
|
/**
|
|
@@ -80,13 +80,13 @@ export declare const UTC_DATE_STRING_REGEX: RegExp;
|
|
|
80
80
|
/**
|
|
81
81
|
* Determines if a string is a valid UTC date string.
|
|
82
82
|
*
|
|
83
|
+
* @param input - Value to test against the UTC-formatted date string pattern.
|
|
84
|
+
* @returns True when the input matches the canonical UTC date layout.
|
|
85
|
+
*
|
|
83
86
|
* @dbxUtil
|
|
84
87
|
* @dbxUtilCategory date
|
|
85
88
|
* @dbxUtilTags date, utc, string, predicate, validate
|
|
86
89
|
* @dbxUtilRelated is-iso8601-date-string, utc-date-string-regex
|
|
87
|
-
*
|
|
88
|
-
* @param input - The string to test
|
|
89
|
-
* @returns True if the input is a valid UTC date string
|
|
90
90
|
*/
|
|
91
91
|
export declare function isUTCDateString(input: string): boolean;
|
|
92
92
|
/**
|
|
@@ -126,14 +126,14 @@ export interface TimezoneStringRef {
|
|
|
126
126
|
/**
|
|
127
127
|
* Returns true only if the inputs have the same timezone, or both do not have a timezone set.
|
|
128
128
|
*
|
|
129
|
+
* @param a - First object that may contain a timezone reference.
|
|
130
|
+
* @param b - Second object that may contain a timezone reference.
|
|
131
|
+
* @returns True if both objects have the same timezone or neither has a timezone set.
|
|
132
|
+
*
|
|
129
133
|
* @dbxUtil
|
|
130
134
|
* @dbxUtilCategory date
|
|
131
135
|
* @dbxUtilTags date, timezone, compare, equal, predicate
|
|
132
136
|
* @dbxUtilRelated is-considered-utc-timezone-string
|
|
133
|
-
*
|
|
134
|
-
* @param a - First object that may contain a timezone reference
|
|
135
|
-
* @param b - Second object that may contain a timezone reference
|
|
136
|
-
* @returns True if both objects have the same timezone or neither has a timezone set
|
|
137
137
|
*/
|
|
138
138
|
export declare function hasSameTimezone(a: Maybe<Partial<TimezoneStringRef>>, b: Maybe<Partial<TimezoneStringRef>>): boolean;
|
|
139
139
|
/**
|
|
@@ -214,13 +214,13 @@ export declare const ISO8601_DAY_STRING_START_REGEX: RegExp;
|
|
|
214
214
|
*
|
|
215
215
|
* I.E. 2022-01-02T04:00:00.000Z in GMT-6 returns 2022-01-02
|
|
216
216
|
*
|
|
217
|
+
* @param date - Reference instant whose UTC calendar day should be anchored.
|
|
218
|
+
* @returns Midnight UTC of the same UTC day as `date`.
|
|
219
|
+
*
|
|
217
220
|
* @dbxUtil
|
|
218
221
|
* @dbxUtilCategory date
|
|
219
222
|
* @dbxUtilTags date, utc, start-of-day, day, normalize
|
|
220
223
|
* @dbxUtilRelated start-of-day-for-system-date-in-utc, parse-iso8601-day-string-to-utc-date
|
|
221
|
-
*
|
|
222
|
-
* @param date - The date to get the start of day for
|
|
223
|
-
* @returns A new Date set to midnight UTC of the input date's UTC day
|
|
224
224
|
*/
|
|
225
225
|
export declare function startOfDayForUTCDateInUTC(date: Date): Date;
|
|
226
226
|
/**
|
|
@@ -228,49 +228,49 @@ export declare function startOfDayForUTCDateInUTC(date: Date): Date;
|
|
|
228
228
|
*
|
|
229
229
|
* I.E. 2022-01-02T04:00:00.000Z in GMT-6 (10PM Jan 1st CST) returns 2022-01-01
|
|
230
230
|
*
|
|
231
|
+
* @param date - Reference instant whose system-local calendar day should be anchored.
|
|
232
|
+
* @returns Midnight UTC corresponding to the local-time start of `date`.
|
|
233
|
+
*
|
|
231
234
|
* @dbxUtil
|
|
232
235
|
* @dbxUtilCategory date
|
|
233
236
|
* @dbxUtilTags date, utc, start-of-day, system, local
|
|
234
237
|
* @dbxUtilRelated start-of-day-for-utc-date-in-utc
|
|
235
|
-
*
|
|
236
|
-
* @param date - The date to get the start of local day for
|
|
237
|
-
* @returns A new Date set to midnight UTC of the input date's local day
|
|
238
238
|
*/
|
|
239
239
|
export declare function startOfDayForSystemDateInUTC(date: Date): Date;
|
|
240
240
|
/**
|
|
241
241
|
* Parses an ISO8601DayString (YYYY-MM-DD) to a UTC Date at midnight.
|
|
242
242
|
*
|
|
243
|
+
* @param inputDateString - ISO8601 day string to parse (e.g. '2022-01-15').
|
|
244
|
+
* @returns Midnight UTC of the calendar day named by `inputDateString`.
|
|
245
|
+
*
|
|
243
246
|
* @dbxUtil
|
|
244
247
|
* @dbxUtilCategory date
|
|
245
248
|
* @dbxUtilTags date, iso8601, day, parse, utc, convert
|
|
246
249
|
* @dbxUtilRelated is-iso8601-day-string, start-of-day-for-utc-date-in-utc
|
|
247
|
-
*
|
|
248
|
-
* @param inputDateString - The ISO8601 day string to parse (e.g., '2022-01-15')
|
|
249
|
-
* @returns A Date object set to midnight UTC on the specified day
|
|
250
250
|
*/
|
|
251
251
|
export declare function parseISO8601DayStringToUTCDate(inputDateString: ISO8601DayString): Date;
|
|
252
252
|
/**
|
|
253
253
|
* Determines if a string is a valid ISO8601 day string (YYYY-MM-DD format).
|
|
254
254
|
*
|
|
255
|
+
* @param input - Value to test against the ISO8601 day-string pattern.
|
|
256
|
+
* @returns True when the input is exactly a YYYY-MM-DD value.
|
|
257
|
+
*
|
|
255
258
|
* @dbxUtil
|
|
256
259
|
* @dbxUtilCategory date
|
|
257
260
|
* @dbxUtilTags date, iso8601, day, string, predicate, validate
|
|
258
261
|
* @dbxUtilRelated is-iso8601-day-string-start, parse-iso8601-day-string-to-utc-date, iso8601-day-string-regex
|
|
259
|
-
*
|
|
260
|
-
* @param input - The string to test
|
|
261
|
-
* @returns True if the input is a valid ISO8601 day string
|
|
262
262
|
*/
|
|
263
263
|
export declare function isISO8601DayString(input: string): input is ISO8601DayString;
|
|
264
264
|
/**
|
|
265
265
|
* Determines if a string starts with a valid ISO8601 day string pattern (YYYY-MM-DD).
|
|
266
266
|
*
|
|
267
|
+
* @param input - Value to test for an ISO8601 day-string prefix.
|
|
268
|
+
* @returns True when the input begins with a YYYY-MM-DD prefix.
|
|
269
|
+
*
|
|
267
270
|
* @dbxUtil
|
|
268
271
|
* @dbxUtilCategory date
|
|
269
272
|
* @dbxUtilTags date, iso8601, day, string, predicate, prefix
|
|
270
273
|
* @dbxUtilRelated is-iso8601-day-string, iso8601-day-string-start-regex
|
|
271
|
-
*
|
|
272
|
-
* @param input - The string to test
|
|
273
|
-
* @returns True if the input starts with a valid ISO8601 day string pattern
|
|
274
274
|
*/
|
|
275
275
|
export declare function isISO8601DayStringStart(input: string): input is ISO8601DayString;
|
|
276
276
|
/**
|
|
@@ -294,13 +294,13 @@ export declare const MONTH_DAY_SLASH_DATE_STRING_REGEX: RegExp;
|
|
|
294
294
|
/**
|
|
295
295
|
* Determines if a string is a valid Month/Day/Year slash date format.
|
|
296
296
|
*
|
|
297
|
+
* @param input - Value to test against the slash-separated date pattern.
|
|
298
|
+
* @returns True when the input matches the Month/Day/Year slash format.
|
|
299
|
+
*
|
|
297
300
|
* @dbxUtil
|
|
298
301
|
* @dbxUtilCategory date
|
|
299
302
|
* @dbxUtilTags date, slash, month, day, string, predicate, validate
|
|
300
303
|
* @dbxUtilRelated month-day-slash-date-to-date-string, month-day-slash-date-string-regex
|
|
301
|
-
*
|
|
302
|
-
* @param input - The string to test
|
|
303
|
-
* @returns True if the input is a valid Month/Day/Year slash date
|
|
304
304
|
*/
|
|
305
305
|
export declare function isMonthDaySlashDate(input: string): input is MonthDaySlashDate;
|
|
306
306
|
/**
|
|
@@ -308,13 +308,13 @@ export declare function isMonthDaySlashDate(input: string): input is MonthDaySla
|
|
|
308
308
|
* Handles single digit months and days by adding leading zeros.
|
|
309
309
|
* If year is only 2 digits, prepends '20' to make a 4-digit year.
|
|
310
310
|
*
|
|
311
|
+
* @param slashDate - The slash date string to convert (e.g., '1/1/20' or '11/15/2022')
|
|
312
|
+
* @returns An ISO8601 formatted day string (YYYY-MM-DD)
|
|
313
|
+
*
|
|
311
314
|
* @dbxUtil
|
|
312
315
|
* @dbxUtilCategory date
|
|
313
316
|
* @dbxUtilTags date, slash, day, string, convert, parse
|
|
314
317
|
* @dbxUtilRelated is-month-day-slash-date
|
|
315
|
-
*
|
|
316
|
-
* @param slashDate - The slash date string to convert (e.g., '1/1/20' or '11/15/2022')
|
|
317
|
-
* @returns An ISO8601 formatted day string (YYYY-MM-DD)
|
|
318
318
|
*/
|
|
319
319
|
export declare function monthDaySlashDateToDateString(slashDate: MonthDaySlashDate): ISO8601DayString;
|
|
320
320
|
/**
|
|
@@ -348,13 +348,13 @@ export declare function dateFromDateOrTimeMillisecondsNumber(input: Maybe<DateOr
|
|
|
348
348
|
/**
|
|
349
349
|
* Converts a unix timestamp number to a Date object.
|
|
350
350
|
*
|
|
351
|
+
* @param dateTimeNumber - Unix timestamp number to convert.
|
|
352
|
+
* @returns Date object if timestamp is valid, null/undefined if timestamp is null/undefined.
|
|
353
|
+
*
|
|
351
354
|
* @dbxUtil
|
|
352
355
|
* @dbxUtilCategory date
|
|
353
356
|
* @dbxUtilTags date, milliseconds, unix, convert, parse
|
|
354
357
|
* @dbxUtilRelated date-from-date-or-time-milliseconds-number, unix-date-time-seconds-number-to-date
|
|
355
|
-
*
|
|
356
|
-
* @param dateTimeNumber - Unix timestamp number to convert
|
|
357
|
-
* @returns Date object if timestamp is valid, null/undefined if timestamp is null/undefined
|
|
358
358
|
*/
|
|
359
359
|
export declare function unixMillisecondsNumberToDate(dateTimeNumber: Maybe<UnixDateTimeMillisecondsNumber>): Maybe<Date>;
|
|
360
360
|
/**
|
|
@@ -377,14 +377,14 @@ export type DateOrMilliseconds = Date | Milliseconds;
|
|
|
377
377
|
*
|
|
378
378
|
* If the input is a number of milliseconds, it is added to the current date.
|
|
379
379
|
*
|
|
380
|
+
* @param dateOrMilliseconds - Either a concrete Date or a millisecond offset from `now`.
|
|
381
|
+
* @param now - Anchor used to resolve a millisecond offset; defaults to the current time.
|
|
382
|
+
* @returns Resolved Date for either a direct value or the offset-from-now case.
|
|
383
|
+
*
|
|
380
384
|
* @dbxUtil
|
|
381
385
|
* @dbxUtilCategory date
|
|
382
386
|
* @dbxUtilTags date, milliseconds, convert, normalize, offset
|
|
383
387
|
* @dbxUtilRelated add-milliseconds, date-from-date-or-time-milliseconds-number
|
|
384
|
-
*
|
|
385
|
-
* @param dateOrMilliseconds - The date or milliseconds to convert to a Date.
|
|
386
|
-
* @param now - The current date to use when adding milliseconds. Defaults to the current time.
|
|
387
|
-
* @returns The Date representation of the input.
|
|
388
388
|
*/
|
|
389
389
|
export declare function dateOrMillisecondsToDate(dateOrMilliseconds: DateOrMilliseconds, now?: Maybe<Date>): Date;
|
|
390
390
|
/**
|
|
@@ -584,13 +584,13 @@ export type DateMonth = number;
|
|
|
584
584
|
*
|
|
585
585
|
* Converts JavaScript's 0-based month (0-11) to a 1-based month (1-12).
|
|
586
586
|
*
|
|
587
|
+
* @param date - Reference instant whose local month should be reported.
|
|
588
|
+
* @returns One-based local month-of-year, ready for human-facing display.
|
|
589
|
+
*
|
|
587
590
|
* @dbxUtil
|
|
588
591
|
* @dbxUtilCategory date
|
|
589
592
|
* @dbxUtilTags date, month, year, accessor, system, local
|
|
590
593
|
* @dbxUtilRelated month-of-year-from-date-month, month-of-year-from-utc-date
|
|
591
|
-
*
|
|
592
|
-
* @param date - The date to extract the month from
|
|
593
|
-
* @returns The month of year as a number from 1-12
|
|
594
594
|
*/
|
|
595
595
|
export declare function monthOfYearFromDate(date: Date): MonthOfYear;
|
|
596
596
|
/**
|
|
@@ -598,37 +598,38 @@ export declare function monthOfYearFromDate(date: Date): MonthOfYear;
|
|
|
598
598
|
*
|
|
599
599
|
* Converts JavaScript's 0-based month (0-11) to a 1-based month (1-12).
|
|
600
600
|
*
|
|
601
|
+
* @param date - Reference instant whose UTC month should be reported.
|
|
602
|
+
* @returns One-based UTC month-of-year, ready for human-facing display.
|
|
603
|
+
*
|
|
601
604
|
* @dbxUtil
|
|
602
605
|
* @dbxUtilCategory date
|
|
603
606
|
* @dbxUtilTags date, month, year, accessor, utc
|
|
604
607
|
* @dbxUtilRelated month-of-year-from-date, month-of-year-from-date-month
|
|
605
|
-
*
|
|
606
|
-
* @param date - The date to extract the month from
|
|
607
|
-
* @returns The month of year as a number from 1-12
|
|
608
608
|
*/
|
|
609
609
|
export declare function monthOfYearFromUTCDate(date: Date): MonthOfYear;
|
|
610
610
|
/**
|
|
611
611
|
* Converts a JavaScript Date month (0-11) to a MonthOfYear (1-12).
|
|
612
612
|
*
|
|
613
|
+
* @param dateMonth - JavaScript Date month (0-11)
|
|
614
|
+
* @returns The month of year as a number from 1-12.
|
|
615
|
+
*
|
|
613
616
|
* @dbxUtil
|
|
614
617
|
* @dbxUtilCategory date
|
|
615
618
|
* @dbxUtilTags date, month, year, convert, javascript
|
|
616
619
|
* @dbxUtilRelated make-date-month-for-month-of-year, month-of-year-from-date
|
|
617
|
-
*
|
|
618
|
-
* @param dateMonth - JavaScript Date month (0-11)
|
|
619
|
-
* @returns The month of year as a number from 1-12
|
|
620
620
|
*/
|
|
621
621
|
export declare function monthOfYearFromDateMonth(dateMonth: DateMonth): MonthOfYear;
|
|
622
622
|
/**
|
|
623
623
|
* Converts a MonthOfYear (1-12) to a JavaScript Date month (0-11).
|
|
624
624
|
*
|
|
625
|
+
* @param monthOfYear - Month of year (1-12)
|
|
626
|
+
* @returns JavaScript Date month (0-11)
|
|
627
|
+
*
|
|
625
628
|
* @dbxUtil
|
|
626
629
|
* @dbxUtilCategory date
|
|
627
630
|
* @dbxUtilTags date, month, convert, javascript
|
|
628
631
|
* @dbxUtilRelated month-of-year-from-date-month, month-of-year-from-date
|
|
629
632
|
*
|
|
630
|
-
* @param monthOfYear - Month of year (1-12)
|
|
631
|
-
* @returns JavaScript Date month (0-11)
|
|
632
633
|
* @__NO_SIDE_EFFECTS__
|
|
633
634
|
*/
|
|
634
635
|
export declare function makeDateMonthForMonthOfYear(monthOfYear: MonthOfYear): DateMonth;
|
|
@@ -648,39 +649,39 @@ export type DateRelativeState = DateRelativeDirection | 'present';
|
|
|
648
649
|
* Returns true if the value is a Date object.
|
|
649
650
|
* Uses both instanceof and Object.prototype.toString for reliable type checking.
|
|
650
651
|
*
|
|
652
|
+
* @param value - The value to check.
|
|
653
|
+
* @returns True if the value is a Date object.
|
|
654
|
+
*
|
|
651
655
|
* @dbxUtil
|
|
652
656
|
* @dbxUtilCategory date
|
|
653
657
|
* @dbxUtilTags date, predicate, type-guard, validate
|
|
654
658
|
* @dbxUtilRelated is-equal-date, is-past
|
|
655
|
-
*
|
|
656
|
-
* @param value - The value to check
|
|
657
|
-
* @returns True if the value is a Date object
|
|
658
659
|
*/
|
|
659
660
|
export declare function isDate(value: unknown): value is Date;
|
|
660
661
|
/**
|
|
661
662
|
* Returns true if the two input dates represent the same point in time.
|
|
662
663
|
* Compares the timestamp values rather than the object references.
|
|
663
664
|
*
|
|
665
|
+
* @param a - First date to compare.
|
|
666
|
+
* @param b - Second date to compare.
|
|
667
|
+
* @returns True if the dates represent the same point in time.
|
|
668
|
+
*
|
|
664
669
|
* @dbxUtil
|
|
665
670
|
* @dbxUtilCategory date
|
|
666
671
|
* @dbxUtilTags date, equal, compare, predicate
|
|
667
672
|
* @dbxUtilRelated is-date, is-past
|
|
668
|
-
*
|
|
669
|
-
* @param a - First date to compare
|
|
670
|
-
* @param b - Second date to compare
|
|
671
|
-
* @returns True if the dates represent the same point in time
|
|
672
673
|
*/
|
|
673
674
|
export declare function isEqualDate(a: Date, b: Date): boolean;
|
|
674
675
|
/**
|
|
675
676
|
* Returns true if the input date is in the past relative to the current time.
|
|
676
677
|
*
|
|
678
|
+
* @param input - Instant to compare against the system clock.
|
|
679
|
+
* @returns True when `input` is strictly before the current time.
|
|
680
|
+
*
|
|
677
681
|
* @dbxUtil
|
|
678
682
|
* @dbxUtilCategory date
|
|
679
683
|
* @dbxUtilTags date, past, compare, predicate, time
|
|
680
684
|
* @dbxUtilRelated is-equal-date, is-date
|
|
681
|
-
*
|
|
682
|
-
* @param input - The date to check
|
|
683
|
-
* @returns True if the date is in the past
|
|
684
685
|
*/
|
|
685
686
|
export declare function isPast(input: Date): boolean;
|
|
686
687
|
/**
|
|
@@ -52,7 +52,7 @@ export declare function dateFromLogicalDate(logicalDate: Maybe<LogicalDate>): Ma
|
|
|
52
52
|
* Determines if the input value is a recognized LogicalDateStringCode.
|
|
53
53
|
* Currently, only the 'now' value is recognized as a LogicalDateStringCode.
|
|
54
54
|
*
|
|
55
|
-
* @param logicalDate - The value to check
|
|
56
|
-
* @returns True if the value is a recognized LogicalDateStringCode
|
|
55
|
+
* @param logicalDate - The value to check.
|
|
56
|
+
* @returns True if the value is a recognized LogicalDateStringCode.
|
|
57
57
|
*/
|
|
58
58
|
export declare function isLogicalDateStringCode(logicalDate: Maybe<string | LogicalDate>): logicalDate is LogicalDateStringCode;
|
|
@@ -18,24 +18,24 @@ export type DateOrUnixDateTimeSecondsNumber = Date | UnixDateTimeSecondsNumber;
|
|
|
18
18
|
/**
|
|
19
19
|
* Converts a Date object or unix timestamp number to a unix timestamp number.
|
|
20
20
|
*
|
|
21
|
+
* @param input - Date object or unix timestamp number to convert.
|
|
22
|
+
* @returns Unix timestamp number if input is valid, null/undefined if input is null/undefined.
|
|
23
|
+
*
|
|
21
24
|
* @dbxUtil
|
|
22
25
|
* @dbxUtilCategory date
|
|
23
26
|
* @dbxUtilTags date, unix, seconds, timestamp, convert, normalize
|
|
24
27
|
* @dbxUtilRelated unix-date-time-seconds-number-from-date, date-from-date-or-time-seconds-number
|
|
25
|
-
*
|
|
26
|
-
* @param input - Date object or unix timestamp number to convert
|
|
27
|
-
* @returns Unix timestamp number if input is valid, null/undefined if input is null/undefined
|
|
28
28
|
*/
|
|
29
29
|
export declare function unixDateTimeSecondsNumberFromDateOrTimeNumber(input: Maybe<DateOrUnixDateTimeSecondsNumber>): Maybe<UnixDateTimeSecondsNumber>;
|
|
30
30
|
/**
|
|
31
31
|
* Gets the current time as a unix timestamp number.
|
|
32
32
|
*
|
|
33
|
+
* @returns Current time as unix timestamp number.
|
|
34
|
+
*
|
|
33
35
|
* @dbxUtil
|
|
34
36
|
* @dbxUtilCategory date
|
|
35
37
|
* @dbxUtilTags date, unix, seconds, timestamp, now, current, time
|
|
36
38
|
* @dbxUtilRelated unix-date-time-seconds-number-from-date
|
|
37
|
-
*
|
|
38
|
-
* @returns Current time as unix timestamp number
|
|
39
39
|
*/
|
|
40
40
|
export declare function unixDateTimeSecondsNumberForNow(): UnixDateTimeSecondsNumber;
|
|
41
41
|
/**
|
|
@@ -63,12 +63,12 @@ export declare function dateFromDateOrTimeSecondsNumber(input: Maybe<DateOrUnixD
|
|
|
63
63
|
/**
|
|
64
64
|
* Converts a unix timestamp number to a Date object.
|
|
65
65
|
*
|
|
66
|
+
* @param dateTimeNumber - Unix timestamp number to convert.
|
|
67
|
+
* @returns Date object if timestamp is valid, null/undefined if timestamp is null/undefined.
|
|
68
|
+
*
|
|
66
69
|
* @dbxUtil
|
|
67
70
|
* @dbxUtilCategory date
|
|
68
71
|
* @dbxUtilTags date, unix, seconds, timestamp, convert, parse
|
|
69
72
|
* @dbxUtilRelated unix-date-time-seconds-number-from-date, date-from-date-or-time-seconds-number
|
|
70
|
-
*
|
|
71
|
-
* @param dateTimeNumber - Unix timestamp number to convert
|
|
72
|
-
* @returns Date object if timestamp is valid, null/undefined if timestamp is null/undefined
|
|
73
73
|
*/
|
|
74
74
|
export declare function unixDateTimeSecondsNumberToDate(dateTimeNumber: Maybe<UnixDateTimeSecondsNumber>): Maybe<Date>;
|
|
@@ -26,9 +26,9 @@ export declare const TIME_UNIT_SHORT_LABEL_MAP: Readonly<Record<TimeUnit, string
|
|
|
26
26
|
/**
|
|
27
27
|
* Converts an amount in the given time unit to milliseconds.
|
|
28
28
|
*
|
|
29
|
-
* @param amount - The numeric amount in the given unit
|
|
30
|
-
* @param unit - The time unit of the amount
|
|
31
|
-
* @returns The equivalent number of milliseconds
|
|
29
|
+
* @param amount - The numeric amount in the given unit.
|
|
30
|
+
* @param unit - The time unit of the amount.
|
|
31
|
+
* @returns The equivalent number of milliseconds.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```typescript
|
|
@@ -40,9 +40,9 @@ export declare function timeUnitToMilliseconds(amount: number, unit: TimeUnit):
|
|
|
40
40
|
/**
|
|
41
41
|
* Converts milliseconds to an amount in the given time unit.
|
|
42
42
|
*
|
|
43
|
-
* @param ms -
|
|
44
|
-
* @param unit -
|
|
45
|
-
* @returns
|
|
43
|
+
* @param ms - Source duration measured in milliseconds.
|
|
44
|
+
* @param unit - Time unit to express the duration in.
|
|
45
|
+
* @returns Same duration rescaled to the requested unit.
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* ```typescript
|
|
@@ -56,10 +56,10 @@ export declare function millisecondsToTimeUnit(ms: Milliseconds, unit: TimeUnit)
|
|
|
56
56
|
*
|
|
57
57
|
* Goes through milliseconds as an intermediary for the conversion.
|
|
58
58
|
*
|
|
59
|
-
* @param amount - The numeric amount in the source unit
|
|
60
|
-
* @param fromUnit - The source time unit
|
|
61
|
-
* @param toUnit - The target time unit
|
|
62
|
-
* @returns The equivalent amount in the target unit
|
|
59
|
+
* @param amount - The numeric amount in the source unit.
|
|
60
|
+
* @param fromUnit - The source time unit.
|
|
61
|
+
* @param toUnit - The target time unit.
|
|
62
|
+
* @returns The equivalent amount in the target unit.
|
|
63
63
|
*
|
|
64
64
|
* @example
|
|
65
65
|
* ```typescript
|
|
@@ -79,8 +79,8 @@ export interface TimeDuration {
|
|
|
79
79
|
/**
|
|
80
80
|
* Converts a TimeDuration to milliseconds.
|
|
81
81
|
*
|
|
82
|
-
* @param duration - The duration to convert
|
|
83
|
-
* @returns The equivalent number of milliseconds
|
|
82
|
+
* @param duration - The duration to convert.
|
|
83
|
+
* @returns The equivalent number of milliseconds.
|
|
84
84
|
*
|
|
85
85
|
* @example
|
|
86
86
|
* ```typescript
|
|
@@ -93,8 +93,8 @@ export declare function timeDurationToMilliseconds(duration: TimeDuration): Mill
|
|
|
93
93
|
*
|
|
94
94
|
* First converts to total minutes, then splits into hours and minutes.
|
|
95
95
|
*
|
|
96
|
-
* @param duration - The duration to convert
|
|
97
|
-
* @returns An HoursAndMinutes object
|
|
96
|
+
* @param duration - The duration to convert.
|
|
97
|
+
* @returns An HoursAndMinutes object.
|
|
98
98
|
*
|
|
99
99
|
* @example
|
|
100
100
|
* ```typescript
|
|
@@ -106,9 +106,9 @@ export declare function timeDurationToHoursAndMinutes(duration: TimeDuration): H
|
|
|
106
106
|
/**
|
|
107
107
|
* Converts an HoursAndMinutes object to a total number in the specified time unit.
|
|
108
108
|
*
|
|
109
|
-
* @param hoursAndMinutes - The hours and minutes to convert
|
|
110
|
-
* @param toUnit - The target time unit
|
|
111
|
-
* @returns The equivalent amount in the target unit
|
|
109
|
+
* @param hoursAndMinutes - The hours and minutes to convert.
|
|
110
|
+
* @param toUnit - The target time unit.
|
|
111
|
+
* @returns The equivalent amount in the target unit.
|
|
112
112
|
*
|
|
113
113
|
* @example
|
|
114
114
|
* ```typescript
|
|
@@ -92,46 +92,48 @@ export interface ExpirationDetails<T extends Expires = Expires> {
|
|
|
92
92
|
* - **TTL / throttle**: `expirationDetails({ expiresFromDate: lastRunAt, expiresIn: throttleMs })` — see {@link isThrottled}
|
|
93
93
|
* - **Pre-emptive refresh**: `expirationDetails({ expiresFromDate: expiresAt, expiresIn: -bufferMs })` — treat as expired `bufferMs` before the real expiration, e.g. to refresh a token before it actually dies
|
|
94
94
|
*
|
|
95
|
+
* @param input - Configuration for calculating expiration.
|
|
96
|
+
* @returns An ExpirationDetails object that can determine expiration state.
|
|
97
|
+
*
|
|
95
98
|
* @dbxUtil
|
|
96
99
|
* @dbxUtilCategory date
|
|
97
100
|
* @dbxUtilTags expiration, expires, expiry, ttl, throttle, refresh, time-to-live
|
|
98
101
|
* @dbxUtilRelated is-expired, is-throttled, calculate-expiration-date, is-under-threshold, check-atleast-one-not-expired, check-any-have-expired
|
|
99
|
-
*
|
|
100
102
|
* @template T - The type of Expires object
|
|
101
|
-
* @param input - Configuration for calculating expiration
|
|
102
|
-
* @returns An ExpirationDetails object that can determine expiration state
|
|
103
103
|
*/
|
|
104
104
|
export declare function expirationDetails<T extends Expires = Expires>(input: ExpirationDetailsInput<T>): ExpirationDetails<T>;
|
|
105
105
|
/**
|
|
106
106
|
* Convenience function for calculating and returning the expiration date given the input.
|
|
107
107
|
* This is a shorthand for expirationDetails(input).getExpirationDate().
|
|
108
108
|
*
|
|
109
|
+
* @param input - Input configuration used to calculate the expiration date.
|
|
110
|
+
* @returns The calculated expiration date, or null if no expiration is defined.
|
|
111
|
+
*
|
|
109
112
|
* @dbxUtil
|
|
110
113
|
* @dbxUtilCategory date
|
|
111
114
|
* @dbxUtilTags expiration, expires, expiry, ttl, calculate, date
|
|
112
115
|
* @dbxUtilRelated expiration-details, is-expired
|
|
113
|
-
*
|
|
114
|
-
* @param input - Input configuration used to calculate the expiration date
|
|
115
|
-
* @returns The calculated expiration date, or null if no expiration is defined
|
|
116
116
|
*/
|
|
117
117
|
export declare function calculateExpirationDate(input: ExpirationDetailsInput<Expires>): Maybe<Date>;
|
|
118
118
|
/**
|
|
119
119
|
* Convenience wrapper around {@link expirationDetails}().hasExpired() that treats null/undefined input or no expiration date as expired.
|
|
120
120
|
*
|
|
121
|
+
* @param input - Expiration configuration. Null/undefined is treated as expired.
|
|
122
|
+
* @param now - Optional override for the current time. Defaults to the current time. Apply any buffer (e.g. for clock skew or pre-emptive refresh) by shifting this value forward.
|
|
123
|
+
* @returns True when the input is null/undefined or its expiration date has passed; otherwise false.
|
|
124
|
+
*
|
|
121
125
|
* @dbxUtil
|
|
122
126
|
* @dbxUtilCategory date
|
|
123
127
|
* @dbxUtilTags expiration, expires, expiry, expired, has-expired, is-expired, ttl
|
|
124
128
|
* @dbxUtilRelated expiration-details, is-throttled, calculate-expiration-date
|
|
125
129
|
*
|
|
126
|
-
* @param input - Expiration configuration. Null/undefined is treated as expired.
|
|
127
|
-
* @param now - Optional override for the current time. Defaults to the current time. Apply any buffer (e.g. for clock skew or pre-emptive refresh) by shifting this value forward.
|
|
128
|
-
* @returns True when the input is null/undefined or its expiration date has passed; otherwise false.
|
|
129
|
-
*
|
|
130
130
|
* @example
|
|
131
|
+
* ```ts
|
|
131
132
|
* isExpired(null); // true
|
|
132
133
|
* isExpired({ expiresAt: pastDate }); // true
|
|
133
134
|
* isExpired({ expiresAt: futureDate }); // false
|
|
134
135
|
* isExpired({ expiresAt: futureDate }, addMilliseconds(new Date(), 60_000)); // true (when within buffer)
|
|
136
|
+
* ```
|
|
135
137
|
*/
|
|
136
138
|
export declare function isExpired<T extends Expires = Expires>(input: Maybe<ExpirationDetailsInput<T>>, now?: Maybe<Date>): boolean;
|
|
137
139
|
/**
|
|
@@ -142,15 +144,15 @@ export declare function isExpired<T extends Expires = Expires>(input: Maybe<Expi
|
|
|
142
144
|
* Example:
|
|
143
145
|
* - Should send a notification at max every 2 days. The threshold is 2 days in milliseconds, and "nextRunAt" is the previously calculated date that was originally "now" + "threshold".
|
|
144
146
|
*
|
|
147
|
+
* @param threshold - The threshold time. Typically this is amount of time that was used to calculate the original "nextRunAt" time.
|
|
148
|
+
* @param nextRunAt - Time the next run will occur. If null/undefined, then this function will return false.
|
|
149
|
+
* @param now - Optional override for the current time. Defaults to the current time.
|
|
150
|
+
* @returns True if the threshold has not passed since the next run time, compared to now.
|
|
151
|
+
*
|
|
145
152
|
* @dbxUtil
|
|
146
153
|
* @dbxUtilCategory date
|
|
147
154
|
* @dbxUtilTags threshold, throttle, ttl, time-window, rate-limit
|
|
148
155
|
* @dbxUtilRelated is-throttled, expiration-details
|
|
149
|
-
*
|
|
150
|
-
* @param threshold The threshold time. Typically this is amount of time that was used to calculate the original "nextRunAt" time.
|
|
151
|
-
* @param nextRunAt Time the next run will occur. If null/undefined, then this function will return false.
|
|
152
|
-
* @param now Optional override for the current time. Defaults to the current time.
|
|
153
|
-
* @returns True if the threshold has not passed since the next run time, compared to now.
|
|
154
156
|
*/
|
|
155
157
|
export declare function isUnderThreshold(threshold: Milliseconds, nextRunAt: Maybe<DateOrUnixDateTimeMillisecondsNumber>, now?: Maybe<Date>): boolean;
|
|
156
158
|
/**
|
|
@@ -159,15 +161,15 @@ export declare function isUnderThreshold(threshold: Milliseconds, nextRunAt: May
|
|
|
159
161
|
* Returns true if the throttle time has not passed since the last run time, compared to now.
|
|
160
162
|
* This is useful for rate limiting operations (e.g., "only allow this action once every X milliseconds").
|
|
161
163
|
*
|
|
164
|
+
* @param throttleTime - Minimum time in milliseconds that must pass between operations.
|
|
165
|
+
* @param lastRunAt - Timestamp when the operation was last performed.
|
|
166
|
+
* @param now - Optional override for the current time (defaults to the current time)
|
|
167
|
+
* @returns True if the operation should be throttled (not enough time has passed), false otherwise.
|
|
168
|
+
*
|
|
162
169
|
* @dbxUtil
|
|
163
170
|
* @dbxUtilCategory date
|
|
164
171
|
* @dbxUtilTags throttle, throttled, rate-limit, debounce, ttl, expiration
|
|
165
172
|
* @dbxUtilRelated expiration-details, is-under-threshold, is-expired
|
|
166
|
-
*
|
|
167
|
-
* @param throttleTime - Minimum time in milliseconds that must pass between operations
|
|
168
|
-
* @param lastRunAt - Timestamp when the operation was last performed
|
|
169
|
-
* @param now - Optional override for the current time (defaults to the current time)
|
|
170
|
-
* @returns True if the operation should be throttled (not enough time has passed), false otherwise
|
|
171
173
|
*/
|
|
172
174
|
export declare function isThrottled(throttleTime: Maybe<Milliseconds>, lastRunAt: Maybe<DateOrUnixDateTimeMillisecondsNumber>, now?: Maybe<Date>): boolean;
|
|
173
175
|
/**
|
|
@@ -176,13 +178,13 @@ export declare function isThrottled(throttleTime: Maybe<Milliseconds>, lastRunAt
|
|
|
176
178
|
*
|
|
177
179
|
* If the list is empty, returns false.
|
|
178
180
|
*
|
|
181
|
+
* @param details - Collection of ExpirationDetails to check.
|
|
182
|
+
* @returns True if at least one item has not expired, false otherwise.
|
|
183
|
+
*
|
|
179
184
|
* @dbxUtil
|
|
180
185
|
* @dbxUtilCategory date
|
|
181
186
|
* @dbxUtilTags expiration, valid, collection, any
|
|
182
187
|
* @dbxUtilRelated expiration-details, check-any-have-expired
|
|
183
|
-
*
|
|
184
|
-
* @param details - Collection of ExpirationDetails to check
|
|
185
|
-
* @returns True if at least one item has not expired, false otherwise
|
|
186
188
|
*/
|
|
187
189
|
export declare function checkAtleastOneNotExpired(details: ExpirationDetails<Expires>[]): boolean;
|
|
188
190
|
/**
|
|
@@ -191,13 +193,13 @@ export declare function checkAtleastOneNotExpired(details: ExpirationDetails<Exp
|
|
|
191
193
|
*
|
|
192
194
|
* If the list is empty, returns the value specified by defaultIfEmpty.
|
|
193
195
|
*
|
|
196
|
+
* @param details - Collection of ExpirationDetails to check.
|
|
197
|
+
* @param defaultIfEmpty - Default value to return if the list is empty (defaults to true)
|
|
198
|
+
* @returns True if any item has expired, or the defaultIfEmpty value for an empty list.
|
|
199
|
+
*
|
|
194
200
|
* @dbxUtil
|
|
195
201
|
* @dbxUtilCategory date
|
|
196
202
|
* @dbxUtilTags expiration, refresh, collection, any
|
|
197
203
|
* @dbxUtilRelated expiration-details, check-atleast-one-not-expired
|
|
198
|
-
*
|
|
199
|
-
* @param details - Collection of ExpirationDetails to check
|
|
200
|
-
* @param defaultIfEmpty - Default value to return if the list is empty (defaults to true)
|
|
201
|
-
* @returns True if any item has expired, or the defaultIfEmpty value for an empty list
|
|
202
204
|
*/
|
|
203
205
|
export declare function checkAnyHaveExpired(details: ExpirationDetails<Expires>[], defaultIfEmpty?: boolean): boolean;
|