https://github.com/parro-it/ai-map
Map over async iterables
https://github.com/parro-it/ai-map
Last synced: about 1 year ago
JSON representation
Map over async iterables
- Host: GitHub
- URL: https://github.com/parro-it/ai-map
- Owner: parro-it
- License: mit
- Created: 2017-11-20T22:21:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-29T18:31:29.000Z (over 8 years ago)
- Last Synced: 2024-10-05T11:36:00.740Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 294 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# ai-map
[](http://travis-ci.org/parro-it/ai-map)
[](https://npmjs.org/package/ai-map)
> Map over async iterables
The map() function creates a new async iterable with the results of calling a
provided function on every element in the async iterable.
> **_This module is part of
> [Async iterable fun](https://github.com/parro-it/ai-fun), a complete toolset
> of modules to work with async iterables._**
## Usage
description of the example
```js
import aiMap from 'ai-map';
for (const item of {aiMap}()) {
yield item;
};
```
This will output
```
```
## API
### index
Creates a new async iterable with the results of calling a
provided function on every element in the async iterable.
**Parameters**
- `data` **AsyncIterable** The async iterable to map over
- `transform` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function to apply to each element in the async iterable, taking 3 arguments:
. ```
__currentValue__ - The current element being processed in the async iterable.
__currentIndex__ - The index of the current element being processed in the async
iterable. Starts at index 0
__data__ - The async iterable map was called upon.
```
Returns **AyncIterable** An iterable that iterates over the `transform` calls results.
### with
Higher order function that partially apply `transform` to the
map function.
**Parameters**
- `transform` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** The transform argument to partially apply to map
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** A `map` unary function that take a data argument
and return a new async iterable.
## Install
With [npm](https://npmjs.org/) installed, run
```bash
npm install --save ai-map
```
## See Also
- [`parro-it/ai-fun`](https://github.com/parro-it/ai-fun)
- [`noffle/common-readme`](https://github.com/noffle/common-readme)
## License
MIT Licensed © 2017 Andrea Parodi