<commit_before>var getDirname = require('path').dirname,
  Package = require('./package'),
  util = require('./util'),
  resolveFilename = util.resolveFilename,
  resolveFilenames = util.resolveFilenames,
  rethrow = util.rethrow;

module.exports = Resolver;

/**
 * Responsibility:
 *   To identify the dependencies of
 *   a module and return them, as well
 *   as the module in a list,
 *   starting with the oldest parent,
 *   and ending with the dependency
 *   itself.
 *
 * Reason:
 *   This eliminates need to locate
 *   dependencies at runtime; thereby
 *   improving performance.
 */

function Resolver(rootPath) {
  this._basedir = rootPath;
}

/**
 * Recursively resolve the package by its path,
 * along with all of its $inject(ed) dependencies.
 *
 * @param {String} path
 * @returns {Array} of packages, starting at the leafs
 */

Resolver.prototype.resolve = function resolve(path) {
  var filename, dirname, factory, package, deps;

  try {
    filename = resolveFilename(path, arguments[1] || this._basedir);
    dirname = getDirname(filename);
    factory = require(filename);
  } catch (e) {
    rethrow(e, 'Cannot resolve "%s"', path);
  }

  package = new Package(filename, factory);
  if (!package.hasDependencies) return [package];

  try {
    package.injectedPaths = resolveFilenames(
      package.injectedPaths, dirname);
  } catch (e) {
    rethrow(e, 'Cannot resolve dependency of "%s"', package.path);
  }

  deps = package.injectedPaths.map(function (injectedPath) {
    var dep;
    try {
      dep = resolve(injectedPath, dirname);
    } catch (e) {
      rethrow(e, 'Cannot inject dependency of "%s"', package.path);
    }
    return dep;
  });

  deps.push(package);
  return util.flattenArray(deps);
};
<commit_msg>resolver: minor refactor<commit_after>var getDirname = require('path').dirname,
  Package = require('./package'),
  util = require('./util'),
  resolveFilename = util.resolveFilename,
  resolveFilenames = util.resolveFilenames,
  rethrow = util.rethrow;

module.exports = Resolver;

/**
 * Responsibility:
 *   To identify the dependencies of
 *   a module and return them, as well
 *   as the module in a list,
 *   starting with the oldest parent,
 *   and ending with the dependency
 *   itself.
 *
 * Reason:
 *   This eliminates need to locate
 *   dependencies at runtime; thereby
 *   improving performance.
 */

function Resolver(rootPath) {
  this._basedir = rootPath;
}

/**
 * Recursively resolve the package by its path,
 * along with all of its $inject(ed) dependencies.
 *
 * @param {String} path
 * @returns {Array} of packages, starting at the leafs
 */

Resolver.prototype.resolve = function resolve(path) {
  var filename, dirname, factory, package, deps;

  try {
    filename = resolveFilename(path, arguments[1] || this._basedir);
    factory = require(filename);
  } catch (e) {
    rethrow(e, 'Cannot resolve "%s"', path);
  }

  dirname = getDirname(filename);
  package = new Package(filename, factory);
  if (!package.hasDependencies) return [package];

  try {
    package.injectedPaths = resolveFilenames(
      package.injectedPaths, dirname);
  } catch (e) {
    rethrow(e, 'Cannot resolve dependency of "%s"', package.path);
  }

  deps = package.injectedPaths.map(function (injectedPath) {
    var dep;
    try {
      dep = resolve(injectedPath, dirname);
    } catch (e) {
      rethrow(e, 'Cannot inject dependency of "%s"', package.path);
    }
    return dep;
  });

  deps.push(package);
  return util.flattenArray(deps);
};

{'fraction_non_alphanumeric': 0.12368495877168041, 'fraction_numerical': 0.0005686664771111743, 'mean_word_length': 3.527670527670528, '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': '4390858', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1069, 'n_words': 320}