async-iterable-map
v2.0.3
Published
Transforms items of an async iterable concurrently
Downloads
40
Maintainers
Readme
async-iterable-map
Transforms items of an async iterable concurrently
Like p-map
but for AsyncIterable
s.
If you like this package, be sure to star its repo, and please consider donating.
Usage
import { map } from "async-iterable-map"
map(source, transform, options = {})
Generic type parameters:
T = unknown
- type of input elementsU = unknown
- type of output elements
Parameters:
source: AsyncIterable<T> | Iterable<T>
- the iterable to transformtransform: (element: T) => Promise<U> | U
- the transform / mapping function from the input to the outputoptions.concurrency: number
- how many elements to transform concurrently. Must be a positive integer orInfinity
. Default:Infinity
Returns:
AsyncIterableIterator<U> & PromiseLike<U[]>
- Use the
AsyncIterableIterator<U>
interface to iterate through the remaining output elements one by one. - Use the
PromiseLike<U[]>
interface to get all of the remaining output elements.
- Use the
Both interfaces return the output elements in order.
Transforms items of an async iterable concurrently.