Skip to content

Commit

Permalink
Merge pull request coinbase#210 from blair/promise-each-series-templa…
Browse files Browse the repository at this point in the history
…te-parameter-for-return-type

eachSeries: be more specific on the return type.
  • Loading branch information
fb55 authored Apr 10, 2018
2 parents 8ca3df9 + 39cac81 commit 5987fa9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/promises.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export function delay(time: number): Promise<void> {
/**
* Apply each argument in arr to iteratorFn, waiting for the promise to resolve before continuing
*/
export function eachSeries<T>(arr: T[], iteratorFn: (arg: T) => Promise<any>) {
export function eachSeries<T, U>(arr: T[], iteratorFn: (arg: T) => Promise<U>): Promise<null | U> {
return arr.reduce((prev, item) => {
return prev.then(() => {
return iteratorFn(item);
});
}, Promise.resolve());
}, Promise.resolve(null));
}

/**
Expand Down

0 comments on commit 5987fa9

Please sign in to comment.