Add types for map functions with promise return (#38294)

When no callback is passed, the function should return a promise (since version 3.0.0)
https://github.com/caolan/async/blob/master/CHANGELOG.md#v300
This commit is contained in:
Bert Verhelst 2019-09-26 01:07:01 +02:00 committed by Ben Lichtman
parent 3889492dec
commit 04d87f9e90

View File

@ -126,9 +126,11 @@ export function forEachOfLimit<T, E = Error>(obj: IterableCollection<T>, limit:
export const eachOf: typeof forEachOf;
export const eachOfSeries: typeof forEachOf;
export const eachOfLimit: typeof forEachOfLimit;
export function map<T, R, E = Error>(arr: T[] | IterableIterator<T> | Dictionary<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function map<T, R, E = Error>(arr: T[] | IterableIterator<T> | Dictionary<T>, iterator: AsyncResultIterator<T, R, E>, callback: AsyncResultArrayCallback<R, E>): void;
export function map<T, R, E = Error>(arr: T[] | IterableIterator<T> | Dictionary<T>, iterator: AsyncResultIterator<T, R, E>): Promise<R>;
export const mapSeries: typeof map;
export function mapLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function mapLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R, E>, callback: AsyncResultArrayCallback<R, E>): void;
export function mapLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R, E>): Promise<R>;
export function mapValuesLimit<T, R, E = Error>(
obj: Dictionary<T>,
@ -136,8 +138,14 @@ export function mapValuesLimit<T, R, E = Error>(
iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void,
callback: AsyncResultObjectCallback<R, E>
): void;
export function mapValuesLimit<T, R, E = Error>(
obj: Dictionary<T>,
limit: number,
iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void
): Promise<R>;
export function mapValues<T, R, E = Error>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
export function mapValues<T, R, E = Error>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void): Promise<R>;
export const mapValuesSeries: typeof mapValues;
export function filter<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
export const filterSeries: typeof filter;