<commit_before>/**
 * Invoke each handler in turn until the list is exhausted or the request has
 * been ended.
 */
function invokeHandlers(handlers, req, res, callback) {
  var nextHandler = handlers[0];
  var remaining = handlers.slice(1);

  var next = function(err) {
    if (err) {
      res['throw'](err);
      callback(err);
    } else if (res.ended) {
      // The request has finished; we're done.
      callback();
    } else {
      // Call the remaining handlers.
      invokeHandlers(remaining, req, res, callback);
    }
  };

  if (nextHandler) {
    try {
      nextHandler.call(res, req, next);
    } catch (err) {
      res['throw'](err);
      callback(err);
    }
  } else {
    callback();
  }
}

module.exports = invokeHandlers;<commit_msg>Don't create function unnecessarily<commit_after>/**
 * Invoke each handler in turn until the list is exhausted or the request has
 * been ended.
 */
function invokeHandlers(handlers, req, res, callback) {
  var nextHandler = handlers[0];

  if (nextHandler) {
    var remaining = handlers.slice(1);
    var next = function(err) {
      if (err) {
        res['throw'](err);
        callback(err);
      } else if (res.ended) {
        // The request has finished; we're done.
        callback();
      } else {
        // Call the remaining handlers.
        invokeHandlers(remaining, req, res, callback);
      }
    };

    try {
      nextHandler.call(res, req, next);
    } catch (err) {
      res['throw'](err);
      callback(err);
    }
  } else {
    callback();
  }
}

module.exports = invokeHandlers;
{'fraction_non_alphanumeric': 0.1340533672172808, 'fraction_numerical': 0.0025412960609911056, 'mean_word_length': 2.4539473684210527, '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': '3072839', 'n_tokens_mistral': 496, 'n_tokens_neox': 479, 'n_words': 138}