An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# ai-map

[![Travis Build Status](https://img.shields.io/travis/parro-it/ai-map/master.svg)](http://travis-ci.org/parro-it/ai-map)
[![NPM downloads](https://img.shields.io/npm/dt/ai-map.svg)](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