Run through a for loop concurrently with Promises.
// serial
const users = [];
for(let i = 0; i < 10; i++) {
users[i] = await getUser(i);
}
// concurrent
const users = await pForMap(
0,
i => i < 10,
i => ++i,
async i => users[i] = await getUser(i)
);
Returns a Promise
that resolves to the resultant array of values.
Type: any
Example: 0
Initial iterator value; what i
is set to initially.
Type: Function
Example: i => i < 10
Expected to return a Boolean
.
Type: Function
Example: i => ++i
Returns the next i
value.
Type: Function
Example: i => console.log(i)
Expected to return a Promise
.