@dereekb/util 10.0.20 → 10.0.22
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/fetch/CHANGELOG.md +8 -0
- package/fetch/package.json +1 -1
- package/index.cjs.js +305 -198
- package/index.esm.js +380 -253
- package/package.json +1 -1
- package/src/lib/array/array.d.ts +7 -0
- package/src/lib/array/array.factory.d.ts +16 -0
- package/src/lib/page/page.calculator.d.ts +3 -3
- package/src/lib/page/page.d.ts +1 -1
- package/src/lib/page/page.filter.d.ts +2 -2
- package/src/lib/promise/promise.d.ts +35 -13
- package/src/lib/promise/promise.loop.d.ts +3 -2
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +1 -1
package/package.json
CHANGED
package/src/lib/array/array.d.ts
CHANGED
|
@@ -111,6 +111,13 @@ export declare function takeLast<T>(values: T[], maxToTake: number, keepFromFron
|
|
|
111
111
|
* @returns
|
|
112
112
|
*/
|
|
113
113
|
export declare function forEachWithArray<T>(array: Maybe<ArrayOrValue<T>>, forEach: (value: T) => void): T[];
|
|
114
|
+
/**
|
|
115
|
+
* Counts all the values in a nested array.
|
|
116
|
+
*
|
|
117
|
+
* @param array
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
export declare function countAllInNestedArray<T>(array: T[][]): number;
|
|
114
121
|
/**
|
|
115
122
|
* @deprecated Use mergeArraysIntoArray() instead. Will be removed in v10.1.
|
|
116
123
|
*/
|
|
@@ -30,3 +30,19 @@ export declare function arrayFactory<T>(factory: Factory<T> | FactoryWithIndex<T
|
|
|
30
30
|
* @returns
|
|
31
31
|
*/
|
|
32
32
|
export declare function arrayInputFactory<O, I>(factory: FactoryWithRequiredInput<O, I>): ArrayInputFactory<I, O>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a factory that returns the items from the input array and returns null after the factory function has exhausted all array values.
|
|
35
|
+
*
|
|
36
|
+
* The factory can only be used once.
|
|
37
|
+
*
|
|
38
|
+
* @param array
|
|
39
|
+
*/
|
|
40
|
+
export declare function terminatingFactoryFromArray<T>(array: T[]): Factory<T | null>;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* Creates a factory that returns the items from the input array and returns the terminating value if the input array is empty.
|
|
44
|
+
*
|
|
45
|
+
* @param array
|
|
46
|
+
* @param terminatingValue
|
|
47
|
+
*/
|
|
48
|
+
export declare function terminatingFactoryFromArray<T, E>(array: T[], terminatingValue: E): Factory<T | E>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Page } from './page';
|
|
1
|
+
import { type PageNumber, type Page } from './page';
|
|
2
2
|
export interface PageCalculatorConfig {
|
|
3
3
|
pageSize: number;
|
|
4
4
|
limitKey?: string;
|
|
@@ -16,9 +16,9 @@ export declare class PageCalculator {
|
|
|
16
16
|
calcWithPage(page?: Page): {
|
|
17
17
|
[x: string]: number;
|
|
18
18
|
};
|
|
19
|
-
calc(page?:
|
|
19
|
+
calc(page?: PageNumber): {
|
|
20
20
|
[x: string]: number;
|
|
21
21
|
};
|
|
22
22
|
calcSkipWithPage(page?: Page): number;
|
|
23
|
-
calcSkip(page?:
|
|
23
|
+
calcSkip(page?: PageNumber): number;
|
|
24
24
|
}
|
package/src/lib/page/page.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Filter, type OptionalFilter } from '../filter';
|
|
2
|
-
import { type Page } from '../page';
|
|
2
|
+
import { type PageNumber, type Page } from '../page';
|
|
3
3
|
import { type IterateFn, type IteratePageFn } from '../iterate';
|
|
4
4
|
/**
|
|
5
5
|
* Represents a page number with a filter.
|
|
@@ -29,7 +29,7 @@ export interface FilteredPageIterateFn<T> {
|
|
|
29
29
|
* @param request
|
|
30
30
|
* @returns
|
|
31
31
|
*/
|
|
32
|
-
export declare function filteredPage<F = unknown>(page:
|
|
32
|
+
export declare function filteredPage<F = unknown>(page: PageNumber, request?: Filter<F>): FilteredPage<F>;
|
|
33
33
|
/**
|
|
34
34
|
* Iterates using a delegate function sequentially.
|
|
35
35
|
*
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { type ArrayOrValue } from '../array/array';
|
|
1
2
|
import { type Milliseconds } from '../date/date';
|
|
2
3
|
import { type PrimativeKey, type ReadOneOrMoreKeysFunction } from '../key';
|
|
3
4
|
import { type IndexNumber } from '../value';
|
|
4
5
|
import { type Maybe } from '../value/maybe.type';
|
|
6
|
+
import { type PromiseOrValue } from './promise.type';
|
|
5
7
|
export type RunAsyncTaskForValueConfig<T = unknown> = Omit<PerformAsyncTaskConfig<T>, 'throwError'>;
|
|
6
8
|
export type RunAsyncTasksForValuesConfig<T = unknown> = Omit<PerformAsyncTasksConfig<T>, 'throwError'>;
|
|
7
9
|
/**
|
|
@@ -61,7 +63,28 @@ export declare function performAsyncTask<O>(taskFn: () => Promise<O>, config?: P
|
|
|
61
63
|
* Used as a key to identify the "group" that a task belongs to to prevent other concurrent tasks from that group from running in parallel when parallel execution is desired.
|
|
62
64
|
*/
|
|
63
65
|
export type PerformTasksInParallelTaskUniqueKey = string;
|
|
64
|
-
export
|
|
66
|
+
export type PerformTasksInParallelFunctionConfig<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey> = Omit<PerformTasksFromFactoryInParallelFunctionConfig<I, K>, 'waitBetweenTaskInputRequests'>;
|
|
67
|
+
/**
|
|
68
|
+
* Function that awaits a promise generated from each of the input values.
|
|
69
|
+
*
|
|
70
|
+
* Will throw an error if any error is encountered as soon as it is encountered. No further tasks will be dispatched, but tasks that have already been dispatched will continue to run.
|
|
71
|
+
*/
|
|
72
|
+
export type PerformTasksInParallelFunction<I> = (input: I[]) => Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Convenience function for calling performTasksInParallelFunction() with the given input.
|
|
75
|
+
*
|
|
76
|
+
* @param input
|
|
77
|
+
* @param config
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
export declare function performTasksInParallel<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(input: I[], config: PerformTasksInParallelFunctionConfig<I, K>): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a function that performs tasks in parallel.
|
|
83
|
+
*
|
|
84
|
+
* @param config
|
|
85
|
+
*/
|
|
86
|
+
export declare function performTasksInParallelFunction<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(config: PerformTasksInParallelFunctionConfig<I, K>): PerformTasksInParallelFunction<I>;
|
|
87
|
+
export interface PerformTasksFromFactoryInParallelFunctionConfig<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey> {
|
|
65
88
|
/**
|
|
66
89
|
* Creates a promise from the input.
|
|
67
90
|
*/
|
|
@@ -86,24 +109,23 @@ export interface PerformTasksInParallelFunctionConfig<I, K extends PrimativeKey
|
|
|
86
109
|
* Optional amount of time to wait between each task.
|
|
87
110
|
*/
|
|
88
111
|
readonly waitBetweenTasks?: Milliseconds;
|
|
112
|
+
/**
|
|
113
|
+
* Optional amount of time to wait between each task input request.
|
|
114
|
+
*/
|
|
115
|
+
readonly waitBetweenTaskInputRequests?: Milliseconds;
|
|
89
116
|
}
|
|
117
|
+
export type PerformTaskFactoryTasksInParallelFunctionTaskInputFactory<I> = () => PromiseOrValue<ArrayOrValue<I> | null>;
|
|
90
118
|
/**
|
|
91
|
-
* Function that awaits
|
|
119
|
+
* Function that awaits all promises generated from the task factory until the factory returns null.
|
|
92
120
|
*
|
|
93
|
-
*
|
|
94
|
-
*/
|
|
95
|
-
export type PerformTasksInParallelFunction<I> = (input: I[]) => Promise<void>;
|
|
96
|
-
/**
|
|
97
|
-
* Convenience function for calling performTasksInParallelFunction() with the given input.
|
|
121
|
+
* If an array is pushed then the task factory will begin (but not necessarily complete) all those tasks before pulling the next set of tasks.
|
|
98
122
|
*
|
|
99
|
-
*
|
|
100
|
-
* @param config
|
|
101
|
-
* @returns
|
|
123
|
+
* Will throw an error if any error is encountered as soon as it is encountered. No further tasks will be dispatched, but tasks that have already been dispatched will continue to run.
|
|
102
124
|
*/
|
|
103
|
-
export
|
|
125
|
+
export type PerformTaskFactoryTasksInParallelFunction<I> = (taskInputFactory: PerformTaskFactoryTasksInParallelFunctionTaskInputFactory<I>) => Promise<void>;
|
|
104
126
|
/**
|
|
105
|
-
* Creates a function that performs tasks in parallel.
|
|
127
|
+
* Creates a function that performs tasks from the task factory in parallel.
|
|
106
128
|
*
|
|
107
129
|
* @param config
|
|
108
130
|
*/
|
|
109
|
-
export declare function
|
|
131
|
+
export declare function performTasksFromFactoryInParallelFunction<I, K extends PrimativeKey = PerformTasksInParallelTaskUniqueKey>(config: PerformTasksFromFactoryInParallelFunctionConfig<I, K>): PerformTaskFactoryTasksInParallelFunction<I>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { type BatchCount } from '../grouping';
|
|
2
2
|
import { type Maybe } from '../value/maybe.type';
|
|
3
|
+
import { type PromiseOrValue } from './promise.type';
|
|
3
4
|
export interface PerformTaskLoopConfig<O> {
|
|
4
5
|
next: (i: number, prev: Maybe<O>) => Promise<O>;
|
|
5
|
-
checkContinue: (prev: Maybe<O>, i: number) => boolean
|
|
6
|
+
checkContinue: (prev: Maybe<O>, i: number) => PromiseOrValue<boolean>;
|
|
6
7
|
}
|
|
7
8
|
export interface PerformTaskLoopWithInitConfig<O> {
|
|
8
9
|
initValue: O;
|
|
9
10
|
next: (i: number, prev: O) => Promise<O>;
|
|
10
|
-
checkContinue: (prev: O, i: number) => boolean
|
|
11
|
+
checkContinue: (prev: O, i: number) => PromiseOrValue<boolean>;
|
|
11
12
|
}
|
|
12
13
|
export declare function performTaskLoop<O>(config: PerformTaskLoopWithInitConfig<O>): Promise<O>;
|
|
13
14
|
export declare function performTaskLoop<O>(config: PerformTaskLoopConfig<O>): Promise<O>;
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [10.0.22](https://github.com/dereekb/dbx-components/compare/v10.0.21-dev...v10.0.22) (2024-02-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [10.0.21](https://github.com/dereekb/dbx-components/compare/v10.0.20-dev...v10.0.21) (2024-02-17)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [10.0.20](https://github.com/dereekb/dbx-components/compare/v10.0.19-dev...v10.0.20) (2024-02-15)
|
|
6
14
|
|
|
7
15
|
|