UNPKG

24.6 kBTypeScriptView Raw
1// Type definitions for Async 3.2
2// Project: https://github.com/caolan/async, https://caolan.github.io/async
3// Definitions by: Boris Yankov <https://github.com/borisyankov>
4// Arseniy Maximov <https://github.com/kern0>
5// Joe Herman <https://github.com/Penryn>
6// Angus Fenying <https://github.com/fenying>
7// Pascal Martin <https://github.com/pascalmartin>
8// Etienne Rossignon <https://github.com/erossignon>
9// Lifeng Zhu <https://github.com/Juliiii>
10// Tümay Çeber <https://github.com/brendtumi>
11// Andrew Pensinger <https://github.com/apnsngr>
12// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
13// TypeScript Version: 2.3
14
15export as namespace async;
16
17export interface Dictionary<T> { [key: string]: T; }
18export type IterableCollection<T> = T[] | IterableIterator<T> | Dictionary<T>;
19
20export interface ErrorCallback<E = Error> { (err?: E | null): void; }
21export interface AsyncBooleanResultCallback<E = Error> { (err?: E | null, truthValue?: boolean): void; }
22export interface AsyncResultCallback<T, E = Error> { (err?: E | null, result?: T): void; }
23export interface AsyncResultArrayCallback<T, E = Error> { (err?: E | null, results?: Array<T | undefined>): void; }
24export interface AsyncResultObjectCallback<T, E = Error> { (err: E | undefined, results: Dictionary<T | undefined>): void; }
25
26export interface AsyncFunction<T, E = Error> { (callback: (err?: E | null, result?: T) => void): void; }
27export interface AsyncFunctionEx<T, E = Error> { (callback: (err?: E | null, ...results: T[]) => void): void; }
28export interface AsyncIterator<T, E = Error> { (item: T, callback: ErrorCallback<E>): void; }
29export interface AsyncForEachOfIterator<T, E = Error> { (item: T, key: number|string, callback: ErrorCallback<E>): void; }
30export interface AsyncResultIterator<T, R, E = Error> { (item: T, callback: AsyncResultCallback<R, E>): void; }
31export interface AsyncResultIteratorPromise<T, R> { (item: T): Promise<R>; }
32export interface AsyncMemoIterator<T, R, E = Error> { (memo: R | undefined, item: T, callback: AsyncResultCallback<R, E>): void; }
33export interface AsyncBooleanIterator<T, E = Error> { (item: T, callback: AsyncBooleanResultCallback<E>): void; }
34
35export interface AsyncWorker<T, E = Error> { (task: T, callback: ErrorCallback<E>): void; }
36export interface AsyncVoidFunction<E = Error> { (callback: ErrorCallback<E>): void; }
37
38export type AsyncAutoTasks<R extends Dictionary<any>, E> = { [K in keyof R]: AsyncAutoTask<R[K], R, E> };
39export type AsyncAutoTask<R1, R extends Dictionary<any>, E> = AsyncAutoTaskFunctionWithoutDependencies<R1, E> | Array<keyof R | AsyncAutoTaskFunction<R1, R, E>>;
40export interface AsyncAutoTaskFunctionWithoutDependencies<R1, E = Error> { (cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
41export interface AsyncAutoTaskFunction<R1, R extends Dictionary<any>, E = Error> { (results: R, cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
42
43export interface DataContainer<T> {
44 data: T;
45 priority: number;
46}
47
48export interface CallbackContainer {
49 callback: Function;
50}
51
52export interface PriorityContainer {
53 priority: number;
54}
55
56export interface QueueObject<T> {
57 /**
58 * Returns the number of items waiting to be processed.
59 */
60 length(): number;
61
62 /**
63 * Indicates whether or not any items have been pushed and processed by the queue.
64 */
65 started: boolean;
66
67 /**
68 * Returns the number of items currently being processed.
69 */
70 running(): number;
71
72 /**
73 * Returns an array of items currently being processed.
74 */
75 workersList<TWorker extends DataContainer<T>, CallbackContainer>(): TWorker[];
76
77 /**
78 * Returns false if there are items waiting or being processed, or true if not.
79 */
80 idle(): boolean;
81
82 /**
83 * An integer for determining how many worker functions should be run in parallel.
84 * This property can be changed after a queue is created to alter the concurrency on-the-fly.
85 */
86 concurrency: number;
87
88 /**
89 * An integer that specifies how many items are passed to the worker function at a time.
90 * Only applies if this is a cargo object
91 */
92 payload: number;
93
94 /**
95 * Add a new task to the queue. Calls `callback` once the worker has finished
96 * processing the task.
97 *
98 * Instead of a single task, a tasks array can be submitted.
99 * The respective callback is used for every task in the list.
100 */
101 push<R>(task: T | T[]): Promise<R>;
102 push<R, E = Error>(task: T | T[], callback: AsyncResultCallback<R, E>): void;
103
104 /**
105 * Add a new task to the front of the queue
106 */
107 unshift<R>(task: T | T[]): Promise<R>;
108 unshift<R, E = Error>(task: T | T[], callback: AsyncResultCallback<R, E>): void;
109
110 /**
111 * The same as `q.push`, except this returns a promise that rejects if an error occurs.
112 * The `callback` arg is ignored
113 */
114 pushAsync<R>(task: T | T[]): Promise<R>;
115
116 /**
117 * The same as `q.unshift`, except this returns a promise that rejects if an error occurs.
118 * The `callback` arg is ignored
119 */
120 unshiftAsync<R>(task: T | T[]): Promise<R>;
121
122 /**
123 * Remove items from the queue that match a test function.
124 * The test function will be passed an object with a `data` property,
125 * and a `priority` property, if this is a `priorityQueue` object.
126 */
127 remove(filter: (node: DataContainer<T>) => boolean): void;
128
129 /**
130 * A function that sets a callback that is called when the number of
131 * running workers hits the `concurrency` limit, and further tasks will be
132 * queued.
133 *
134 * If the callback is omitted, `q.saturated()` returns a promise
135 * for the next occurrence.
136 */
137 saturated(): Promise<void>;
138 saturated(handler: () => void): void;
139
140 /**
141 * A function that sets a callback that is called when the number
142 * of running workers is less than the `concurrency` & `buffer` limits,
143 * and further tasks will not be queued
144 *
145 * If the callback is omitted, `q.unsaturated()` returns a promise
146 * for the next occurrence.
147 */
148 unsaturated(): Promise<void>;
149 unsaturated(handler: () => void): void;
150
151 /**
152 * A minimum threshold buffer in order to say that the `queue` is `unsaturated`.
153 */
154 buffer: number;
155
156 /**
157 * A function that sets a callback that is called when the last item from the `queue`
158 * is given to a `worker`.
159 *
160 * If the callback is omitted, `q.empty()` returns a promise for the next occurrence.
161 */
162 empty(): Promise<void>;
163 empty(handler: () => void): void;
164
165 /**
166 * A function that sets a callback that is called when the last item from
167 * the `queue` has returned from the `worker`.
168 *
169 * If the callback is omitted, `q.drain()` returns a promise for the next occurrence.
170 */
171 drain(): Promise<void>;
172 drain(handler: () => void): void;
173
174 /**
175 * A function that sets a callback that is called when a task errors.
176 *
177 * If the callback is omitted, `q.error()` returns a promise that rejects on the next error.
178 */
179 error(): Promise<never>;
180 error(handler: (error: Error, task: T) => void): void;
181
182 /**
183 * A boolean for determining whether the queue is in a paused state.
184 */
185 paused: boolean;
186
187 /**
188 * A function that pauses the processing of tasks until `q.resume()` is called.
189 */
190 pause(): void;
191
192 /**
193 * A function that resumes the processing of queued tasks when the queue
194 * is paused.
195 */
196 resume(): void;
197
198 /**
199 * A function that removes the drain callback and empties remaining tasks
200 * from the queue forcing it to go idle. No more tasks should be pushed to
201 * the queue after calling this function.
202 */
203 kill(): void;
204}
205
206/**
207 * A priorityQueue object to manage the tasks.
208 *
209 * There are two differences between queue and priorityQueue objects:
210 * - `push(task, priority, [callback])` — priority should be a number. If an array of tasks is given, all tasks will be assigned the same priority.
211 * - The `unshift` method was removed.
212 */
213// FIXME: can not use Omit due to ts version restriction. Replace Pick with Omit, when ts 3.5+ will be allowed
214export interface AsyncPriorityQueue<T> extends Pick<QueueObject<T>, Exclude<keyof QueueObject<T>, 'push' | 'unshift'>> {
215 push<R>(task: T | T[], priority?: number): Promise<R>;
216 push<R, E = Error>(task: T | T[], priority: number, callback: AsyncResultCallback<R, E>): void;
217}
218
219/**
220 * @deprecated this is a type that left here for backward compatibility.
221 * Please use QueueObject instead
222 */
223export type AsyncQueue<T> = QueueObject<T>;
224
225/**
226 * @deprecated this is a type that left here for backward compatibility.
227 * Please use QueueObject instead
228 */
229export type AsyncCargoQueue<T = any> = QueueObject<T>;
230
231// Collections
232export function each<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncIterator<T, E>, callback: ErrorCallback<E>): void;
233export function each<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncIterator<T, E>): Promise<void>;
234export const eachSeries: typeof each;
235export function eachLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncIterator<T, E>, callback: ErrorCallback<E>): void;
236export function eachLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncIterator<T, E>): Promise<void>;
237export const forEach: typeof each;
238export const forEachSeries: typeof each;
239export const forEachLimit: typeof eachLimit;
240export function forEachOf<T, E = Error>(obj: IterableCollection<T>, iterator: AsyncForEachOfIterator<T, E>, callback: ErrorCallback<E>): void;
241export function forEachOf<T, E = Error>(obj: IterableCollection<T>, iterator: AsyncForEachOfIterator<T, E>): Promise<void>;
242export const forEachOfSeries: typeof forEachOf;
243export function forEachOfLimit<T, E = Error>(obj: IterableCollection<T>, limit: number, iterator: AsyncForEachOfIterator<T, E>, callback: ErrorCallback<E>): void;
244export function forEachOfLimit<T, E = Error>(obj: IterableCollection<T>, limit: number, iterator: AsyncForEachOfIterator<T, E>): Promise<void>;
245export const eachOf: typeof forEachOf;
246export const eachOfSeries: typeof forEachOf;
247export const eachOfLimit: typeof forEachOfLimit;
248export function map<T, R, E = Error>(
249 arr: T[] | IterableIterator<T> | Dictionary<T>,
250 iterator: (AsyncResultIterator<T, R, E> | AsyncResultIteratorPromise<T, R>),
251 callback: AsyncResultArrayCallback<R, E>
252 ): void;
253export function map<T, R, E = Error>(
254 arr: T[] | IterableIterator<T> | Dictionary<T>,
255 iterator: (AsyncResultIterator<T, R, E> | AsyncResultIteratorPromise<T, R>)
256 ): Promise<R[]>;
257
258export const mapSeries: typeof map;
259export function mapLimit<T, R, E = Error>(
260 arr: IterableCollection<T>,
261 limit: number, iterator: (AsyncResultIterator<T, R, E> | AsyncResultIteratorPromise<T, R>),
262 callback: AsyncResultArrayCallback<R, E>
263 ): void;
264export function mapLimit<T, R, E = Error>(
265 arr: IterableCollection<T>,
266 limit: number, iterator: (AsyncResultIterator<T, R, E> | AsyncResultIteratorPromise<T, R>)
267 ): Promise<R[]>;
268
269export function mapValuesLimit<T, R, E = Error>(
270 obj: Dictionary<T>,
271 limit: number,
272 iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void,
273 callback: AsyncResultObjectCallback<R, E>
274 ): void;
275export function mapValuesLimit<T, R, E = Error>(
276 obj: Dictionary<T>,
277 limit: number,
278 iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void
279): Promise<R>;
280
281export function mapValues<T, R, E = Error>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
282export function mapValues<T, R, E = Error>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void): Promise<R>;
283export const mapValuesSeries: typeof mapValues;
284export function filter<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback: AsyncResultArrayCallback<T, E>): void;
285export function filter<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>): Promise<T[]>;
286export const filterSeries: typeof filter;
287export function filterLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback: AsyncResultArrayCallback<T, E>): void;
288export function filterLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>): Promise<T[]>;
289export const select: typeof filter;
290export const selectSeries: typeof filter;
291export const selectLimit: typeof filterLimit;
292export const reject: typeof filter;
293export const rejectSeries: typeof filter;
294export const rejectLimit: typeof filterLimit;
295export function reduce<T, R, E = Error>(arr: T[] | IterableIterator<T>, memo: R, iterator: AsyncMemoIterator<T, R, E>, callback: AsyncResultCallback<R, E>): void;
296export function reduce<T, R, E = Error>(arr: T[] | IterableIterator<T>, memo: R, iterator: AsyncMemoIterator<T, R, E>): Promise<R>;
297export const inject: typeof reduce;
298export const foldl: typeof reduce;
299export const reduceRight: typeof reduce;
300export const foldr: typeof reduce;
301export function detect<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback: AsyncResultCallback<T, E>): void;
302export function detect<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>): Promise<T>;
303export const detectSeries: typeof detect;
304export function detectLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
305export const find: typeof detect;
306export const findSeries: typeof detect;
307export const findLimit: typeof detectLimit;
308export function sortBy<T, V, E = Error>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, V, E>, callback?: AsyncResultArrayCallback<T, E>): void;
309export function some<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
310export const someSeries: typeof some;
311export function someLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
312export const any: typeof some;
313export const anySeries: typeof someSeries;
314export const anyLimit: typeof someLimit;
315export function every<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
316export const everySeries: typeof every;
317export function everyLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
318export const all: typeof every;
319export const allSeries: typeof every;
320export const allLimit: typeof everyLimit;
321
322export function concat<T, R, E = Error>(arr: IterableCollection<T>, iterator: AsyncResultIterator<T, R[], E>, callback: AsyncResultArrayCallback<R, E>): void;
323export function concat<T, R, E = Error>(arr: IterableCollection<T>, iterator: AsyncResultIterator<T, R[], E>): Promise<R[]>;
324export function concatLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R[], E>, callback: AsyncResultArrayCallback<R, E>): void;
325export function concatLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R[], E>): Promise<R[]>;
326export const concatSeries: typeof concat;
327
328// Control Flow
329export function series<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
330export function series<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
331export function series<T, R, E = Error>(tasks: Array<AsyncFunction<T, E>> | Dictionary<AsyncFunction<T, E>>): Promise<R>;
332export function parallel<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
333export function parallel<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
334export function parallel<T, R, E = Error>(tasks: Array<AsyncFunction<T, E>> | Dictionary<AsyncFunction<T, E>>): Promise<R>;
335export function parallelLimit<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultArrayCallback<T, E>): void;
336export function parallelLimit<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultObjectCallback<T, E>): void;
337export function parallelLimit<T, R, E = Error>(tasks: Array<AsyncFunction<T, E>> | Dictionary<AsyncFunction<T, E>>, limit: number): Promise<R>;
338
339export function whilst<T, E = Error>(
340 test: (cb: AsyncBooleanResultCallback) => void,
341 fn: AsyncFunctionEx<T, E>,
342 callback: AsyncFunctionEx<T, E>
343): void;
344export function whilst<T, R, E = Error>(
345 test: (cb: AsyncBooleanResultCallback) => void,
346 fn: AsyncFunctionEx<T, E>
347): Promise<R>;
348export function doWhilst<T, E = Error>(
349 fn: AsyncFunctionEx<T, E>,
350 test: (/* ...results: T[], */ cb: AsyncBooleanResultCallback) => void,
351 callback: AsyncFunctionEx<T, E>
352): void;
353export function doWhilst<T, R, E = Error>(
354 fn: AsyncFunctionEx<T, E>,
355 test: (/* ...results: T[], */ cb: AsyncBooleanResultCallback) => void
356): Promise<R>;
357export function until<T, E = Error>(
358 test: (cb: AsyncBooleanResultCallback) => void,
359 fn: AsyncFunctionEx<T, E>,
360 callback: AsyncFunctionEx<T, E>
361): void;
362export function until<T, R, E = Error>(
363 test: (cb: AsyncBooleanResultCallback) => void,
364 fn: AsyncFunctionEx<T, E>
365): Promise<R>;
366export function doUntil<T, E = Error>(
367 fn: AsyncFunctionEx<T, E>,
368 test: (/* ...results: T[], */ cb: AsyncBooleanResultCallback) => void,
369 callback: AsyncFunctionEx<T, E>
370): void;
371export function doUntil<T, R, E = Error>(
372 fn: AsyncFunctionEx<T, E>,
373 test: (/* ...results: T[], */ cb: AsyncBooleanResultCallback) => void
374): Promise<R>;
375
376export function during<E = Error>(test: (testCallback: AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
377export function doDuring<E = Error>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
378export function forever<E = Error>(next: (next: ErrorCallback<E>) => void, errBack: ErrorCallback<E>): void;
379export function waterfall<T, E = Error>(tasks: Function[], callback?: AsyncResultCallback<T, E>): void;
380export function compose(...fns: Function[]): Function;
381export function seq(...fns: Function[]): Function;
382export function applyEach(fns: Function[], ...argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
383export function applyEachSeries(fns: Function[], ...argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
384export function queue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency?: number): QueueObject<T>;
385export function queue<T, R, E = Error>(worker: AsyncResultIterator<T, R, E>, concurrency?: number): QueueObject<T>;
386export function priorityQueue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency?: number): AsyncPriorityQueue<T>;
387export function cargo<T, E = Error>(worker: AsyncWorker<T[], E>, payload?: number): QueueObject<T>;
388export function cargoQueue<T, E = Error>(
389 worker: AsyncWorker<T[], E>,
390 concurrency?: number,
391 payload?: number,
392): QueueObject<T>;
393export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, concurrency?: number): Promise<R>;
394export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, concurrency: number, callback: AsyncResultCallback<R, E>): void;
395export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, callback: AsyncResultCallback<R, E>): void;
396export function autoInject<E = Error>(tasks: any, callback?: AsyncResultCallback<any, E>): void;
397
398export interface RetryOptions<E> {
399 times?: number | undefined;
400 interval?: number | ((retryCount: number) => number) | undefined;
401 errorFilter?: ((error: E) => boolean) | undefined;
402}
403export function retry<T, E = Error>(
404 task: (() => Promise<T>) | ((callback: AsyncResultCallback<T, E>) => void),
405): Promise<T>;
406export function retry<T, E = Error>(
407 opts: number | RetryOptions<E>,
408 task: (() => Promise<T>) | ((callback: AsyncResultCallback<T, E>) => void),
409): Promise<T>;
410export function retry<T, E = Error>(
411 task: (() => Promise<T>) | ((callback: AsyncResultCallback<T, E>) => void),
412 callback: AsyncResultCallback<T, E>,
413): void;
414export function retry<T, E = Error>(
415 opts: number | RetryOptions<E>,
416 task: (() => Promise<T>) | ((callback: AsyncResultCallback<T, E>) => void),
417 callback: AsyncResultCallback<T, E>,
418): void;
419
420export function retryable<T, E = Error>(task: AsyncFunction<T, E>): AsyncFunction<T, E>;
421export function retryable<T, E = Error>(
422 opts: number | (RetryOptions<E> & { arity?: number | undefined }),
423 task: AsyncFunction<T, E>,
424): AsyncFunction<T, E>;
425export function apply<E = Error>(fn: Function, ...args: any[]): AsyncFunction<any, E>;
426export function nextTick(callback: Function, ...args: any[]): void;
427export const setImmediate: typeof nextTick;
428
429export function reflect<T, E = Error>(fn: AsyncFunction<T, E>): (callback: (err: null, result: {error?: E | undefined, value?: T | undefined}) => void) => void;
430export function reflectAll<T, E = Error>(tasks: Array<AsyncFunction<T, E>>): Array<(callback: (err: null, result: {error?: E | undefined, value?: T | undefined}) => void) => void>;
431
432export function timeout<T, E = Error>(fn: AsyncFunction<T, E>, milliseconds: number, info?: any): AsyncFunction<T, E>;
433export function timeout<T, R, E = Error>(fn: AsyncResultIterator<T, R, E>, milliseconds: number, info?: any): AsyncResultIterator<T, R, E>;
434
435export function times<T, E = Error>(n: number, iterator: (AsyncResultIterator<number, T, E> | AsyncResultIteratorPromise<number, T>), callback: AsyncResultArrayCallback<T, E>): void;
436export function times<T, E = Error>(n: number, iterator: (AsyncResultIterator<number, T, E> | AsyncResultIteratorPromise<number, T>)): Promise<T>;
437
438export const timesSeries: typeof times;
439export function timesLimit<T, E = Error>(
440 n: number,
441 limit: number,
442 iterator: (AsyncResultIterator<number, T, E> | AsyncResultIteratorPromise<number, T>),
443 callback: AsyncResultArrayCallback<T, E>
444 ): void;
445export function timesLimit<T, E = Error>(
446 n: number,
447 limit: number,
448 iterator: (AsyncResultIterator<number, T, E> | AsyncResultIteratorPromise<number, T>)
449 ): Promise<T>;
450
451export function transform<T, R, E = Error>(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
452export function transform<T, R, E = Error>(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
453
454export function transform<T, R, E = Error>(
455 arr: {[key: string]: T},
456 iteratee: (acc: {[key: string]: R}, item: T, key: string, callback: (error?: E) => void) => void,
457 callback?: AsyncResultObjectCallback<T, E>
458 ): void;
459
460export function transform<T, R, E = Error>(
461 arr: {[key: string]: T},
462 acc: {[key: string]: R},
463 iteratee: (acc: {[key: string]: R}, item: T, key: string, callback: (error?: E) => void) => void,
464 callback?: AsyncResultObjectCallback<T, E>
465 ): void;
466
467export function race<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback: AsyncResultCallback<T, E>): void;
468
469// Utils
470export function memoize(fn: Function, hasher?: Function): Function;
471export function unmemoize(fn: Function): Function;
472export function ensureAsync(fn: (... argsAndCallback: any[]) => void): Function;
473export function constant(...values: any[]): AsyncFunction<any>;
474export function asyncify(fn: Function): (...args: any[]) => any;
475export function wrapSync(fn: Function): Function;
476export function log(fn: Function, ...args: any[]): void;
477export function dir(fn: Function, ...args: any[]): void;