<commit_before>// This is the text editor interface.
// Anything you type or change here will be seen by the other person in real time.

// concurrency - how many tasks we can run at a time - integer
function TaskRunner(concurrency) {
    this.capacity = concurrency;
    this.state = "empty";
    this.count = 0;
    this.storage = []; // turn to q
};


TaskRunner.prototype.push = function push( task ) {
    var that = this;

    if( this.count < this.capacity ){
        console.log( "executes immediately" );
        task(cb);
        this.count += 1
    }
    else{
        console.log( "should wait until one of the running tasks completes" );
        this.storage.push( task );
    }

    function cb(){
      // return that.count -= 1;
      that.count -= 1;
      if( that.storage[0] ){
        that.storage[0]();
        that.storage = that.storage.slice(1);
      }

    };// cb

};// push

function exampleSimpleTask(done){
  console.log("running");
  setTimeout(done, Math.random() * 1000);
};<commit_msg>edit solution<commit_after>// This is the text editor interface.
// Anything you type or change here will be seen by the other person in real time.

// concurrency - how many tasks we can run at a time - integer
function TaskRunner(concurrency) {
    this.capacity = concurrency;
    this.state = "empty";
    this.count = 0;
    this.storage = []; // turn to q
};


TaskRunner.prototype.push = function push( task ) {
    var that = this;

    if( this.count < this.capacity ){
        console.log( "executes immediately" );
        task(cb);
        this.count += 1
    }
    else{
        console.log( "should wait until one of the running tasks completes" );
        this.storage.push( task );
    }

    function cb(){
      that.count -= 1;
      if( that.storage[0] ){
        that.storage[0]();
        that.storage = that.storage.slice(1);
      }
    };// cb

};// push

function exampleSimpleTask(done){
  console.log("running");
  setTimeout(done, Math.random() * 1000);
};
{'fraction_non_alphanumeric': 0.13273453093812376, 'fraction_numerical': 0.010479041916167664, 'mean_word_length': 2.3528428093645486, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2469657', 'n_tokens_mistral': 614, 'n_tokens_neox': 591, 'n_words': 188}