Q:

async.js how to repeat a series until an unexpected error occurs?

Is there a way to repeat a series of tasks until an unexpected error occurs in async.js?
Something like this
async.series([
    function(callback) {
        // do stuff
    },
    function(callback) {
        // do more stuff
    },
    function(callback) {
        // do even more stuff
    },
    function(callback) {
        // more more more
    }
], function(error, results) {

    if(error.message.search(/ESOCKETTIMEDOUT|ETIMEDOUT/) == -1) {
        // stop here
    } else {
        // repeat series
    }
});

A:

One possibility:
void function loop() {
  async.series([
      function(callback) {
          // do stuff
      },
      function(callback) {
          // do more stuff
      },
      function(callback) {
          // do even more stuff
      },
      function(callback) {
          // more more more
      }
  ], function(error, results) {
      if (error && error.message.search(/ESOCKETTIMEDOUT|ETIMEDOUT/) == -1) {
        // stop here
      } else {
        loop();
      }
  });
}();

