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