Skip to content

Instantly share code, notes, and snippets.

View pisarivskyi's full-sized avatar
🤔
Hmm...

Anatolii Pisarivskyi pisarivskyi

🤔
Hmm...
View GitHub Profile
@pisarivskyi
pisarivskyi / loop.js
Created June 24, 2016 08:10
async loop with concurency
function asyncLoop(_max, _concurency, iterator, callback) {
let concurency = _concurency, max = _max, index = 0, running = 0;
let o = {
next: function () {
while(running < concurency && index < max) {
iterator(index++, function () {
if (index === max && running == 1) {
return callback();