<commit_before>var extend = require('util')._extend;
var fs = require('fs');
var path = require('path');
var yml = require('js-yaml');

module.exports = function(opts) {
  // Allow extra data to be loaded
  if (opts.extra) {
    var fileContents = fs.readFileSync(opts.extra);
    switch (path.extname(opts.extra)) {
      case '.json':
        this.searchOptions.extra = JSON.parse(fileContents);
        break;
      case '.yml':
        this.searchOptions.extra = yml.safeLoad(fileContents);
        break;
    }
  }
  else {
    this.searchOptions.extra = [];
  }

  // Allow the order of types to be sorted
  this.searchOptions.sort = opts.sort || [];

  // Allow custom page types to be defined
  this.searchOptions.pageTypes = opts.pageTypes || {};

  return this;
}<commit_msg>Use object extend when calling searchConfig<commit_after>var extend = require('extend');
var fs = require('fs');
var path = require('path');
var yml = require('js-yaml');

module.exports = function(opts) {
  this.searchOptions = extend({
    extra: [],
    sort: [],
    pageTypes: {}
  }, opts);

  // Load extra results from an external file
  if (opts.extra) {
    var fileContents = fs.readFileSync(opts.extra);
    switch (path.extname(opts.extra)) {
      case '.json':
        this.searchOptions.extra = JSON.parse(fileContents);
        break;
      case '.yml':
        this.searchOptions.extra = yml.safeLoad(fileContents);
        break;
    }
  }
  else {
    this.searchOptions.extra = [];
  }

  return this;
}
{'fraction_non_alphanumeric': 0.14446653412856197, 'fraction_numerical': 0.0, 'mean_word_length': 2.8917525773195876, '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': '7617008', 'n_tokens_mistral': 469, 'n_tokens_neox': 460, 'n_words': 113}