Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Serial & Parallel Iteration
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
.gitignore
README.md
index.js
package.json
test.js

README.md

Serial & Parallel Iteration

Install

npm install iter

Usage

iter(20, function(next, i){ /* 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(next, i){
    console.log('i: %d', i);
    next(); // to pass an error: next(new Error('failed!'))
  });

Parallel

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

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

Will output:

4
3
2
1
0
Something went wrong with that request. Please try again.