@promises/while-series
v0.5.0
Published
While Series is package from Promises library
Downloads
18
Maintainers
Readme
@promises/while-series
While Series is package from Promises library
Use
Module
$ npm install --save @promises/while-series
import {
default as whileSeries
} from '@promises/while-series';
Browser
<script src="https://unpkg.com/@promises/while-series/bundle.umd.min.js"></script>
let {
whileSeries
} = P;
Examples
let index: number = 0;
whileSeries(() => {
console.log(`test ${index}`);
return index++ < 3;
}, () => timeout((resolve) => {
console.log(`iteratee ${index}`);
resolve();
}, 4 - index)).then(() => {
console.log('completed');
});
// => 'test 0'
// => 'iteratee 1'
// => 'test 1'
// => 'iteratee 2'
// => 'test 2'
// => 'iteratee 3'
// => 'test 3'
// => 'completed'
Wrapper
Module
$ npm install --save @promises/while-series
import Promises from '@promises/core';
import '@promises/while-series/add';
Or
import Promises from '@promises/while-series/add';
Browser
<script src="https://unpkg.com/@promises/core/bundle.umd.min.js"></script>
<script src="https://unpkg.com/@promises/while-series/add/bundle.umd.min.js"></script>
let {
Promises
} = P;
Examples
let index: number = 0;
Promises.whileSeries(() => {
console.log(`test ${index}`);
return index++ < 3;
}, () => Promises.timeout((resolve) => {
console.log(`iteratee ${index}`);
resolve();
}, 4 - index)).then(() => {
console.log('completed');
});
// => 'test 0'
// => 'iteratee 1'
// => 'test 1'
// => 'iteratee 2'
// => 'test 2'
// => 'iteratee 3'
// => 'test 3'
// => 'completed'
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.