@promises/times-parallel
v0.5.0
Published
Times Parallel is package from Promises library
Downloads
32
Maintainers
Readme
@promises/times-parallel
Times Parallel is package from Promises library
Use
Module
$ npm install --save @promises/times-parallel
import {
default as timesParallel
} from '@promises/times-parallel';
Browser
<script src="https://unpkg.com/@promises/times-parallel/bundle.umd.min.js"></script>
let {
timesParallel
} = P;
Examples
let times: number = 3;
timesParallel(times, (time: number) => {
let ms = (times-time) * 3;
return timeout((resolve) => {
console.log(time);
resolve(ms);
}, ms);
}).then((result: number[]) => {
console.log(result);
});
// => 2
// => 1
// => 0
// => [9, 6, 3]
Functional programming
Module
$ npm install --save @promises/times-parallel
import {
__,
default as timesParallel
} from '@promises/times-parallel/fp';
Browser
<script src="https://unpkg.com/@promises/times-parallel/fp/bundle.umd.min.js"></script>
let {
__,
timesParallel
} = PF;
Examples
let times: number = 3;
timesParallel((time: number) => {
let ms = (times-time) * 3;
return timeout((resolve) => {
console.log(time);
resolve(ms);
}, ms);
})(1)(times).then((result: number[]) => {
console.log(result);
});
// => 0
// => 1
// => 2
// => [9, 6, 3]
Wrapper
Module
$ npm install --save @promises/times-parallel
import Promises from '@promises/core';
import '@promises/times-parallel/add';
Or
import Promises from '@promises/times-parallel/add';
Browser
<script src="https://unpkg.com/@promises/core/bundle.umd.min.js"></script>
<script src="https://unpkg.com/@promises/times-parallel/add/bundle.umd.min.js"></script>
let {
Promises
} = P;
Examples
let times: number = 3;
Promises.timesParallel(times, (time: number) => {
let ms = (times-time) * 3;
return timeout((resolve) => {
console.log(time);
resolve(ms);
}, ms);
}).then((result: number[]) => {
console.log(result);
});
// => 2
// => 1
// => 0
// => [9, 6, 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.