asyncMap
asyncMap<
I,O>(xs,mapper):AsyncIterable<O>
Map over an AsyncIterable, and give the results back as an AsyncIterable generator.
Example
await asyncCollect(asyncMap([1, 2, 3], (x) => x + 1))// => [2, 3, 4]
const asyncFn = <T>(x: T) => Promise.resolve(x)async function* foobar() { yield await asyncFn('foo') yield await asyncFn('Bar')}await asyncCollect(asyncMap(foobar(), asyncFn))// => ["foo", "bar"]Alternatives
Type Parameters
• I
• O
The mapped output type.
Parameters
xs
The values to map over.
AsyncIterable<I> | Iterable<I>
mapper
(x, index) => O | Promise<O>
Returns
AsyncIterable<O>
An async map generator.