<commit_before>var types = require("dis-isa");
var utils = require("belty");

function File(options) {
  if (!(this instanceof File)) {
    return new File(options);
  }

  return (
    options instanceof File ?
    utils.assign(this, options) :
    utils.assign(this, configureFile(options))
  );
}

function configureFile(file) {
  if (!file) {
    throw new TypeError("Must provide a valid input. String, Array<String>, { src: Array<String> }, { content: String | Buffer }");
  }

  if (types.isString(file) || types.isArray(file)) {
    return { src: file };
  }
  else {
    const content = file.content || file.source;

    if (types.isString(content) || types.isBuffer(content)) {
      return { content: content.toString(), path: file.path };
    }

    return file;
  }
};

module.exports = File;<commit_msg>adding comments in file to help clarify<commit_after>var types = require("dis-isa");
var utils = require("belty");

function File(options) {
  if (!(this instanceof File)) {
    return new File(options);
  }

  return (
    options instanceof File ?
    utils.assign(this, options) :
    utils.assign(this, configureFile(options))
  );
}

/**
 * file has a couple of relevant fields.
 * 
 * - content, which is a string or buffer that is the actual file content. Sometime
 *   this field comes along with a path in order to properly resolve the paths for
 *   any dependencies relative to the given path.
 * - path, which is a fully qualified path for the file. This does not get resolved
 *   by bit-loader.
 * - src, which is an array of files to be loaded. These gets resolved by bit-loader.
 */
function configureFile(file) {
  if (!file) {
    throw new TypeError("Must provide a valid input. String, Array<String>, { src: Array<String> }, { content: String | Buffer }");
  }

  if (types.isString(file) || types.isArray(file)) {
    return { src: file };
  }
  else {
    const content = file.content || file.source;

    if (types.isString(content) || types.isBuffer(content)) {
      return { content: content.toString(), path: file.path };
    }

    return file;
  }
};

module.exports = File;
{'fraction_non_alphanumeric': 0.1311320754716981, 'fraction_numerical': 0.0, 'mean_word_length': 3.319755600814664, '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': '3541742', 'n_tokens_mistral': 636, 'n_tokens_neox': 628, 'n_words': 208}