<commit_before>
var request = require('./request.js')
  , xml2js = require('xml2js').parseString
  , EUTILS_BASE = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/';

function buildQueryParameters(options, ignoreList) {
  var query = '';
  for (var prop in options) {
    if (options.hasOwnProperty(prop) && ignoreList.indexOf(prop) == -1) {
      query += '&' + prop + '=' + options[prop];
    }
  }
  return query;
}

exports.einfo = function einfo(db) {
  var requestURL = EUTILS_BASE + 'einfo.fcgi?retmode=json&';
  if (db !== undefined) {
    requestURL += 'version=2.0&db=' + db;
  }
  return request(requestURL).then(function(res) {
    return JSON.parse(res);
  });
};

function ensureOptionIsSet(options, names, tag) {
  var msg = 'Invalid arguments supplied to ' + tag;
  if (options === undefined) {
    throw new Error(msg);
  }

  for (var i = 0; i < names.length; ++i) {
    if (options[names[i]] === undefined) {
      throw new Error(msg);
    }
  }
}

exports.esearch = function esearch(options) {

  ensureOptionIsSet(options, ['db', 'term'], 'esearch');
<commit_msg>rearrange code<commit_after>
var request = require('./request.js')
  , Term = require('./term.js')
  , xml2js = require('xml2js').parseString
  , EUTILS_BASE = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/';

function buildQueryParameters(options, ignoreList) {
  var query = '';
  for (var prop in options) {
    if (options.hasOwnProperty(prop) && ignoreList.indexOf(prop) == -1) {
      query += '&' + prop + '=' + options[prop];
    }
  }
  return query;
}

function ensureOptionIsSet(options, names, tag) {
  var msg = 'Invalid arguments supplied to ' + tag;
  if (options === undefined) {
    throw new Error(msg);
  }

  for (var i = 0; i < names.length; ++i) {
    if (options[names[i]] === undefined) {
      throw new Error(msg);
    }
  }
}

exports.einfo = function einfo(db) {
  var requestURL = EUTILS_BASE + 'einfo.fcgi?retmode=json&';
  if (db !== undefined) {
    requestURL += 'version=2.0&db=' + db;
  }
  return request(requestURL).then(function(res) {
    return JSON.parse(res);
  });
};

exports.esearch = function esearch(options) {

  ensureOptionIsSet(options, ['db', 'term'], 'esearch');

{'fraction_non_alphanumeric': 0.17507958162801274, 'fraction_numerical': 0.005457025920873124, 'mean_word_length': 3.592901878914405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '7512171', 'n_tokens_mistral': 781, 'n_tokens_neox': 770, 'n_words': 165}