<commit_before>function Queue() {
  this._queue = [];
}

Queue.prototype.add = function(fn) {
  this._queue.push(fn);
  return this;
}

Queue.prototype._virginScope = function(cb){
  var executed = false;
  return function() {
    if (executed) throw new Error('callback can\'t be executed twice');
    executed = true;
    cb.apply(this, Array.prototype.slice.call(arguments));
  }
}

Queue.prototype.run = function(cb) {
  var q = this;
  var next = function(error) {
    if (error !== void 0) return cb(error);
    var task = q._queue.shift();  
    if (task) {
      task(q._virginScope(next));
    } else {
      cb();
    }
  }
  next();
}<commit_msg>ADD: change virgin scope to anonymous function<commit_after>function Queue() {
  this._queue = [];
}

Queue.prototype.add = function(fn) {
  this._queue.push(fn);
  return this;
}


Queue.prototype.run = function(cb) {
  var queue = this._queue;
  var next = function(error) {
    if (error !== void 0) return cb(error);
    var task = queue.shift();  
    if (!task) return cb();
    task((function(){
      var executed = false;
      return function(error) {
        if (executed) throw new Error('callback can\'t be executed twice');
        executed = true;
        next(error);
      }
    })());
  }
  next();
}
{'fraction_non_alphanumeric': 0.156078431372549, 'fraction_numerical': 0.001568627450980392, 'mean_word_length': 2.8902439024390243, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2413760', 'n_tokens_mistral': 420, 'n_tokens_neox': 416, 'n_words': 105}