iter

Serial & Parallel Iteration

Serial & Parallel Iteration

npm install iter
iter(20, function(nexti){ /* or: iter(0, 20, .. */
  console.log('i: %d', i);
  next();
});

Callbacks;

iter(20)
  .error(function(error){ throw error; })
  .done(function(){ console.log('done'); })
  .run(function(nexti){
    console.log('i: %d', i);
    next(); // to pass an error: next(new Error('failed!')) 
  });

It's serial by default. Use parallel method to make it parallel.

iter.parallel(5, function (donei) {
  setTimeout(function () {
    console.log(i)
    done()
  }, 1000 - (* 200))
})

Will output:

4
3
2
1
0