Loopasync is necessary for async iteration over any collection. Supported in Node
as well as in browsers.
npm install loopasync --save
Node.js
// ES6 modules
import loopasync from 'loopasync';
// CommonJS modules
const loopasync = require('loopasync');
/*
@param collection - collection for iteration
@param iteratee - iterates over elements of collection and invokes iteratee for each element and index as a second param
@param parts - number of parts collection will be split in (default will be calculated for you)
*/
loopasync(collection, iteratee[, parts]);
const loopasync = require('loopasync');
function testLoopasync() {
console.log('start');
const collection = [1, 2, 3, 4];
const iteratee = console.log;
const parts = 2;
loopasync(collection, iteratee, parts);
console.log('finish');
}
testLoopasync();
/*
// will print:
start
finish
1
2
3
4
*/
Feel free to contribute