<commit_before>'use strict';

const path = require('path'),
      fs = require('fs');

/* readSync.js
 * The synchronous version of read.js
 * * */

module.exports = exports = function(item){
  if (typeof item !== 'string')
  throw new TypeError('path must be a string');

  item = path.resolve(item);

  let stat = fs.statSync(item);
  if (stat.isDirectory()) {
    let defaultFile = this.get('default');
    if (defaultFile !== null)
      defaultFile = path.resolve(item, defaultFile);

    let config = {}, file = null;

    try {
      file = fs.readFileSync(defaultFile);
      Object.assign(config, this.parse(file));

      file = fs.readFileSync(path.resolve(item, this.get('package')));
      Object.assign(config, this.parse(file)[this.get('name')]);
    } catch (e) {
      if (e instanceof SyntaxError) throw e;
    }

    return config;
  }

  else if (stat.isFile())
    return this.parse(fs.readFileSync(item));

  else
    new TypeError('item must be a directory or file');
};<commit_msg>Add readSync array input<commit_after>'use strict';

const path = require('path'),
      fs = require('fs');

/* readSync.js
 * The synchronous version of read.js
 * * */

module.exports = exports = function(item){
  if (Array.isArray(item)) {
    let config = {};
    for (let i of item) Object.assign(config, exports.call(this, i));
    return config;
  }

  if (typeof item !== 'string')
  throw new TypeError('path must be a string');

  item = path.resolve(process.cwd(), item);

  console.log(this);

  let stat = fs.statSync(item);
  if (stat.isDirectory()) {
    let defaultFile = path.resolve(item, this.get('default') || '');

    let config = {}, file = null;

    try {
      if (defaultFile !== item) {
        file = fs.readFileSync(defaultFile);
        Object.assign(config, this.parse(file));
      }

      file = fs.readFileSync(path.resolve(item, this.get('package')));
      Object.assign(config, this.parse(file)[this.get('name')]);
    } catch (e) {
      if (e instanceof SyntaxError) throw e;
    }

    return config;
  }

  else if (stat.isFile())
    return this.parse(fs.readFileSync(item));

  else
    new TypeError('item must be a directory or file');
};
{'fraction_non_alphanumeric': 0.15928799634869922, 'fraction_numerical': 0.0, 'mean_word_length': 3.1515151515151514, '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': '6910506', 'n_tokens_mistral': 707, 'n_tokens_neox': 687, 'n_words': 179}