Skip to content

Commit

Permalink
fix(typescript): Allow map() to return a different type than it accepts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Walton committed Nov 26, 2018
1 parent e9a39aa commit 0f4d525
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Expand Up @@ -33,13 +33,13 @@ export function series<t>(tasks: PromiseGeneratingFunction<t>[]): Promise<t[]>;
*/
export function parallel<t>(tasks: PromiseGeneratingFunction<t>[], limit?: number): Promise<t[]>;

type MapIterator<t, u> = (item: t, index: number) => Promise<u>;

type MapIterator<t> = (item: t, index: number) => Promise<t>;
/**
* Given an array `arr` of items, calls `iter(item, index)` for every item in `arr`. `iter()` should return a
* Promise. Up to `limit` items will be called in parallel (defaults to 1.)
*/
export function map<t>(arr: t[], iter: MapIterator<t>, limit?: number): Promise<t[]>;
export function map<t, u>(arr: t[], iter: MapIterator<t, u>, limit?: number): Promise<u[]>;

/**
* Add a timeout to an existing Promise.
Expand Down

0 comments on commit 0f4d525

Please sign in to comment.