<commit_before>import each from 'keen-core/lib/utils/each';
import serialize from 'keen-core/lib/utils/serialize';

export const GET = get;
export const POST = post;
export const PUT = put;
export const DELETE = del;

// HTTP Handlers
// ------------------------------

function get(config, callback){
  if (xhrObject()) {
    return sendXhr('GET', config, callback);
  }
  else if (xdrObject()){
    return sendXdr('GET', config, callback);
  }
  else {
    return sendJsonp(config, callback);
  }
}

function post(config, callback){
  if (xhrObject()) {
    return sendXhr('POST', config, callback);
  }
  else if (xdrObject()){
    return sendXdr('POST', config, callback);
  }
  else {
    callback('XHR POST not supported', null);
  }
}

function put(config, callback) {
  if (xhrObject()) {
    return sendXhr('PUT', config, callback);
  }
  else {
    callback('XHR PUT not supported', null);
  }
}

function del(config, callback) {
  if (xhrObject()) {
    return sendXhr('DELETE', config, callback);
  }
  else {
    callback('XHR DELETE not supported', null);
  }
}


// XMLHttpRequest Support
// ------------------------------

function xhrObject() {
  const root = 'undefined' == typeof window ? this : window;
  if (root.XMLHttpRequest && ('file:' != root.location.protocol || !root.ActiveXObject)) {
    return new XMLHttpRequest;
  } else {
    try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}
    try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}
    try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}
    try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}
  }
  return false;
}

function sendXhr(method, config, callback){<commit_msg>fix for #28<commit_after>import each from 'keen-core/lib/utils/each';
import serialize from 'keen-core/lib/utils/serialize';

export const GET = get;
export const POST = post;
export const PUT = put;
export const DELETE = del;

// HTTP Handlers
// ------------------------------

function get(config, callback){
  if (xhrObject()) {
    return sendXhr('GET', config, callback);
  }
  else if (xdrObject()){
    return sendXdr('GET', config, callback);
  }
  else {
    return sendJsonp(config, callback);
  }
}

function post(config, callback){
  if (xhrObject()) {
    return sendXhr('POST', config, callback);
  }
  else if (xdrObject()){
    return sendXdr('POST', config, callback);
  }
  else {
    callback('XHR POST not supported', null);
  }
}

function put(config, callback) {
  if (xhrObject()) {
    return sendXhr('PUT', config, callback);
  }
  else {
    callback('XHR PUT not supported', null);
  }
}

function del(config, callback) {
  if (xhrObject()) {
    return sendXhr('DELETE', config, callback);
  }
  else {
    callback('XHR DELETE not supported', null);
  }
}


// XMLHttpRequest Support
// ------------------------------

function xhrObject() {
  const root = 'undefined' == typeof window ? this : window;
  if (root.XMLHttpRequest &&
       (
         !root.ActiveXObject ||
         (root.location && root.location.protocol
           && 'file:' !== root.location.protocol)
       )
  ) {
    return new XMLHttpRequest;
  } else {
    try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}
    try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}
    try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}
    try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}
  }
  return false;
}

function sendXhr(method, config, callback){
{'fraction_non_alphanumeric': 0.1812251843448667, 'fraction_numerical': 0.0045377197958026095, 'mean_word_length': 3.0170842824601367, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '2455406', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1131, 'n_words': 291}