<commit_before>var Height = function(opts) {
  'use strict';

  opts = opts || {};

  var checkOpts = function() {
    if (typeof opts.columns !== 'number') {
      throw new TypeError('opts.columns must be a number.')
    }

    if (typeof opts.listElem !== 'string') {
      throw new TypeError('opts.listElem must be a string.')
    }
  }

  var init = function() {
    var elements = document.querySelectorAll(opts.listElem)
    var maxHeight = 0;
    var rowElements = [];

    elements = Array.prototype.slice.call(elements)

    if (elements.length > 0) {
      for (var index = 0; index < elements.length; index++) {
        var toPosition = (index + opts.columns - 1);

        toPosition = (toPosition > elements.length)
          ? (elements.length - 1)
          : toPosition;

        rowElements = elements.slice(index, (toPosition + 1));

        maxHeight = getMaxHeight(rowElements);
        setElementsHeight(rowElements, maxHeight);

        index = toPosition;
      }
    }
  }

  var getMaxHeight = function(elements) {
    var style, heights = [];

    heights = elements.map(function(item) {
      style = window.getComputedStyle(item);

      if (heights.indexOf(parseInt(style.height)) !== 0)
        return parseInt(style.height);
    });

    return Math.max.apply(Math, heights);
  }

  var setElementsHeight = function(elements, maxHeight) {
    for (var j = 0; j < elements.length; j++) {
      elements[j].style.height = maxHeight + 'px';
    }
  }

  checkOpts();
  init();
};<commit_msg>refactor(functions): using named functions instead of variables<commit_after>function Height(opts) {
  'use strict';

  opts = opts || {};

  function checkOpts() {
    if (typeof opts.columns !== 'number' || typeof opts.listElem !== 'string') {
      throw new TypeError('`opts.columns` must be a `number` AND `opts.listElem` must be a `string`')
    }
  }

  function init() {
    var elements = document.querySelectorAll(opts.listElem)
    var maxHeight = 0;
    var rowElements = [];

    elements = Array.prototype.slice.call(elements)

    if (elements.length > 0) {
      for (var index = 0; index < elements.length; index++) {
        var toPosition = (index + opts.columns - 1);

        toPosition = (toPosition > elements.length)
          ? (elements.length - 1)
          : toPosition;

        rowElements = elements.slice(index, (toPosition + 1));

        maxHeight = getMaxHeight(rowElements);
        setElementsHeight(rowElements, maxHeight);

        index = toPosition;
      }
    }
  }

  function getMaxHeight(elements) {
    var style, heights = [];

    heights = elements.map(function(item) {
      style = window.getComputedStyle(item);

      if (heights.indexOf(parseInt(style.height)) !== 0)
        return parseInt(style.height);
    });

    return Math.max.apply(Math, heights);
  }

  function setElementsHeight(elements, maxHeight) {
    for (var j = 0; j < elements.length; j++) {
      elements[j].style.height = maxHeight + 'px';
    }
  }

  checkOpts();
  init();
}
{'fraction_non_alphanumeric': 0.13709943838784275, 'fraction_numerical': 0.005285761480013214, 'mean_word_length': 2.6971916971916974, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3965208', 'n_tokens_mistral': 942, 'n_tokens_neox': 898, 'n_words': 219}