Standard Array.map logic for the iterable, extended for supporting iteration state.
When the callback is asynchronous, the operator does not resolve the value, to give you the flexibility of resolving it in a variety of ways:
Promise.all
Promise.race
import {pipeAsync, map, wait} from 'iter-ops';const i = pipeAsync( [1, 2, 3], map(async a => { const res1 = await firstAsyncRequest(a); const res2 = await secondAsyncRequest(a); return {res1, res2}; }), wait() // resolve sequentially);for await (const a of i) { console.log(a); // prints data from {res1, res2}} Copy
import {pipeAsync, map, wait} from 'iter-ops';const i = pipeAsync( [1, 2, 3], map(async a => { const res1 = await firstAsyncRequest(a); const res2 = await secondAsyncRequest(a); return {res1, res2}; }), wait() // resolve sequentially);for await (const a of i) { console.log(a); // prints data from {res1, res2}}
Standard Array.map logic for the iterable, extended for supporting iteration state.
When the callback is asynchronous, the operator does not resolve the value, to give you the flexibility of resolving it in a variety of ways:
Promise.all
, for a grouped resolutionPromise.race
, for a grouped race-resolution