title: How to break out of async.js map's iterator loop when a condition is met
body: <p>Here <code>date</code> is an array. When <code>if</code> condition satisfies it has to <code>break</code> out of the iterator. But because of iterator it continues looping. Once again it executes <code>if</code> condition and throws the error "can't set header after they are sent". I have to break out of iterator once it executes <code>if</code> condition.</p>
  
  <pre><code>validatemultiday: function(req, callback) {
    async.map(edate, function iterator(date, mapCb) {
      var rangedate = moment(date).format("YYYY-MM-DD");
      if (rangedate == studentfromdate || rangedate == studenttodate) {
        sails.log.info("does1");
        callback(null, 1);
      } else {
        sails.log.info("do2");
        mapCb(null, 2);
      }
    }, callback);
  }
  </code></pre>