lib/recurrify.js
/**
   * Calculates the next invalid date for a particular recurrences starting from
   * the specified valid start date.
   *
   * @param {String} dir: The direction to use, either 'next' or 'prev'
   * @param {Array} schedArr: The set of compiled recurrences to use
   * @param {Array} startsArr: The set of cached start dates for the recurrences
   * @param {Date} startDate: The valid date for which the end date will be found
   * @param {Date} maxEndDate: The latested possible end date or null for none
   */
Calculates the next invalid date for a particular recurrences starting from
the specified valid start date.


Calculates the next invalid date for a particular recurrences starting from the specified valid start date .
function calcEnd (dir, schedArr, startsArr, startDate, maxEndDate) {
    var compare = compareFn(dir); var result
    for (var i = 0, len = schedArr.length; i < len; i++) {
      var start = startsArr[i]
      if (start && start.getTime() === startDate.getTime()) {
        var end = schedArr[i].end(dir, start)
        if (maxEndDate && (!end || compare(end, maxEndDate))) {
          return maxEndDate
        }
        if (!result || compare(end, result)) {
          result = end
        }
      }
    }
    return result
  }
function calcEnd ( dir , schedArr , startsArr , startDate , maxEndDate ) { var compare = compareFn ( dir ) ; var result for ( var i = 0 , len = schedArr . length ; i < len ; i ++ ) { var start = startsArr [ i ] if ( start && start . getTime ( ) === startDate . getTime ( ) ) { var end = schedArr [ i ] . end ( dir , start ) if ( maxEndDate && ( ! end || compare ( end , maxEndDate ) ) ) { return maxEndDate } if ( ! result || compare ( end , result ) ) { result = end } } } return result }
Calculates the next invalid date for a particular recurrences starting from
 the specified valid start date.
Calculates the next invalid date for a particular recurrences starting from the specified valid start date .
// if the end date is past the maxEndDate, just return the maxEndDate // otherwise, return the maximum end date that was calculated