@types/async 3.2.4 → 3.2.8
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.
- async/LICENSE +0 -0
- async/README.md +1 -1
- async/index.d.ts +184 -65
- async/package.json +4 -3
async/LICENSE
CHANGED
|
File without changes
|
async/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for Async (https://github.com/caolan/asyn
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/async.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Sat, 18 Sep 2021 09:31:20 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `async`
|
|
14
14
|
|
async/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export interface AsyncAutoTaskFunction<R1, R extends Dictionary<any>, E = Error>
|
|
|
41
41
|
|
|
42
42
|
export interface DataContainer<T> {
|
|
43
43
|
data: T;
|
|
44
|
+
priority: number;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
export interface CallbackContainer {
|
|
@@ -51,74 +52,181 @@ export interface PriorityContainer {
|
|
|
51
52
|
priority: number;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
export interface
|
|
55
|
+
export interface QueueObject<T> {
|
|
56
|
+
/**
|
|
57
|
+
* Returns the number of items waiting to be processed.
|
|
58
|
+
*/
|
|
55
59
|
length(): number;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Indicates whether or not any items have been pushed and processed by the queue.
|
|
63
|
+
*/
|
|
56
64
|
started: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Returns the number of items currently being processed.
|
|
68
|
+
*/
|
|
57
69
|
running(): number;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Returns an array of items currently being processed.
|
|
73
|
+
*/
|
|
74
|
+
workersList<TWorker extends DataContainer<T>, CallbackContainer>(): TWorker[];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns false if there are items waiting or being processed, or true if not.
|
|
78
|
+
*/
|
|
58
79
|
idle(): boolean;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* An integer for determining how many worker functions should be run in parallel.
|
|
83
|
+
* This property can be changed after a queue is created to alter the concurrency on-the-fly.
|
|
84
|
+
*/
|
|
59
85
|
concurrency: number;
|
|
60
|
-
|
|
61
|
-
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* An integer that specifies how many items are passed to the worker function at a time.
|
|
89
|
+
* Only applies if this is a cargo object
|
|
90
|
+
*/
|
|
91
|
+
payload: number;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Add a new task to the queue. Calls `callback` once the worker has finished
|
|
95
|
+
* processing the task.
|
|
96
|
+
*
|
|
97
|
+
* Instead of a single task, a tasks array can be submitted.
|
|
98
|
+
* The respective callback is used for every task in the list.
|
|
99
|
+
*/
|
|
100
|
+
push<R>(task: T | T[]): Promise<R>;
|
|
101
|
+
push<R, E = Error>(task: T | T[], callback: AsyncResultCallback<R, E>): void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Add a new task to the front of the queue
|
|
105
|
+
*/
|
|
106
|
+
unshift<R>(task: T | T[]): Promise<R>;
|
|
107
|
+
unshift<R, E = Error>(task: T | T[], callback: AsyncResultCallback<R, E>): void;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The same as `q.push`, except this returns a promise that rejects if an error occurs.
|
|
111
|
+
* The `callback` arg is ignored
|
|
112
|
+
*/
|
|
113
|
+
pushAsync<R>(task: T | T[]): Promise<R>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The same as `q.unshift`, except this returns a promise that rejects if an error occurs.
|
|
117
|
+
* The `callback` arg is ignored
|
|
118
|
+
*/
|
|
119
|
+
unshiftAsync<R>(task: T | T[]): Promise<R>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Remove items from the queue that match a test function.
|
|
123
|
+
* The test function will be passed an object with a `data` property,
|
|
124
|
+
* and a `priority` property, if this is a `priorityQueue` object.
|
|
125
|
+
*/
|
|
62
126
|
remove(filter: (node: DataContainer<T>) => boolean): void;
|
|
63
127
|
|
|
128
|
+
/**
|
|
129
|
+
* A function that sets a callback that is called when the number of
|
|
130
|
+
* running workers hits the `concurrency` limit, and further tasks will be
|
|
131
|
+
* queued.
|
|
132
|
+
*
|
|
133
|
+
* If the callback is omitted, `q.saturated()` returns a promise
|
|
134
|
+
* for the next occurrence.
|
|
135
|
+
*/
|
|
64
136
|
saturated(): Promise<void>;
|
|
65
137
|
saturated(handler: () => void): void;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A function that sets a callback that is called when the number
|
|
141
|
+
* of running workers is less than the `concurrency` & `buffer` limits,
|
|
142
|
+
* and further tasks will not be queued
|
|
143
|
+
*
|
|
144
|
+
* If the callback is omitted, `q.unsaturated()` returns a promise
|
|
145
|
+
* for the next occurrence.
|
|
146
|
+
*/
|
|
147
|
+
unsaturated(): Promise<void>;
|
|
148
|
+
unsaturated(handler: () => void): void;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* A minimum threshold buffer in order to say that the `queue` is `unsaturated`.
|
|
152
|
+
*/
|
|
153
|
+
buffer: number;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A function that sets a callback that is called when the last item from the `queue`
|
|
157
|
+
* is given to a `worker`.
|
|
158
|
+
*
|
|
159
|
+
* If the callback is omitted, `q.empty()` returns a promise for the next occurrence.
|
|
160
|
+
*/
|
|
66
161
|
empty(): Promise<void>;
|
|
67
162
|
empty(handler: () => void): void;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A function that sets a callback that is called when the last item from
|
|
166
|
+
* the `queue` has returned from the `worker`.
|
|
167
|
+
*
|
|
168
|
+
* If the callback is omitted, `q.drain()` returns a promise for the next occurrence.
|
|
169
|
+
*/
|
|
68
170
|
drain(): Promise<void>;
|
|
69
171
|
drain(handler: () => void): void;
|
|
70
172
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
error(): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* A function that sets a callback that is called when a task errors.
|
|
175
|
+
*
|
|
176
|
+
* If the callback is omitted, `q.error()` returns a promise that rejects on the next error.
|
|
177
|
+
*/
|
|
178
|
+
error(): Promise<never>;
|
|
78
179
|
error(handler: (error: Error, task: T) => void): void;
|
|
79
180
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
export interface AsyncPriorityQueue<T> {
|
|
85
|
-
length(): number;
|
|
86
|
-
concurrency: number;
|
|
87
|
-
started: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* A boolean for determining whether the queue is in a paused state.
|
|
183
|
+
*/
|
|
88
184
|
paused: boolean;
|
|
89
|
-
push<R, E = Error>(task: T | T[], priority: number, callback?: AsyncResultArrayCallback<R, E>): void;
|
|
90
|
-
saturated: () => any;
|
|
91
|
-
empty: () => any;
|
|
92
|
-
drain: () => any;
|
|
93
|
-
running(): number;
|
|
94
|
-
idle(): boolean;
|
|
95
|
-
pause(): void;
|
|
96
|
-
resume(): void;
|
|
97
|
-
kill(): void;
|
|
98
|
-
workersList<TWorker extends DataContainer<T>, CallbackContainer, PriorityContainer>(): TWorker[];
|
|
99
|
-
error(error: Error, data: any): void;
|
|
100
|
-
unsaturated(): void;
|
|
101
|
-
buffer: number;
|
|
102
|
-
}
|
|
103
185
|
|
|
104
|
-
export interface AsyncCargo {
|
|
105
|
-
length(): number;
|
|
106
|
-
payload?: number;
|
|
107
|
-
push(task: any, callback?: Function): void;
|
|
108
|
-
saturated(): void;
|
|
109
|
-
empty(): void;
|
|
110
186
|
/**
|
|
111
|
-
*
|
|
112
|
-
* If the callback is omitted, q.drain() returns a promise for the next occurrence.
|
|
187
|
+
* A function that pauses the processing of tasks until `q.resume()` is called.
|
|
113
188
|
*/
|
|
114
|
-
drain(): Promise<void>;
|
|
115
|
-
drain(handler: () => void): void;
|
|
116
|
-
idle(): boolean;
|
|
117
189
|
pause(): void;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* A function that resumes the processing of queued tasks when the queue
|
|
193
|
+
* is paused.
|
|
194
|
+
*/
|
|
118
195
|
resume(): void;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* A function that removes the drain callback and empties remaining tasks
|
|
199
|
+
* from the queue forcing it to go idle. No more tasks should be pushed to
|
|
200
|
+
* the queue after calling this function.
|
|
201
|
+
*/
|
|
119
202
|
kill(): void;
|
|
120
203
|
}
|
|
121
204
|
|
|
205
|
+
/**
|
|
206
|
+
* A priorityQueue object to manage the tasks.
|
|
207
|
+
*
|
|
208
|
+
* There are two differences between queue and priorityQueue objects:
|
|
209
|
+
* - `push(task, priority, [callback])` — priority should be a number. If an array of tasks is given, all tasks will be assigned the same priority.
|
|
210
|
+
* - The `unshift` method was removed.
|
|
211
|
+
*/
|
|
212
|
+
// FIXME: can not use Omit due to ts version restriction. Replace Pick with Omit, when ts 3.5+ will be allowed
|
|
213
|
+
export interface AsyncPriorityQueue<T> extends Pick<QueueObject<T>, Exclude<keyof QueueObject<T>, 'push' | 'unshift'>> {
|
|
214
|
+
push<R>(task: T | T[], priority?: number): Promise<R>;
|
|
215
|
+
push<R, E = Error>(task: T | T[], priority: number, callback: AsyncResultCallback<R, E>): void;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @deprecated this is a type that left here for backward compatibility.
|
|
220
|
+
* Please use QueueObject instead
|
|
221
|
+
*/
|
|
222
|
+
export type AsyncQueue<T> = QueueObject<T>;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @deprecated this is a type that left here for backward compatibility.
|
|
226
|
+
* Please use QueueObject instead
|
|
227
|
+
*/
|
|
228
|
+
export type AsyncCargoQueue<T = any> = QueueObject<T>;
|
|
229
|
+
|
|
122
230
|
// Collections
|
|
123
231
|
export function each<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncIterator<T, E>, callback: ErrorCallback<E>): void;
|
|
124
232
|
export function each<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncIterator<T, E>): Promise<void>;
|
|
@@ -223,42 +331,53 @@ export function compose(...fns: Function[]): Function;
|
|
|
223
331
|
export function seq(...fns: Function[]): Function;
|
|
224
332
|
export function applyEach(fns: Function[], ...argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
|
|
225
333
|
export function applyEachSeries(fns: Function[], ...argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
|
|
226
|
-
export function queue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency?: number):
|
|
227
|
-
export function queue<T, R, E = Error>(worker: AsyncResultIterator<T, R, E>, concurrency?: number):
|
|
228
|
-
export function priorityQueue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency
|
|
229
|
-
export function cargo<E = Error>(worker:
|
|
230
|
-
export function
|
|
231
|
-
|
|
334
|
+
export function queue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency?: number): QueueObject<T>;
|
|
335
|
+
export function queue<T, R, E = Error>(worker: AsyncResultIterator<T, R, E>, concurrency?: number): QueueObject<T>;
|
|
336
|
+
export function priorityQueue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency?: number): AsyncPriorityQueue<T>;
|
|
337
|
+
export function cargo<T, E = Error>(worker: AsyncWorker<T[], E>, payload?: number): QueueObject<T>;
|
|
338
|
+
export function cargoQueue<T, E = Error>(
|
|
339
|
+
worker: AsyncWorker<T[], E>,
|
|
340
|
+
concurrency?: number,
|
|
341
|
+
payload?: number,
|
|
342
|
+
): QueueObject<T>;
|
|
343
|
+
export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, concurrency?: number): Promise<R>;
|
|
344
|
+
export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, concurrency: number, callback: AsyncResultCallback<R, E>): void;
|
|
345
|
+
export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, callback: AsyncResultCallback<R, E>): void;
|
|
232
346
|
export function autoInject<E = Error>(tasks: any, callback?: AsyncResultCallback<any, E>): void;
|
|
233
347
|
|
|
234
|
-
export interface RetryOptions {
|
|
235
|
-
times?: number;
|
|
236
|
-
interval?: number | ((retryCount: number) => number);
|
|
237
|
-
errorFilter?: (error:
|
|
348
|
+
export interface RetryOptions<E> {
|
|
349
|
+
times?: number | undefined;
|
|
350
|
+
interval?: number | ((retryCount: number) => number) | undefined;
|
|
351
|
+
errorFilter?: ((error: E) => boolean) | undefined;
|
|
238
352
|
}
|
|
239
353
|
export function retry<T, E = Error>(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
354
|
+
task: (() => Promise<T>) | ((callback: AsyncResultCallback<T, E>) => void),
|
|
355
|
+
): Promise<T>;
|
|
356
|
+
export function retry<T, E = Error>(
|
|
357
|
+
opts: number | RetryOptions<E>,
|
|
358
|
+
task: (() => Promise<T>) | ((callback: AsyncResultCallback<T, E>) => void),
|
|
359
|
+
): Promise<T>;
|
|
360
|
+
export function retry<T, E = Error>(
|
|
361
|
+
task: (() => Promise<T>) | ((callback: AsyncResultCallback<T, E>) => void),
|
|
362
|
+
callback: AsyncResultCallback<T, E>,
|
|
363
|
+
): void;
|
|
243
364
|
export function retry<T, E = Error>(
|
|
244
|
-
opts
|
|
245
|
-
task
|
|
246
|
-
callback
|
|
365
|
+
opts: number | RetryOptions<E>,
|
|
366
|
+
task: (() => Promise<T>) | ((callback: AsyncResultCallback<T, E>) => void),
|
|
367
|
+
callback: AsyncResultCallback<T, E>,
|
|
247
368
|
): void;
|
|
248
369
|
|
|
249
370
|
export function retryable<T, E = Error>(task: AsyncFunction<T, E>): AsyncFunction<T, E>;
|
|
250
371
|
export function retryable<T, E = Error>(
|
|
251
|
-
opts:
|
|
252
|
-
|
|
253
|
-
| RetryOptions & {arity?: number},
|
|
254
|
-
task: AsyncFunction<T, E>
|
|
372
|
+
opts: number | (RetryOptions<E> & { arity?: number | undefined }),
|
|
373
|
+
task: AsyncFunction<T, E>,
|
|
255
374
|
): AsyncFunction<T, E>;
|
|
256
375
|
export function apply<E = Error>(fn: Function, ...args: any[]): AsyncFunction<any, E>;
|
|
257
376
|
export function nextTick(callback: Function, ...args: any[]): void;
|
|
258
377
|
export const setImmediate: typeof nextTick;
|
|
259
378
|
|
|
260
|
-
export function reflect<T, E = Error>(fn: AsyncFunction<T, E>): (callback: (err: null, result: {error?: E, value?: T}) => void) => void;
|
|
261
|
-
export function reflectAll<T, E = Error>(tasks: Array<AsyncFunction<T, E>>): Array<(callback: (err: null, result: {error?: E, value?: T}) => void) => void>;
|
|
379
|
+
export function reflect<T, E = Error>(fn: AsyncFunction<T, E>): (callback: (err: null, result: {error?: E | undefined, value?: T | undefined}) => void) => void;
|
|
380
|
+
export function reflectAll<T, E = Error>(tasks: Array<AsyncFunction<T, E>>): Array<(callback: (err: null, result: {error?: E | undefined, value?: T | undefined}) => void) => void>;
|
|
262
381
|
|
|
263
382
|
export function timeout<T, E = Error>(fn: AsyncFunction<T, E>, milliseconds: number, info?: any): AsyncFunction<T, E>;
|
|
264
383
|
export function timeout<T, R, E = Error>(fn: AsyncResultIterator<T, R, E>, milliseconds: number, info?: any): AsyncResultIterator<T, R, E>;
|
async/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/async",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.8",
|
|
4
4
|
"description": "TypeScript definitions for Async",
|
|
5
|
+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/async",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"contributors": [
|
|
7
8
|
{
|
|
@@ -59,6 +60,6 @@
|
|
|
59
60
|
},
|
|
60
61
|
"scripts": {},
|
|
61
62
|
"dependencies": {},
|
|
62
|
-
"typesPublisherContentHash": "
|
|
63
|
-
"typeScriptVersion": "3.
|
|
63
|
+
"typesPublisherContentHash": "3f35b238c96275a2c048c3cb20dc43836163366b79ac6be29293d6c83bbbafdf",
|
|
64
|
+
"typeScriptVersion": "3.7"
|
|
64
65
|
}
|