\begin{quote}
Map over promises concurrently \end{quote}
Useful when you need to run promise-\/returning \& async functions multiple times with different inputs concurrently.\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8030}{}\doxysection{Install}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8030}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install p-\/map }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8031}{}\doxysection{Usage}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8031}

\begin{DoxyCode}{0}
\DoxyCodeLine{const pMap = require('p-\/map');}
\DoxyCodeLine{const got = require('got');}
\DoxyCodeLine{}
\DoxyCodeLine{const sites = [}
\DoxyCodeLine{    getWebsiteFromUsername('sindresorhus'), //=> Promise}
\DoxyCodeLine{    'ava.li',}
\DoxyCodeLine{    'todomvc.com',}
\DoxyCodeLine{    'github.com'}
\DoxyCodeLine{];}
\DoxyCodeLine{}
\DoxyCodeLine{(async () => \{}
\DoxyCodeLine{    const mapper = async site => \{}
\DoxyCodeLine{        const \{requestUrl\} = await got.head(site);}
\DoxyCodeLine{        return requestUrl;}
\DoxyCodeLine{    \};}
\DoxyCodeLine{}
\DoxyCodeLine{    const result = await pMap(sites, mapper, \{concurrency: 2\});}
\DoxyCodeLine{}
\DoxyCodeLine{    console.log(result);}
\DoxyCodeLine{    //=> ['http://sindresorhus.com/', 'http://ava.li/', 'http://todomvc.com/', 'http://github.com/']}
\DoxyCodeLine{\})(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8032}{}\doxysection{API}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8032}
\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8033}{}\doxysubsection{p\+Map(input, mapper, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8033}
Returns a {\ttfamily Promise} that is fulfilled when all promises in {\ttfamily input} and ones returned from {\ttfamily mapper} are fulfilled, or rejects if any of the promises reject. The fulfilled value is an {\ttfamily Array} of the fulfilled values returned from {\ttfamily mapper} in {\ttfamily input} order.\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8034}{}\doxysubsubsection{input}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8034}
Type\+: {\ttfamily Iterable$<$Promise$\vert$any$>$}

Iterated over concurrently in the {\ttfamily mapper} function.\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8035}{}\doxysubsubsection{mapper(element, index)}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8035}
Type\+: {\ttfamily Function}

Expected to return a {\ttfamily Promise} or value.\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8036}{}\doxysubsubsection{options}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8036}
Type\+: {\ttfamily Object}\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8037}{}\doxyparagraph{concurrency}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8037}
Type\+: {\ttfamily number}~\newline
 Default\+: {\ttfamily Infinity}~\newline
 Minimum\+: {\ttfamily 1}

Number of concurrently pending promises returned by {\ttfamily mapper}.\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8038}{}\doxysection{Related}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8038}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/p-all}{\texttt{ p-\/all}} -\/ Run promise-\/returning \& async functions concurrently with optional limited concurrency
\item \href{https://github.com/sindresorhus/p-filter}{\texttt{ p-\/filter}} -\/ Filter promises concurrently
\item \href{https://github.com/sindresorhus/p-times}{\texttt{ p-\/times}} -\/ Run promise-\/returning \& async functions a specific number of times concurrently
\item \href{https://github.com/sindresorhus/p-props}{\texttt{ p-\/props}} -\/ Like {\ttfamily Promise.\+all()} but for {\ttfamily Map} and {\ttfamily Object}
\item \href{https://github.com/sindresorhus/p-map-series}{\texttt{ p-\/map-\/series}} -\/ Map over promises serially
\item \href{https://github.com/sindresorhus/p-queue}{\texttt{ p-\/queue}} -\/ Promise queue with concurrency control
\item \href{https://github.com/sindresorhus/promise-fun}{\texttt{ More…}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8039}{}\doxysection{License}\label{md_sfcode_node_modules_del_node_modules_p_map_readme_autotoc_md8039}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 