npm package: @promises/for-each-parallel
Description: For Each Parallel is package from Promises library
Author: Yisrael Eliev
Latest version: 0.5.0



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

**For Each Parallel is package from Promises library**

## Use

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

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


**Examples**
```typescript
 let array: number[] = [3, 7, 1, 5];

 console.log('before');

 forEachParallel(array, (value: number) => {
     console.log(`start: ${ value }`);

     return timeout((resolve) => {
         console.log(`end: ${ value }`);
         resolve();
     }, value);

 }).then(() => {
     console.log('complete');
 });

 console.log('after');

 // => before
 // => after
 // => start 3
 // => start 7
 // => start 1
 // => start 5
 // => end 1
 // => end 3
 // => end 5
 // => end 7
 // => complete
```


### Functional programming

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

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


**Examples**
```typescript
 let array: number[] = [3, 7, 1, 5];

 console.log('before');

 forEachParallel((value: number) => {
     console.log(`start: ${ value }`);

     return timeout((resolve) => {
         console.log(`end: ${ value }`);
         resolve();
     }, value);

 })(Infinity, array).then(() => {
     console.log('complete');
 });

 console.log('after');

 // => before
 // => after
 // => start 3
 // => start 7
 // => start 1
 // => start 5
 // => end 1
 // => end 3
 // => end 5
 // => end 7
 // => complete
```


### Wrapper

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

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


**Examples**
```typescript
 let array: number[] = [3, 7, 1, 5];
 let promises: Promises<number[]> = Promises.resolve<number[]>(array);

 console.log('before');
 promises.forEachParallel((value: number) => {
     console.log(`start: ${ value }`);
     return timeout((resolve) => {
         console.log(`end: ${ value }`);
         resolve();
     }, value);
 }).then(() => {
     console.log('complete');
 });
 console.log('after');

 // => before
 // => after
 // => start 3
 // => start 7
 // => start 1
 // => start 5
 // => end 1
 // => end 3
 // => end 5
 // => end 7
 // => complete
```


## 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).