<commit_before>
var QueuePostMessages = function() {
  this.queue = [];

  _.bindAll(this, 'sendBatch');
  this.sendBatch = _.debounce(this.sendBatch, this._debounceTime);
}

_.extend(QueuePostMessages.prototype, {

  _debounceTime: 100,

  push: function(message) {
    message.target = "page"; // il messaggio riguarda la pagina

    this.queue.push(message);
    this.sendBatch();
  },

  sendBatch: function() {
    window.postMessage(this.queue, "*");
    this.queue = [];
  }

});


var queuePostMessages = new QueuePostMessages();

// @private
var sendMessage = function(message) {
  queuePostMessages.push(message)
};<commit_msg>Cap backboneAgent batch messages at 1000<commit_after>
var QueuePostMessages = function() {
  this.queue = [];

  _.bindAll(this, 'sendBatch');
  this.sendBatch = _.debounce(this.sendBatch, this._debounceTime);
}

_.extend(QueuePostMessages.prototype, {

  _debounceTime: 100,

  push: function(message) {
    message.target = "page"; // il messaggio riguarda la pagina

    // console.log('!!! ', message.name, this.queue.length, new Date().getTime());
    this.queue.push(message);

    if (this.queue.length >= 1000) {
      this.sendBatchImmediate();
    } else {
      this.sendBatch();
    }
  },

  sendBatch: function() {
    this.send();
  },

  sendBatchImmediate: function() {
    this.send();
  },

  send: function() {
    // console.log('!!!! sending batch message')
    window.postMessage(this.queue, "*");
    this.queue = [];
  }

});


var queuePostMessages = new QueuePostMessages();

// @private
var sendMessage = function(message) {
  queuePostMessages.push(message)
};
{'fraction_non_alphanumeric': 0.15918869084204057, 'fraction_numerical': 0.008604794099569761, 'mean_word_length': 3.625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4931552', 'n_tokens_mistral': 553, 'n_tokens_neox': 516, 'n_words': 99}