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

0.5.0 • Public • Published

@promises/map-parallel

Source Code Version MIT License Bundle Size

Map Parallel is package from Promises library

Use

Module

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

Browser

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

Examples

 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

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

Browser

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

Examples

 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

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

Or

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

Browser

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

Package Sidebar

Install

npm i @promises/map-parallel

Weekly Downloads

4

Version

0.5.0

License

MIT

Unpacked Size

137 kB

Total Files

39

Last publish

Collaborators

  • yisraelx