<commit_before>---
---

(function(window, document) {

  var log = debug('cog-web:api');

  function COG(options) {
    this.url = options.url;
    this.token = options.token;

    var sub = this.token ? this.token.substring(0, 8) : undefined;
    log('constructing new interface object instance with token %s', sub);
  }

  /* internals */

  COG.prototype._ajax = function(options, callback) {
    // options.url = this.url + options.url;
    options.beforeSend = options.beforeSend || ((xhr) => {
      var header = util.generateBasicAuth(this.token);
      xhr.setRequestHeader('Authorization', header);
    });

    return $.ajax(options).then((data, status, xhr) => {
      callback(null, data, status, xhr);
    }, (xhr, status, err) => {
      callback(err, null, status, xhr);<commit_msg>Drop use of arrow functions due to slow ES6 adoption.<commit_after>---
---

(function(window, document) {

  var log = debug('cog-web:api');

  function COG(options) {
    this.url = options.url;
    this.token = options.token;

    var sub = this.token ? this.token.substring(0, 8) : undefined;
    log('constructing new interface object instance with token %s', sub);
  }

  /* internals */

  COG.prototype._ajax = function(options, callback) {
    var self = this;
    // options.url = this.url + options.url;
    options.beforeSend = options.beforeSend || function(xhr) {
      var header = util.generateBasicAuth(self.token);
      xhr.setRequestHeader('Authorization', header);
    };

    return $.ajax(options).then(function(data, status, xhr) {
      callback(null, data, status, xhr);
    }, function(xhr, status, err) {
      callback(err, null, status, xhr);
{'fraction_non_alphanumeric': 0.15407673860911272, 'fraction_numerical': 0.002997601918465228, 'mean_word_length': 3.193467336683417, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4281769', 'n_tokens_mistral': 533, 'n_tokens_neox': 520, 'n_words': 125}