<commit_before>function each (array, iterator, callback) {
  var i = -1
  var len = array.length
  var results = []

  function done (err, res) {
    results[i] = res

    if (err) {
      callback(err, results)
      callback = noop
      return
    }

    if (i === len - 1) return callback(err, results)
  }

  function noop () {}

  while (++i < len) {
    iterator(array[i], i, done)
  }
}

module.exports = each<commit_msg>fix index in done function for "this" confusion<commit_after>function each (array, iterator, callback) {
  var i = -1
  var len = array.length
  var results = []

  function done (i, err, res) {

    results[i] = res

    if (err) {
      callback(err, results)
      callback = noop
      return
    }

    if (i === len -1)
      return callback(err, results)

  }

  function noop () {}

  while (++i < len) {
    iterator(array[i], i, done.bind(null, i))
  }
}

module.exports = each
{'fraction_non_alphanumeric': 0.13864628820960698, 'fraction_numerical': 0.004366812227074236, 'mean_word_length': 2.3962962962962964, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2849570', 'n_tokens_mistral': 323, 'n_tokens_neox': 309, 'n_words': 94}