npm package: @promises/for-each-right-series
Description: For Each Right Series is package from Promises library
Author: Yisrael Eliev
Latest version: 0.5.0



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

**For Each Right Series is package from Promises library**

## Use

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

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


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

 console.log('before');

 forEachRightSeries(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 5
 // => end 5
 // => start 1
 // => end 1
 // => start 7
 // => end 7
 // => start 3
 // => end 3
 // => complete
```


### Functional programming

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

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


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

 console.log('before');

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

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

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

 console.log('after');

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


### Wrapper

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

**Browser**
```html
<script src="https://unpkg.com/@promises/core/bundle.umd.min.js"></script>
<script src="https://unpkg.com/@promises/for-each-right-series/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(array);

 console.log('before');
 promises.forEachRightSeries((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 5
 // => end 5
 // => start 1
 // => end 1
 // => start 7
 // => end 7
 // => start 3
 // => end 3
 // => 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).