npm package: @promises/map-parallel
Description: Map Parallel is package from Promises library
Author: Yisrael Eliev
Latest version: 0.5.0



# @promises/map-parallel
[![Source Code](https://img.shields.io/badge/%3C%2F%3E-source_code-blue.svg)](https://github.com/yisraelx/promises/blob/master/modules/map-parallel)
[![Version](https://img.shields.io/npm/v/@promises/map-parallel.svg)](https://www.npmjs.com/package/@promises/map-parallel)
[![MIT License](https://img.shields.io/npm/l/@promises/map-parallel.svg)](https://github.com/yisraelx/promises/blob/master/LICENSE)
[![Bundle Size](https://img.shields.io/bundlephobia/min/@promises/map-parallel.svg)](https://bundlephobia.com/result?p=@promises/map-parallel)

**Map Parallel is package from Promises library**

## Use

**Module**
```sh
$ npm install --save @promises/map-parallel
```
```typescript
import {
 default as mapParallel
} from '@promises/map-parallel';
```

**Browser**
```html
<script src="https://unpkg.com/@promises/map-parallel/bundle.umd.min.js"></script>
```
```typescript
let {
 mapParallel
} = P;
```


**Examples**
```typescript
 let mapper = (time: number) => {
     return timeout((resolve) => {
         resolve(count++);
     }, time);
 };

 let count: number = 0;
 let array: number[] = [7, 1, 6, 9, 3];

 mapParallel(array, mapper).then((result: number[]) => {
     console.log(result); // result => [1, 4, 2, 0, 3]
 });
```


### Functional programming

**Module**
```sh
$ npm install --save @promises/map-parallel
```
```typescript
import {
 __,
 default as mapParallel
} from '@promises/map-parallel/fp';
```

**Browser**
```html
<script src="https://unpkg.com/@promises/map-parallel/fp/bundle.umd.min.js"></script>
```
```typescript
let {
 __,
 mapParallel
} = PF;
```


**Examples**
```typescript
 let mapper = (time: number) => {
     return timeout((resolve) => {
         resolve(count++);
     }, time);
 };

 let count: number = 0;
 let array: number[] = [7, 1, 6, 9, 3];

 mapParallel(mapper)(1)(array).then((result: number[]) => {
     console.log(result); // result => [0, 1, 2, 3, 4]
 });
```


### Wrapper

**Module**
```sh
$ npm install --save @promises/map-parallel
```
```typescript
import Promises from '@promises/core';
import '@promises/map-parallel/add';
```
*Or*
```typescript
import Promises from '@promises/map-parallel/add';
```

**Browser**
```html
<script src="https://unpkg.com/@promises/core/bundle.umd.min.js"></script>
<script src="https://unpkg.com/@promises/map-parallel/add/bundle.umd.min.js"></script>
```
```typescript
let {
 Promises
} = P;
```


**Examples**
```typescript
 let mapper = (time: number) => {
     return Promises.timeout((resolve) => {
         resolve(count++);
     }, time);
 };

 let count: number = 0;
 let array: number[] = [7, 1, 6, 9, 3];
 let promises = Promises.resolve(array);

 promises.mapParallel(mapper).then((result: number[]) => {
     console.log(result); // result => [1, 4, 2, 0, 3]
 });
```


## Compatibility
These modules are written in typescript and available in ES5 and ES6 standard, the requirements are a global __Promise__ (native or polyfill).

## License
Copyright © 2017 [Yisrael Eliav](https://github.com/yisraelx),
Licensed under the [MIT license](https://github.com/yisraelx/promises/blob/master/LICENSE).