A function to iterate over items with asynchronous calls synchronously.


A super simple function to loop over items accepting a callback, so asynchronous callbacks will be executed in order.

Install with npm:

npm install spurt

Example usage:

var spurt = require('spurt');
var items = [1, 2, 3];
spurt(items, function(itemnext) {
    // do something async, such as insert into db: 
    db.insert(item, function(errres) { // each entry 
        if (!err) {
    }, function() { // all rows done 
        console.log("Inserted all the rows");

Pull requests welcome

  • maybe more flexible error handling
  • optional success callback

MIT license