https://github.com/seangenabe/async-iterable-map
https://github.com/seangenabe/async-iterable-map
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/seangenabe/async-iterable-map
- Owner: seangenabe
- License: mit
- Created: 2019-07-31T14:11:33.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-31T14:18:56.000Z (about 6 years ago)
- Last Synced: 2025-01-31T08:16:18.489Z (8 months ago)
- Language: TypeScript
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# async-iterable-map
Transforms items of an async iterable concurrently
[](https://www.npmjs.com/package/async-iterable-map)

[](https://david-dm.org/seangenabe/async-iterable-map)
[](https://david-dm.org/seangenabe/async-iterable-map#info=devDependencies)Like `p-map` but for `AsyncIterable`s.
If you like this package, be sure to star its repo, and please consider [donating](https://seangenabe.netlify.com/donate).
## Usage
```typescript
import { map } from "async-iterable-map"
```### map(source, transform, options = {})
Generic type parameters:
* `T = unknown` - type of input elements
* `U = unknown` - type of output elementsParameters:
* `source: AsyncIterable | Iterable` - the iterable to transform
* `transform: (element: T) => Promise | U` - the transform / mapping function from the input to the output
* `options.concurrency: number` - how many elements to transform concurrently. Must be a positive integer or `Infinity`. Default: `Infinity`Returns:
* `AsyncIterableIterator & PromiseLike`
* Use the `AsyncIterableIterator` interface to iterate through the remaining output elements one by one.
* Use the `PromiseLike` interface to get all of the remaining output elements.Both interfaces return the output elements in order.
Transforms items of an async iterable concurrently.