<commit_before>var utils, _;

_ = require('underscore');

utils = module.exports = {};

utils.isErrorStatus = function(statusCode, options) {
  options = options || {};
  _.defaults(options, {
    allow4xx: false
  });
  statusCode = +statusCode;
  if (options.allow4xx) {
    return statusCode >= 500 && statusCode < 600;
  } else {
    return statusCode >= 400 && statusCode < 600;
  }
};<commit_msg>adding walk util<commit_after>var utils, _, fs;

_ = require('underscore');
fs = require('fs');

utils = module.exports = {};

utils.isErrorStatus = function(statusCode, options) {
  options = options || {};
  _.defaults(options, {
    allow4xx: false
  });
  statusCode = +statusCode;
  if (options.allow4xx) {
    return statusCode >= 500 && statusCode < 600;
  } else {
    return statusCode >= 400 && statusCode < 600;
  }
};

utils.walk = function(dir, callback) {
  var results = [];

  fs.readdir(dir, function(err, list) {
    if (err) return callback(err);

    var pending = list.length;
    if (!pending) return callback(null, results);

    list.forEach(function(file) {
      file = dir + '/' + file;
      fs.stat(file, function(err, stat) {
        if (stat && stat.isDirectory()) {
          walk(file, function(err, res) {
            results = results.concat(res);
            if (!--pending) { callback(null, results); }
          });
        } else {
          results.push(file);
          if (!--pending) { callback(null, results); }
        }
      });
    });
  });
};
{'fraction_non_alphanumeric': 0.16198125836680052, 'fraction_numerical': 0.018741633199464525, 'mean_word_length': 2.7468671679197993, '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': '755901', 'n_tokens_mistral': 496, 'n_tokens_neox': 468, 'n_words': 106}