Skip to content

Instantly share code, notes, and snippets.

@eschwartz
Created July 10, 2017 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eschwartz/70a15f12e6ef90f377d5d51fba9c86d8 to your computer and use it in GitHub Desktop.
Save eschwartz/70a15f12e6ef90f377d5d51fba9c86d8 to your computer and use it in GitHub Desktop.
Async map
import * as _ from 'lodash';
async function mapAsync<TVal, TRes>(items:TVal[], iter:(val:TVal, i:(number | string)) => Promise<TRes>):Promise<TRes[]> {
return Promise.all(_.map(items, iter));
}
export default mapAsync;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment