<commit_before>/*
 *  See https://github.com/stackp/promisejs
 */

(function(glue) {

  function Promise() {
    this.callbacks = [];
  }

  Promise.prototype.then = function(func, context) {
    var p;
    if (this.isdone) {
      p = func.apply(context, this.args);
    } else {
      p = new Promise();
      this.callbacks.push(function() {
        var res = func.apply(context, arguments);
        if (res && typeof res.then === 'function') {
          res.then(p.done, p);
        }
      });
    }
    return p;
  };

  Promise.prototype.done = function() {
    this.args = arguments;
    this.isdone = true;
    for (var i = 0; i < this.callbacks.length; i++) {
      this.callbacks[i].apply(null, arguments);
    }
    this.callbacks = [];
  };

  glue.promise = function() {
    return new Promise();
  };

})(glue);<commit_msg>some cleanup<commit_after>/**
 * Basic implementation of promises
 * see https://github.com/stackp/promisejs
*/

(function(glue) {

  function Promise() {
    this.callbacks = [];
  }

  Promise.prototype.then = function(func, context) {
    var p;
    if (this.isdone) {
      p = func.apply(context, this.args);
    } else {
      p = new Promise();
      this.callbacks.push(function() {
        var res = func.apply(context, arguments);
        if (res && typeof res.then === 'function') {
          res.then(p.done, p);
        }
      });
    }
    return p;
  };

  Promise.prototype.done = function() {
    this.args = arguments;
    this.isdone = true;
    for (var i = 0; i < this.callbacks.length; i++) {
      this.callbacks[i].apply(null, arguments);
    }
    this.callbacks = [];
  };
  

  /**
   PUBLIC ∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼∼
  */
    
  glue.promise = function() {
    return new Promise();
  };

})(glue);
{'fraction_non_alphanumeric': 0.18386914833615342, 'fraction_numerical': 0.0011280315848843769, 'mean_word_length': 2.255045871559633, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3667383', 'n_tokens_mistral': 632, 'n_tokens_neox': 617, 'n_words': 120}