<commit_before>var DateRange = (function() {
  return function(clock) {
    var startDate, endDate, period = "WEEK";

    updateRange(clock.currentDate());

    return {
      startDate: function() {
        return startDate;
      },
      endDate: function() {
        return endDate;
      },
      useMonth: function() {
        period = "MONTH";
        updateRange(clock.currentDate());
      },
      useYear: function() {
        period = "YEAR";
        updateRange(clock.currentDate());
      }
    };

    function monday(date) {
      return moment(date).day("Monday");
    }

    function sunday(date) {
      return monday(date).add(6, "days");
    }

    function firstDayOfMonth(date) {
      return moment(date).date(1);
    }

    function lastDayOfMonth(date) {
      var daysInMonth = moment(date).daysInMonth();
      return firstDayOfMonth(date).add(daysInMonth - 1, "days");
    }

    function firstDayOfYear(date) {
      return moment(date).dayOfYear(1);
    }

    function lastDayOfYear(date) {
      return firstDayOfYear(date).add(1,"years").add(-1, "days");
    }

    function updateRange(currentDate) {
      if(period === "WEEK") {
        startDate = monday(currentDate).toDate();
        endDate = sunday(currentDate).toDate();
      } else if(period === "MONTH") {
        startDate = firstDayOfMonth(currentDate).toDate();
        endDate = lastDayOfMonth(currentDate).toDate();
      } else {
        startDate = firstDayOfYear(currentDate).toDate();
        endDate = lastDayOfYear(currentDate).toDate();
      }
    }
  };
})();<commit_msg>Rearranged code to see most important private function before<commit_after>var DateRange = (function() {
  return function(clock) {
    var startDate, endDate, period = "WEEK";

    updateRange(clock.currentDate());

    return {
      startDate: function() {
        return startDate;
      },
      endDate: function() {
        return endDate;
      },
      useMonth: function() {
        period = "MONTH";
        updateRange(clock.currentDate());
      },
      useYear: function() {
        period = "YEAR";
        updateRange(clock.currentDate());
      }
    };

    function updateRange(currentDate) {
      if(period === "WEEK") {
        startDate = monday(currentDate).toDate();
        endDate = sunday(currentDate).toDate();
      } else if(period === "MONTH") {
        startDate = firstDayOfMonth(currentDate).toDate();
        endDate = lastDayOfMonth(currentDate).toDate();
      } else {
        startDate = firstDayOfYear(currentDate).toDate();
        endDate = lastDayOfYear(currentDate).toDate();
      }
    }

    function monday(date) {
      return moment(date).day("Monday");
    }

    function sunday(date) {
      return monday(date).add(6, "days");
    }

    function firstDayOfMonth(date) {
      return moment(date).date(1);
    }

    function lastDayOfMonth(date) {
      var daysInMonth = moment(date).daysInMonth();
      return firstDayOfMonth(date).add(daysInMonth - 1, "days");
    }

    function firstDayOfYear(date) {
      return moment(date).dayOfYear(1);
    }

    function lastDayOfYear(date) {
      return firstDayOfYear(date).add(1,"years").add(-1, "days");
    }
  };
})();
{'fraction_non_alphanumeric': 0.14330218068535824, 'fraction_numerical': 0.003738317757009346, 'mean_word_length': 2.595744680851064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '182833', 'n_tokens_mistral': 1006, 'n_tokens_neox': 970, 'n_words': 170}