<commit_before>module.exports = function() {

  function doXHR(method, url, opts, callback) {
    var xhr = new XHR();
    var body = options.body || options.data;
    var doJSON = false;
    var sync = !!options.sync;

    xhr = new XHR();
    xhr.url = url;
    xhr.method = method;
    xhr.headers = options.headers || {};
    xhr.onreadystatechange = readystatechange;
    xhr.onload = load.bind(callback);
    xhr.onerror = error;
    xhr.ontimeout = timeout;
    xhr.onprogress = noop; // IE9

    if ('json' in options) {
      doJSON = true;
      headers['Content-Type'] = 'application/json';
      body = JSON.stringify(options.json);
    }

    xhr.open(method, url, !sync);
    xhr.send(body);

    function load() {
      var error;
      var status = xhr.statusCode || xhr.status;
      var body = xhr.body || xhr.response || xhr.responseText;

      if (status === 0 || (status >= 400 && status < 600)) {
        var message = xhr.responseText || String(xhr.status);
      }
    }
  }

  function Req(type, url, opts) {
    var thens = [];

    doXHR(type, url, opts, function(data) {
      thens.forEach(function(then) {
        then.call(then, data)
      });
    });

    return {
      then: function(callback) {
        thens.push(callback);
      }
    };
  }

  return {
    get: function(url, opts) {
      return new Req('get', url, opts);
    },

    post: function(url, opts) {
      return new Req('post', url, opts);
    }
  };

};<commit_msg>cleanup a bit<commit_after>module.exports = function() {

  Object.extend = function(dest, src) {
    for (var property in src)
      src.hasOwnProperty(property) &&
        dest[property] = src[property];

    return dest;
  };

  function doXHR(opts, callback) {
    var url = opts.url;
    var method = opts.method;
    var xhr = new XHR();
    var body = options.body || options.data;
    var doJSON = false;
    var sync = !!options.sync;

    xhr = new XHR();
    xhr.url = url;
    xhr.method = method;
    xhr.headers = options.headers || {};
    xhr.onreadystatechange = readystatechange;
    xhr.onload = load.bind(callback);
    xhr.onerror = error;
    xhr.ontimeout = timeout;
    xhr.onprogress = noop; // IE9

    if ('json' in options) {
      doJSON = true;
      headers['Content-Type'] = 'application/json';
      body = JSON.stringify(options.json);
    }

    xhr.open(method, url, !sync);
    xhr.send(body);

    function load() {
      var error;
      var status = xhr.statusCode || xhr.status;
      var body = xhr.body || xhr.response || xhr.responseText;

      if (status === 0 || (status >= 400 && status < 600)) {
        var message = xhr.responseText || String(xhr.status);
      }
    }
  }

  function Req(opts) {
    var thens = [];

    doXHR(opts, function(data) {
      thens.forEach(function(then) {
        then.call(then, data)
      });
    });

    return {
      then: function(callback) {
        thens.push(callback);
      }
    };
  }

  function doReq(url, opts) {
    return new Req({method: 'get', url: url}.extend(opts));
  }

  var requ = {};
  ['get', 'post', 'put', 'update'].forEach(function(method) {
    requ[method] = function(url, opts) {
      return doReq(url, opts);
    };
  });

  return requ;
};
{'fraction_non_alphanumeric': 0.1543458088462728, 'fraction_numerical': 0.0049489638107021346, 'mean_word_length': 2.334020618556701, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7257091', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1082, 'n_words': 247}