@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
|
@@ -16,7 +16,7 @@ export type UsePromiseCallback = (cb: PromiseCallback) => void;
|
|
|
16
16
|
* Node.js-style error-first callback; calling it with an error rejects the promise, and
|
|
17
17
|
* calling it without an error resolves it.
|
|
18
18
|
*
|
|
19
|
-
* @param use -
|
|
20
|
-
* @returns
|
|
19
|
+
* @param use - Performs an async operation and signals completion via the provided callback.
|
|
20
|
+
* @returns Resolves when the callback is invoked without an error, or rejects with the provided error.
|
|
21
21
|
*/
|
|
22
22
|
export declare function useCallback(use: UsePromiseCallback): Promise<void>;
|
package/src/lib/promise/is.d.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks whether the input value is a native Promise by testing for a `.then` method.
|
|
3
3
|
*
|
|
4
|
+
* @param obj - The value to test.
|
|
5
|
+
* @returns `true` if the value is a Promise, `false` otherwise.
|
|
6
|
+
*
|
|
4
7
|
* @dbxUtil
|
|
5
8
|
* @dbxUtilCategory promise
|
|
6
9
|
* @dbxUtilTags promise, type-guard, async, then, check
|
|
7
10
|
* @dbxUtilRelated is-promise-like, as-promise
|
|
8
|
-
*
|
|
9
|
-
* @param obj - The value to test.
|
|
10
|
-
* @returns `true` if the value is a Promise, `false` otherwise.
|
|
11
11
|
*/
|
|
12
12
|
export declare function isPromise<T, S>(obj: Promise<T> | S): obj is Promise<T>;
|
|
13
13
|
/**
|
|
14
14
|
* Checks whether the input value is PromiseLike (i.e., has a `.then` method), which
|
|
15
15
|
* includes both native Promises and custom thenables.
|
|
16
16
|
*
|
|
17
|
+
* @param obj - The value to test.
|
|
18
|
+
* @returns `true` if the value is PromiseLike, `false` otherwise.
|
|
19
|
+
*
|
|
17
20
|
* @dbxUtil
|
|
18
21
|
* @dbxUtilCategory promise
|
|
19
22
|
* @dbxUtilTags promise, type-guard, async, then, thenable, check
|
|
20
23
|
* @dbxUtilRelated is-promise, as-promise
|
|
21
|
-
*
|
|
22
|
-
* @param obj - The value to test.
|
|
23
|
-
* @returns `true` if the value is PromiseLike, `false` otherwise.
|
|
24
24
|
*/
|
|
25
25
|
export declare function isPromiseLike<T, S>(obj: PromiseLike<T> | S): obj is PromiseLike<T>;
|
|
@@ -7,30 +7,30 @@ export interface PollConfig {
|
|
|
7
7
|
*
|
|
8
8
|
* Defaults to 250.
|
|
9
9
|
*/
|
|
10
|
-
wait?: number;
|
|
10
|
+
readonly wait?: number;
|
|
11
11
|
/**
|
|
12
12
|
* Predicate function that returns `true` when the polling condition has been met.
|
|
13
13
|
*/
|
|
14
|
-
check: () => boolean;
|
|
14
|
+
readonly check: () => boolean;
|
|
15
15
|
/**
|
|
16
16
|
* Maximum number of polling iterations before giving up.
|
|
17
17
|
*
|
|
18
18
|
* Defaults to `Number.MAX_SAFE_INTEGER`.
|
|
19
19
|
*/
|
|
20
|
-
timesToGiveup?: number;
|
|
20
|
+
readonly timesToGiveup?: number;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Polls at a regular interval until a condition is met or the maximum number of attempts is reached.
|
|
24
24
|
*
|
|
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`
|
|
29
|
+
* @returns Resolves when the check condition returns `true` or the max attempts are exhausted.
|
|
30
|
+
*
|
|
25
31
|
* @dbxUtil
|
|
26
32
|
* @dbxUtilCategory promise
|
|
27
33
|
* @dbxUtilTags promise, poll, wait, retry, condition, async, interval
|
|
28
34
|
* @dbxUtilRelated wait-for-ms, perform-task-loop
|
|
29
|
-
*
|
|
30
|
-
* @param config - Polling configuration including check function, wait interval, and max attempts.
|
|
31
|
-
* @param config.check - predicate function that returns true when the polling condition has been satisfied
|
|
32
|
-
* @param config.wait - milliseconds to wait between polling iterations; defaults to 250
|
|
33
|
-
* @param config.timesToGiveup - maximum number of polling iterations before giving up; defaults to `Number.MAX_SAFE_INTEGER`
|
|
34
|
-
* @returns A Promise that resolves when the check condition returns `true` or the max attempts are exhausted.
|
|
35
35
|
*/
|
|
36
36
|
export declare function poll({ check, wait, timesToGiveup }: PollConfig): Promise<void>;
|
|
@@ -16,31 +16,31 @@ export type RunAsyncTasksForValuesConfig<T = unknown> = Omit<PerformAsyncTasksCo
|
|
|
16
16
|
/**
|
|
17
17
|
* Runs a single async task and returns the resulting value. Always configured to throw on failure.
|
|
18
18
|
*
|
|
19
|
+
* @param taskFn - The async task to execute.
|
|
20
|
+
* @param config - Optional configuration for retries and retry behavior.
|
|
21
|
+
* @returns The value produced by the task, or undefined if the task produced no value.
|
|
22
|
+
* @throws {Error} Rethrows any error thrown by the task function.
|
|
23
|
+
*
|
|
19
24
|
* @dbxUtil
|
|
20
25
|
* @dbxUtilCategory promise
|
|
21
26
|
* @dbxUtilTags promise, async, task, retry, run, value
|
|
22
27
|
* @dbxUtilRelated perform-async-task, run-async-tasks-for-values, perform-async-tasks
|
|
23
|
-
*
|
|
24
|
-
* @param taskFn - The async task to execute.
|
|
25
|
-
* @param config - Optional configuration for retries and retry behavior.
|
|
26
|
-
* @returns The value produced by the task, or undefined if the task produced no value.
|
|
27
|
-
* @throws Rethrows any error thrown by the task function.
|
|
28
28
|
*/
|
|
29
29
|
export declare function runAsyncTaskForValue<O>(taskFn: () => Promise<O>, config?: RunAsyncTaskForValueConfig<0>): Promise<Maybe<O>>;
|
|
30
30
|
/**
|
|
31
31
|
* Runs an async task for each input value and returns an array of the resulting values.
|
|
32
32
|
* Always configured to throw on failure.
|
|
33
33
|
*
|
|
34
|
+
* @param input - The array of input values to process.
|
|
35
|
+
* @param taskFn - The async task function to run for each input value.
|
|
36
|
+
* @param config - Optional configuration for parallelism and retries.
|
|
37
|
+
* @returns The results produced by the task function for each input.
|
|
38
|
+
* @throws {Error} Rethrows any error thrown by a task function.
|
|
39
|
+
*
|
|
34
40
|
* @dbxUtil
|
|
35
41
|
* @dbxUtilCategory promise
|
|
36
42
|
* @dbxUtilTags promise, async, tasks, parallel, batch, retry, run, values
|
|
37
43
|
* @dbxUtilRelated perform-async-tasks, run-async-task-for-value
|
|
38
|
-
*
|
|
39
|
-
* @param input - The array of input values to process.
|
|
40
|
-
* @param taskFn - The async task function to run for each input value.
|
|
41
|
-
* @param config - Optional configuration for parallelism and retries.
|
|
42
|
-
* @returns An array of results produced by the task function for each input.
|
|
43
|
-
* @throws Rethrows any error thrown by a task function.
|
|
44
44
|
*/
|
|
45
45
|
export declare function runAsyncTasksForValues<T, K = unknown>(input: T[], taskFn: PerformAsyncTaskFn<T, K>, config?: RunAsyncTasksForValuesConfig<T>): Promise<K[]>;
|
|
46
46
|
/**
|
|
@@ -116,30 +116,30 @@ export interface PerformAsyncTasksConfig<I = unknown, K extends PrimativeKey = P
|
|
|
116
116
|
* Performs async tasks for each input value with configurable retry and parallelism behavior.
|
|
117
117
|
* Useful for operations that may experience optimistic concurrency collisions.
|
|
118
118
|
*
|
|
119
|
-
* @dbxUtil
|
|
120
|
-
* @dbxUtilCategory promise
|
|
121
|
-
* @dbxUtilTags async, promise, parallel, retry, task, batch, concurrency, throttle
|
|
122
|
-
* @dbxUtilRelated perform-tasks-in-parallel, perform-async-task
|
|
123
|
-
*
|
|
124
119
|
* @param input - The array of input values to process.
|
|
125
120
|
* @param taskFn - The async function to execute for each input.
|
|
126
121
|
* @param config - Configuration for retries, parallelism, and error handling.
|
|
127
122
|
* @returns An aggregated result with succeeded/failed items and their outputs/errors.
|
|
128
|
-
* @throws Rethrows the last error from retries if `throwError` is true (default).
|
|
123
|
+
* @throws {Error} Rethrows the last error from retries if `throwError` is true (default).
|
|
124
|
+
*
|
|
125
|
+
* @dbxUtil
|
|
126
|
+
* @dbxUtilCategory promise
|
|
127
|
+
* @dbxUtilTags async, promise, parallel, retry, task, batch, concurrency, throttle
|
|
128
|
+
* @dbxUtilRelated perform-tasks-in-parallel, perform-async-task
|
|
129
129
|
*/
|
|
130
130
|
export declare function performAsyncTasks<I, O = unknown, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(input: I[], taskFn: PerformAsyncTaskFn<I, O>, config?: PerformAsyncTasksConfig<I, K>): Promise<PerformAsyncTasksResult<I, O>>;
|
|
131
131
|
/**
|
|
132
132
|
* Performs a single async task with configurable retry behavior and returns the result with success status.
|
|
133
133
|
*
|
|
134
|
+
* @param taskFn - The async task to execute.
|
|
135
|
+
* @param config - Optional configuration for retries and error handling.
|
|
136
|
+
* @returns A result object containing the value (if successful) and a success flag.
|
|
137
|
+
* @throws {Error} Rethrows the last error from retries if `throwError` is true (default).
|
|
138
|
+
*
|
|
134
139
|
* @dbxUtil
|
|
135
140
|
* @dbxUtilCategory promise
|
|
136
141
|
* @dbxUtilTags promise, async, task, retry, run, success
|
|
137
142
|
* @dbxUtilRelated perform-async-tasks, run-async-task-for-value
|
|
138
|
-
*
|
|
139
|
-
* @param taskFn - The async task to execute.
|
|
140
|
-
* @param config - Optional configuration for retries and error handling.
|
|
141
|
-
* @returns A result object containing the value (if successful) and a success flag.
|
|
142
|
-
* @throws Rethrows the last error from retries if `throwError` is true (default).
|
|
143
143
|
*/
|
|
144
144
|
export declare function performAsyncTask<O>(taskFn: () => Promise<O>, config?: PerformAsyncTaskConfig<0>): Promise<PerformAsyncTaskResult<O>>;
|
|
145
145
|
/**
|
|
@@ -166,22 +166,23 @@ export type PerformTasksInParallelFunction<I> = (input: I[]) => Promise<void>;
|
|
|
166
166
|
*
|
|
167
167
|
* @param input - The array of items to process.
|
|
168
168
|
* @param config - Configuration for task execution, parallelism, and concurrency constraints.
|
|
169
|
-
* @returns
|
|
170
|
-
* @throws Rethrows the first error encountered during task execution.
|
|
169
|
+
* @returns Resolves when all tasks complete.
|
|
170
|
+
* @throws {Error} Rethrows the first error encountered during task execution.
|
|
171
171
|
*/
|
|
172
172
|
export declare function performTasksInParallel<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(input: I[], config: PerformTasksInParallelFunctionConfig<I, K>): Promise<void>;
|
|
173
173
|
/**
|
|
174
174
|
* Creates a reusable function that performs tasks in parallel with optional concurrency limits
|
|
175
175
|
* and non-concurrent task key constraints.
|
|
176
176
|
*
|
|
177
|
+
* @param config - Configuration for task factory, parallelism limits, and concurrency keys.
|
|
178
|
+
* @returns Accepts an array of inputs and returns a Promise resolving when all tasks complete.
|
|
179
|
+
*
|
|
177
180
|
* @dbxUtil
|
|
178
181
|
* @dbxUtilCategory promise
|
|
179
182
|
* @dbxUtilKind factory
|
|
180
183
|
* @dbxUtilTags promise, parallel, factory, concurrency, async, tasks
|
|
181
184
|
* @dbxUtilRelated perform-tasks-in-parallel, perform-async-tasks-function
|
|
182
185
|
*
|
|
183
|
-
* @param config - Configuration for task factory, parallelism limits, and concurrency keys.
|
|
184
|
-
* @returns A function that accepts an array of inputs and returns a Promise resolving when all tasks complete.
|
|
185
186
|
* @__NO_SIDE_EFFECTS__
|
|
186
187
|
*/
|
|
187
188
|
export declare function performTasksInParallelFunction<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(config: PerformTasksInParallelFunctionConfig<I, K>): PerformTasksInParallelFunction<I>;
|
|
@@ -223,7 +224,7 @@ export interface PerformTasksFromFactoryInParallelFunctionConfig<I, K extends Pr
|
|
|
223
224
|
* A factory function that produces the next batch of task inputs. Returns `null` to signal
|
|
224
225
|
* that no more inputs are available.
|
|
225
226
|
*/
|
|
226
|
-
export type PerformTaskFactoryTasksInParallelFunctionTaskInputFactory<I> = () => PromiseOrValue<ArrayOrValue<I
|
|
227
|
+
export type PerformTaskFactoryTasksInParallelFunctionTaskInputFactory<I> = () => PromiseOrValue<Maybe<ArrayOrValue<I>>>;
|
|
227
228
|
/**
|
|
228
229
|
* Function that awaits all promises generated from the task factory until the factory returns null.
|
|
229
230
|
*
|
|
@@ -236,27 +237,29 @@ export type PerformTaskFactoryTasksInParallelFunction<I> = (taskInputFactory: Pe
|
|
|
236
237
|
* Creates a function that pulls task inputs from a factory and executes them in parallel
|
|
237
238
|
* with configurable concurrency limits and non-concurrent key constraints.
|
|
238
239
|
*
|
|
240
|
+
* @param config - Configuration for the task factory, parallelism, and concurrency behavior.
|
|
241
|
+
* @returns Accepts a task input factory and returns a Promise that resolves when all tasks complete.
|
|
242
|
+
*
|
|
239
243
|
* @dbxUtil
|
|
240
244
|
* @dbxUtilCategory promise
|
|
241
245
|
* @dbxUtilKind factory
|
|
242
246
|
* @dbxUtilTags promise, parallel, factory, concurrency, async, pull-tasks
|
|
243
247
|
* @dbxUtilRelated perform-tasks-in-parallel-function
|
|
244
248
|
*
|
|
245
|
-
* @param config - Configuration for the task factory, parallelism, and concurrency behavior.
|
|
246
|
-
* @returns a function that accepts a task input factory and returns a Promise that resolves when all tasks complete
|
|
247
249
|
* @__NO_SIDE_EFFECTS__
|
|
248
250
|
*/
|
|
249
251
|
export declare function performTasksFromFactoryInParallelFunction<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(config: PerformTasksFromFactoryInParallelFunctionConfig<I, K>): PerformTaskFactoryTasksInParallelFunction<I>;
|
|
250
252
|
/**
|
|
251
253
|
* Creates a default non-concurrent task key factory that generates unique incrementing number strings.
|
|
252
254
|
*
|
|
255
|
+
* @returns A {@link StringFactory} that produces unique keys for identifying non-concurrent tasks.
|
|
256
|
+
*
|
|
253
257
|
* @dbxUtil
|
|
254
258
|
* @dbxUtilCategory promise
|
|
255
259
|
* @dbxUtilKind factory
|
|
256
260
|
* @dbxUtilTags promise, parallel, key, factory, unique, incrementing
|
|
257
261
|
* @dbxUtilRelated perform-tasks-in-parallel-function, incrementing-number-factory
|
|
258
262
|
*
|
|
259
|
-
* @returns A {@link StringFactory} that produces unique keys for identifying non-concurrent tasks.
|
|
260
263
|
* @__NO_SIDE_EFFECTS__
|
|
261
264
|
*/
|
|
262
265
|
export declare function makeDefaultNonConcurrentTaskKeyFactory(): StringFactory<any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FactoryWithRequiredInput } from '../getter/getter';
|
|
2
2
|
import { type Maybe } from '../value/maybe.type';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Tries an array of Promise factories one after another until one
|
|
5
5
|
* produces a successful result. Returns `undefined` if none succeed.
|
|
6
6
|
*
|
|
7
7
|
* @param input - The input to pass to each factory.
|
|
@@ -43,14 +43,15 @@ export interface TryWithPromiseFactoriesFunctionConfig<I, O> extends TryWithProm
|
|
|
43
43
|
* Creates a {@link TryWithPromiseFactoriesFunction} that sequentially tries each promise factory
|
|
44
44
|
* until one returns a non-null value (or a Maybe value if `successOnMaybe` is true).
|
|
45
45
|
*
|
|
46
|
+
* @param config - Configuration including the array of promise factories and default behavior options.
|
|
47
|
+
* @returns Tries each factory in order for a given input.
|
|
48
|
+
*
|
|
46
49
|
* @dbxUtil
|
|
47
50
|
* @dbxUtilCategory promise
|
|
48
51
|
* @dbxUtilKind factory
|
|
49
52
|
* @dbxUtilTags promise, factory, try, sequential, fallback, async
|
|
50
53
|
* @dbxUtilRelated run-named-async-tasks-function
|
|
51
54
|
*
|
|
52
|
-
* @param config - Configuration including the array of promise factories and default behavior options.
|
|
53
|
-
* @returns A function that tries each factory in order for a given input.
|
|
54
55
|
* @__NO_SIDE_EFFECTS__
|
|
55
56
|
*/
|
|
56
57
|
export declare function tryWithPromiseFactoriesFunction<I, O>(config: TryWithPromiseFactoriesFunctionConfig<I, O>): TryWithPromiseFactoriesFunction<I, O>;
|
|
@@ -8,11 +8,11 @@ export interface PerformTaskLoopConfig<O> {
|
|
|
8
8
|
/**
|
|
9
9
|
* Produces the next value given the iteration index and the previous value.
|
|
10
10
|
*/
|
|
11
|
-
next: (i: number, prev: Maybe<O>) => Promise<O>;
|
|
11
|
+
readonly next: (i: number, prev: Maybe<O>) => Promise<O>;
|
|
12
12
|
/**
|
|
13
13
|
* Returns whether to continue looping. Called after each iteration with the current value and next index.
|
|
14
14
|
*/
|
|
15
|
-
checkContinue: (prev: Maybe<O>, i: number) => PromiseOrValue<boolean>;
|
|
15
|
+
readonly checkContinue: (prev: Maybe<O>, i: number) => PromiseOrValue<boolean>;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Configuration for {@link performTaskLoop} with a required initial value.
|
|
@@ -21,15 +21,15 @@ export interface PerformTaskLoopWithInitConfig<O> {
|
|
|
21
21
|
/**
|
|
22
22
|
* The initial value to start the loop with.
|
|
23
23
|
*/
|
|
24
|
-
initValue: O;
|
|
24
|
+
readonly initValue: O;
|
|
25
25
|
/**
|
|
26
26
|
* Produces the next value given the iteration index and the previous value.
|
|
27
27
|
*/
|
|
28
|
-
next: (i: number, prev: O) => Promise<O>;
|
|
28
|
+
readonly next: (i: number, prev: O) => Promise<O>;
|
|
29
29
|
/**
|
|
30
30
|
* Returns whether to continue looping. Called after each iteration with the current value and next index.
|
|
31
31
|
*/
|
|
32
|
-
checkContinue: (prev: O, i: number) => PromiseOrValue<boolean>;
|
|
32
|
+
readonly checkContinue: (prev: O, i: number) => PromiseOrValue<boolean>;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Executes an async task in a loop, calling `next` repeatedly until `checkContinue` returns false.
|
|
@@ -49,7 +49,7 @@ export interface PerformTaskCountLoopConfig<O> extends Omit<PerformTaskLoopConfi
|
|
|
49
49
|
/**
|
|
50
50
|
* The number of iterations to perform.
|
|
51
51
|
*/
|
|
52
|
-
count: number;
|
|
52
|
+
readonly count: number;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Configuration for {@link performTaskCountLoop} with a required initial value.
|
|
@@ -58,7 +58,7 @@ export interface PerformTaskCountLoopWithInitConfig<O> extends Omit<PerformTaskL
|
|
|
58
58
|
/**
|
|
59
59
|
* The number of iterations to perform.
|
|
60
60
|
*/
|
|
61
|
-
count: number;
|
|
61
|
+
readonly count: number;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Performs an async task loop a fixed number of times. A convenience wrapper around
|
|
@@ -84,18 +84,18 @@ export interface PerformMakeLoopConfig<O> {
|
|
|
84
84
|
/**
|
|
85
85
|
* The factory function to create each item.
|
|
86
86
|
*/
|
|
87
|
-
make: PerformMakeLoopFunction<O>;
|
|
87
|
+
readonly make: PerformMakeLoopFunction<O>;
|
|
88
88
|
/**
|
|
89
89
|
* The total number of items to create.
|
|
90
90
|
*/
|
|
91
|
-
count: number;
|
|
91
|
+
readonly count: number;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Creates an array of items by invoking a make function in a loop a specified number of times.
|
|
95
95
|
* Each iteration receives the current index and the array of items created so far.
|
|
96
96
|
*
|
|
97
97
|
* @param config - Configuration with the make function and count.
|
|
98
|
-
* @returns
|
|
98
|
+
* @returns The all created items.
|
|
99
99
|
*/
|
|
100
100
|
export declare function performMakeLoop<O>(config: PerformMakeLoopConfig<O>): Promise<O[]>;
|
|
101
101
|
/**
|
|
@@ -113,7 +113,7 @@ export interface PerformBatchLoopConfig<O> extends BatchCount {
|
|
|
113
113
|
/**
|
|
114
114
|
* Factory function that creates a batch of items given the requested count.
|
|
115
115
|
*/
|
|
116
|
-
make: PerformBatchLoopFunction<O>;
|
|
116
|
+
readonly make: PerformBatchLoopFunction<O>;
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Creates items in batches by dividing a total count into batch-sized chunks and
|
|
@@ -2,7 +2,7 @@ import { type AsyncFactory } from '../getter/getter';
|
|
|
2
2
|
import { type Maybe } from '../value';
|
|
3
3
|
import { type RunAsyncTasksForValuesConfig } from './promise';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Returns a Promise, typically returning void/no value.
|
|
6
6
|
*/
|
|
7
7
|
export type AsyncTask<T = void> = AsyncFactory<T>;
|
|
8
8
|
/**
|
|
@@ -17,7 +17,7 @@ export type NamedAsyncTask<T = void> = {
|
|
|
17
17
|
*/
|
|
18
18
|
export type NamedAsyncTaskRecord<T = void> = Record<string, AsyncTask<T>>;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Runs an array of named async tasks.
|
|
21
21
|
*/
|
|
22
22
|
export type RunNamedAsyncTasksFunction<T = void> = (inputTasks: RunNamedAsyncTasksInput<T>, options?: Maybe<RunNamedAsyncTasksFunctionOptions<T>>) => Promise<RunNamedAsyncTasksResult<T>>;
|
|
23
23
|
/**
|
|
@@ -52,14 +52,15 @@ export interface RunNamedAsyncTasksResult<T = void> {
|
|
|
52
52
|
/**
|
|
53
53
|
* Creates a new RunNamedAsyncTasksFunction.
|
|
54
54
|
*
|
|
55
|
+
* @param config - Optional configuration.
|
|
56
|
+
* @returns A new RunNamedAsyncTasksFunction.
|
|
57
|
+
*
|
|
55
58
|
* @dbxUtil
|
|
56
59
|
* @dbxUtilCategory promise
|
|
57
60
|
* @dbxUtilKind factory
|
|
58
61
|
* @dbxUtilTags promise, async, task, factory, named, parallel
|
|
59
62
|
* @dbxUtilRelated try-with-promise-factories-function
|
|
60
63
|
*
|
|
61
|
-
* @param config Optional configuration.
|
|
62
|
-
* @returns A new RunNamedAsyncTasksFunction.
|
|
63
64
|
* @__NO_SIDE_EFFECTS__
|
|
64
65
|
*/
|
|
65
66
|
export declare function runNamedAsyncTasksFunction<T = void>(config?: RunNamedAsyncTasksFunctionConfig<T>): RunNamedAsyncTasksFunction<T>;
|
|
@@ -67,7 +68,7 @@ export declare function runNamedAsyncTasksFunction<T = void>(config?: RunNamedAs
|
|
|
67
68
|
* Convenience function that creates a {@link RunNamedAsyncTasksFunction} and immediately
|
|
68
69
|
* executes it with the given tasks.
|
|
69
70
|
*
|
|
70
|
-
* @param inputTasks -
|
|
71
|
+
* @param inputTasks - The named tasks or a record of task functions keyed by name.
|
|
71
72
|
* @param config - Optional configuration for callbacks and default execution options.
|
|
72
73
|
* @returns The result containing successful and failed tasks.
|
|
73
74
|
*/
|
|
@@ -5,11 +5,11 @@ export type PromiseOrValue<T> = Promise<T> | T;
|
|
|
5
5
|
/**
|
|
6
6
|
* Wraps the input in a resolved Promise if it is not already a Promise.
|
|
7
7
|
*
|
|
8
|
+
* @param input - A value or Promise to normalize into a Promise.
|
|
9
|
+
* @returns Resolves to the input value.
|
|
10
|
+
*
|
|
8
11
|
* @dbxUtil
|
|
9
12
|
* @dbxUtilCategory promise
|
|
10
13
|
* @dbxUtilTags promise, async, normalize, resolve, ensure
|
|
11
|
-
*
|
|
12
|
-
* @param input - A value or Promise to normalize into a Promise.
|
|
13
|
-
* @returns A Promise that resolves to the input value.
|
|
14
14
|
*/
|
|
15
15
|
export declare function asPromise<T>(input: PromiseOrValue<T>): Promise<T>;
|
package/src/lib/promise/use.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type GetterOrValue } from '../getter';
|
|
2
2
|
import { type UseAsync } from '../value';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Resolves a cached Promise value and passes it to the given async consumer,
|
|
5
5
|
* returning the consumer's result.
|
|
6
6
|
*/
|
|
7
7
|
export type UsePromiseFunction<I> = <O>(useFn: UseAsync<I, O>) => Promise<O>;
|
|
@@ -9,7 +9,7 @@ export type UsePromiseFunction<I> = <O>(useFn: UseAsync<I, O>) => Promise<O>;
|
|
|
9
9
|
* Creates a {@link UsePromiseFunction} that resolves the input promise and passes the result
|
|
10
10
|
* to any consumer function provided at call time.
|
|
11
11
|
*
|
|
12
|
-
* @param input -
|
|
13
|
-
* @returns
|
|
12
|
+
* @param input - Promise or a getter that returns a Promise, whose resolved value will be passed to consumers.
|
|
13
|
+
* @returns Accepts an async consumer and returns the consumer's result.
|
|
14
14
|
*/
|
|
15
15
|
export declare function usePromise<I>(input: GetterOrValue<Promise<I>>): UsePromiseFunction<I>;
|
|
@@ -84,25 +84,25 @@ export type ChangeRelationObjectsMaskFn<T> = (x: T) => boolean;
|
|
|
84
84
|
* Configuration for modifying a single-type relation collection via {@link ModelRelationUtility}.
|
|
85
85
|
*/
|
|
86
86
|
export interface UpdateRelationConfig<T> {
|
|
87
|
-
readKey: ReadRelationKeyFn<T>;
|
|
88
|
-
merge: MergeRelationObjectsFn<T>;
|
|
87
|
+
readonly readKey: ReadRelationKeyFn<T>;
|
|
88
|
+
readonly merge: MergeRelationObjectsFn<T>;
|
|
89
89
|
/**
|
|
90
90
|
* Whether or not an item should be removed when remove is called.
|
|
91
91
|
*/
|
|
92
|
-
shouldRemove?: (x: T) => boolean;
|
|
92
|
+
readonly shouldRemove?: (x: T) => boolean;
|
|
93
93
|
/**
|
|
94
94
|
* Whether or not the item should be considered when performing a change.
|
|
95
95
|
*
|
|
96
96
|
* For instance, existing items that are passed to this function and it returns false are unable to be changed,
|
|
97
97
|
* and new/target items that are passed to this function and it returns false are ignored.
|
|
98
98
|
*/
|
|
99
|
-
mask?: ChangeRelationObjectsMaskFn<T>;
|
|
99
|
+
readonly mask?: ChangeRelationObjectsMaskFn<T>;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Extends {@link UpdateRelationConfig} with a type reader for multi-type relation collections.
|
|
103
103
|
*/
|
|
104
104
|
export interface UpdateMiltiTypeRelationConfig<T> extends UpdateRelationConfig<T> {
|
|
105
|
-
readType: ReadRelationModelTypeFn<T>;
|
|
105
|
+
readonly readType: ReadRelationModelTypeFn<T>;
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Utility class for modifying a collection of relational objects.
|
|
@@ -136,11 +136,11 @@ export declare class ModelRelationUtility {
|
|
|
136
136
|
*
|
|
137
137
|
* Order from the "current" is retained. Anything in currentRetain overrides modifiedResults.
|
|
138
138
|
*
|
|
139
|
-
* @param current -
|
|
140
|
-
* @param currentRetain -
|
|
141
|
-
* @param modifiedResults -
|
|
142
|
-
* @param readKey -
|
|
143
|
-
* @returns
|
|
139
|
+
* @param current - The original array whose ordering is preserved.
|
|
140
|
+
* @param currentRetain - Items from `current` that were excluded from modification and take precedence in the merge.
|
|
141
|
+
* @param modifiedResults - Items that were modified or added during the relation change.
|
|
142
|
+
* @param readKey - Function that extracts the relation key from each item for ordering.
|
|
143
|
+
* @returns The merged array with original ordering restored.
|
|
144
144
|
*/
|
|
145
145
|
private static _mergeMaskResults;
|
|
146
146
|
private static _modifyCollectionWithoutMask;
|
|
@@ -166,11 +166,11 @@ export declare class ModelRelationUtility {
|
|
|
166
166
|
/**
|
|
167
167
|
* Used to modify a collection which may be multi-type. If readType is provided, the collection is handled as a multi-type map.
|
|
168
168
|
*
|
|
169
|
-
* @param current -
|
|
170
|
-
* @param mods -
|
|
171
|
-
* @param modifyCollection -
|
|
172
|
-
* @param readType -
|
|
173
|
-
* @returns
|
|
169
|
+
* @param current - The current collection of relation objects.
|
|
170
|
+
* @param mods - The modifications to apply to the collection.
|
|
171
|
+
* @param modifyCollection - Function that applies modifications to a single-type subset of the collection.
|
|
172
|
+
* @param readType - Optional function to read the type from each relation object, enabling multi-type handling.
|
|
173
|
+
* @returns The modified collection with all changes applied.
|
|
174
174
|
*/
|
|
175
175
|
private static _modifyCollection;
|
|
176
176
|
private static _modifyMultiTypeCollection;
|
|
@@ -25,20 +25,21 @@ export type HandlerSetFunction<T, R = HandleResult> = (handlerFunction: Internal
|
|
|
25
25
|
/**
|
|
26
26
|
* Creates a {@link HandlerSetFunction} that registers a handler function on a pre-defined key.
|
|
27
27
|
*
|
|
28
|
+
* @param accessor - The handler set accessor to register on.
|
|
29
|
+
* @param key - The key (or keys) to associate the handler with.
|
|
30
|
+
* @returns Accepts a handler function and registers it for the given key.
|
|
31
|
+
*
|
|
28
32
|
* @dbxUtil
|
|
29
33
|
* @dbxUtilCategory service
|
|
30
34
|
* @dbxUtilKind factory
|
|
31
35
|
* @dbxUtilTags service, handler, set, factory, register
|
|
32
36
|
* @dbxUtilRelated handler-mapped-set-function, handler-factory
|
|
33
37
|
*
|
|
34
|
-
* @param accessor - The handler set accessor to register on.
|
|
35
|
-
* @param key - The key (or keys) to associate the handler with.
|
|
36
|
-
* @returns A function that accepts a handler function and registers it for the given key.
|
|
37
38
|
* @__NO_SIDE_EFFECTS__
|
|
38
39
|
*/
|
|
39
40
|
export declare function handlerSetFunction<T, K extends PrimativeKey = string, R = HandleResult>(accessor: HandlerSetAccessor<T, K, R>, key: ArrayOrValue<K>): HandlerSetFunction<T, R>;
|
|
40
41
|
/**
|
|
41
|
-
*
|
|
42
|
+
* Registers a handler function whose input type differs from the handler's native type,
|
|
42
43
|
* using a mapping function to convert between them.
|
|
43
44
|
*/
|
|
44
45
|
export type HandlerMappedSetFunction<I, R = HandleResult> = (handlerFunction: InternalHandlerFunction<I, R>) => void;
|
|
@@ -46,16 +47,17 @@ export type HandlerMappedSetFunction<I, R = HandleResult> = (handlerFunction: In
|
|
|
46
47
|
* Creates a {@link HandlerMappedSetFunction} that maps the handler's native input type to a different
|
|
47
48
|
* type before invoking the registered handler function.
|
|
48
49
|
*
|
|
50
|
+
* @param accessor - The handler set accessor to register on.
|
|
51
|
+
* @param key - The key (or keys) to associate the handler with.
|
|
52
|
+
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
53
|
+
* @returns Accepts a mapped handler function and registers it.
|
|
54
|
+
*
|
|
49
55
|
* @dbxUtil
|
|
50
56
|
* @dbxUtilCategory service
|
|
51
57
|
* @dbxUtilKind factory
|
|
52
58
|
* @dbxUtilTags service, handler, set, mapped, factory, transform
|
|
53
59
|
* @dbxUtilRelated handler-set-function, handler-mapped-set-function-factory
|
|
54
60
|
*
|
|
55
|
-
* @param accessor - The handler set accessor to register on.
|
|
56
|
-
* @param key - The key (or keys) to associate the handler with.
|
|
57
|
-
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
58
|
-
* @returns A function that accepts a mapped handler function and registers it.
|
|
59
61
|
* @__NO_SIDE_EFFECTS__
|
|
60
62
|
*/
|
|
61
63
|
export declare function handlerMappedSetFunction<I, T, K extends PrimativeKey = string, R = HandleResult>(accessor: HandlerSetAccessor<T, K, R>, key: ArrayOrValue<K>, mapFn: MapFunction<T, I>): HandlerMappedSetFunction<I, R>;
|
|
@@ -66,24 +68,25 @@ export type HandlerMappedSetFunctionFactory<I, K extends PrimativeKey = string,
|
|
|
66
68
|
/**
|
|
67
69
|
* Creates a {@link HandlerMappedSetFunctionFactory} that produces mapped set functions for any given key.
|
|
68
70
|
*
|
|
71
|
+
* @param accessor - The handler set accessor to register on.
|
|
72
|
+
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
73
|
+
* @returns A factory that creates HandlerMappedSetFunctions for specific keys.
|
|
74
|
+
*
|
|
69
75
|
* @dbxUtil
|
|
70
76
|
* @dbxUtilCategory service
|
|
71
77
|
* @dbxUtilKind factory
|
|
72
78
|
* @dbxUtilTags service, handler, mapped, factory, dispatch
|
|
73
79
|
* @dbxUtilRelated handler-mapped-set-function, handler-set-function
|
|
74
80
|
*
|
|
75
|
-
* @param accessor - The handler set accessor to register on.
|
|
76
|
-
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
77
|
-
* @returns A factory that creates HandlerMappedSetFunctions for specific keys.
|
|
78
81
|
* @__NO_SIDE_EFFECTS__
|
|
79
82
|
*/
|
|
80
83
|
export declare function handlerMappedSetFunctionFactory<I, T, K extends PrimativeKey = string, R = HandleResult>(accessor: HandlerSetAccessor<T, K, R>, mapFn: MapFunction<T, I>): HandlerMappedSetFunctionFactory<I, K, R>;
|
|
81
84
|
/**
|
|
82
|
-
*
|
|
85
|
+
* Configures handler bindings via a configurer object.
|
|
83
86
|
*/
|
|
84
87
|
export type HandlerConfigurerFunction<C extends HandlerBindAccessor<T, K, R>, T, K extends PrimativeKey = string, R = HandleResult> = (configurer: C) => void;
|
|
85
88
|
/**
|
|
86
|
-
*
|
|
89
|
+
* Binds an object to a handler and invokes a configure callback.
|
|
87
90
|
*/
|
|
88
91
|
export type HandlerConfigurer<C extends HandlerBindAccessor<T, K, R>, T, K extends PrimativeKey = string, R = HandleResult> = (bindTo: unknown, configure: HandlerConfigurerFunction<C, T, K, R>) => void;
|
|
89
92
|
/**
|
|
@@ -97,20 +100,21 @@ export interface HandlerConfigurerFactoryConfig<C extends HandlerBindAccessor<T,
|
|
|
97
100
|
/**
|
|
98
101
|
* Creates a typed configurer from a bind accessor.
|
|
99
102
|
*/
|
|
100
|
-
configurerForAccessor: (accessor: HandlerBindAccessor<T, K, R>) => C;
|
|
103
|
+
readonly configurerForAccessor: (accessor: HandlerBindAccessor<T, K, R>) => C;
|
|
101
104
|
}
|
|
102
105
|
/**
|
|
103
106
|
* Creates a {@link HandlerConfigurerFactory} that produces configurers for binding handler functions
|
|
104
107
|
* to a handler instance with automatic `this` binding.
|
|
105
108
|
*
|
|
109
|
+
* @param config - Configuration providing the accessor-to-configurer mapping.
|
|
110
|
+
* @returns A factory that creates HandlerConfigurers for specific handlers.
|
|
111
|
+
*
|
|
106
112
|
* @dbxUtil
|
|
107
113
|
* @dbxUtilCategory service
|
|
108
114
|
* @dbxUtilKind factory
|
|
109
115
|
* @dbxUtilTags service, handler, configurer, factory, bind
|
|
110
116
|
* @dbxUtilRelated handler-bind-accessor, handler-factory
|
|
111
117
|
*
|
|
112
|
-
* @param config - Configuration providing the accessor-to-configurer mapping.
|
|
113
|
-
* @returns A factory that creates HandlerConfigurers for specific handlers.
|
|
114
118
|
* @__NO_SIDE_EFFECTS__
|
|
115
119
|
*/
|
|
116
120
|
export declare function handlerConfigurerFactory<C extends HandlerBindAccessor<T, K, R>, T, K extends PrimativeKey = string, R = HandleResult>(config: HandlerConfigurerFactoryConfig<C, T, K, R>): HandlerConfigurerFactory<C, T, K, R>;
|
|
@@ -109,14 +109,15 @@ export declare function handlerFactory<T, K extends PrimativeKey = string, R = H
|
|
|
109
109
|
/**
|
|
110
110
|
* Convenience function that creates a new {@link Handler} from the given key reader using default options.
|
|
111
111
|
*
|
|
112
|
+
* @param readKey - Function to extract the dispatch key from an input value.
|
|
113
|
+
* @returns A new Handler instance.
|
|
114
|
+
*
|
|
112
115
|
* @dbxUtil
|
|
113
116
|
* @dbxUtilCategory service
|
|
114
117
|
* @dbxUtilKind factory
|
|
115
118
|
* @dbxUtilTags service, handler, factory, dispatch, key, convenience
|
|
116
119
|
* @dbxUtilRelated handler-factory
|
|
117
120
|
*
|
|
118
|
-
* @param readKey - Function to extract the dispatch key from an input value.
|
|
119
|
-
* @returns A new Handler instance.
|
|
120
121
|
* @__NO_SIDE_EFFECTS__
|
|
121
122
|
*/
|
|
122
123
|
export declare function makeHandler<T, K extends PrimativeKey = string>(readKey: ReadKeyFunction<T, K>): Handler<T, K>;
|
|
@@ -27,7 +27,7 @@ export declare class TypedServiceRegistryInstance<S, T extends string = string>
|
|
|
27
27
|
*
|
|
28
28
|
* @param type - The type key to look up.
|
|
29
29
|
* @returns The registered service instance.
|
|
30
|
-
* @throws Error
|
|
30
|
+
* @throws {Error} If no service is registered for the given type.
|
|
31
31
|
*/
|
|
32
32
|
serviceForType(type: T): S;
|
|
33
33
|
}
|
|
@@ -38,7 +38,7 @@ export interface TypedServiceRegistrySetupConfig<S, T extends string = string> {
|
|
|
38
38
|
/**
|
|
39
39
|
* A record mapping type keys to their service instances.
|
|
40
40
|
*/
|
|
41
|
-
services: {
|
|
41
|
+
readonly services: {
|
|
42
42
|
[K in T]: S;
|
|
43
43
|
};
|
|
44
44
|
}
|