<commit_before>function newXHR() {
  if (window.ActiveXObject)
    return new ActiveXObject('Microsoft.XMLHTTP');
  else if (window.XMLHttpRequest)
    return new XMLHttpRequest();
  return null;
};

module.exports = function(url, callback, postBody) {
  var xhr = newXHR();

  if (!xhr)
    return;

  xhr.onreadystatechange = function() {
    if (xhr.readyState === 4)
      callback(xhr.responseText);
  };

  if (postBody) {
    xhr.open('POST', url, true);
    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  }
  else
    xhr.open('GET', url, true);

  xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  xhr.send(this.postBody);
};<commit_msg>Throw when no XHR object available.<commit_after>function newXHR() {
  if (window.ActiveXObject)
    return new ActiveXObject('Microsoft.XMLHTTP');
  else if (window.XMLHttpRequest)
    return new XMLHttpRequest();
  return null;
};

module.exports = function(url, callback, postBody) {
  var xhr = newXHR();

  if (!xhr)
    throw new Error('No XMLHttpRequest object available.');

  xhr.onreadystatechange = function() {
    if (xhr.readyState === 4)
      callback(xhr.responseText);
  };

  if (postBody) {
    xhr.open('POST', url, true);
    xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  }
  else
    xhr.open('GET', url, true);

  xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  xhr.send(this.postBody);
};
{'fraction_non_alphanumeric': 0.15352697095435686, 'fraction_numerical': 0.0013831258644536654, 'mean_word_length': 3.972508591065292, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5224894', 'n_tokens_mistral': 504, 'n_tokens_neox': 492, 'n_words': 100}