@promises/map-series
TypeScript icon, indicating that this package has built-in type declarations

0.5.0 • Public • Published

@promises/map-series

Source Code Version MIT License Bundle Size

Map Series is package from Promises library

Use

Module

$ npm install --save @promises/map-series
import {
 default as mapSeries
} from '@promises/map-series';

Browser

<script src="https://unpkg.com/@promises/map-series/bundle.umd.min.js"></script>
let {
 mapSeries
} = P;

Examples

 let mapper = (time: number) => {
     return timeout((resolve) => {
         resolve(index);
     }, time);
 };

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

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

Functional programming

Module

$ npm install --save @promises/map-series
import {
 __,
 default as mapSeries
} from '@promises/map-series/fp';

Browser

<script src="https://unpkg.com/@promises/map-series/fp/bundle.umd.min.js"></script>
let {
 __,
 mapSeries
} = PF;

Examples

 let mapper = (time: number) => {
     return timeout((resolve) => {
         resolve(index);
     }, time);
 };

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

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

Wrapper

Module

$ npm install --save @promises/map-series
import Promises from '@promises/core';
import '@promises/map-series/add';

Or

import Promises from '@promises/map-series/add';

Browser

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

Examples

 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<number[]> = Promises.resolve<number[]>(array);

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

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, Licensed under the MIT license.

Package Sidebar

Install

npm i @promises/map-series

Weekly Downloads

2

Version

0.5.0

License

MIT

Unpacked Size

124 kB

Total Files

39

Last publish

Collaborators

  • yisraelx