<commit_before>'use strict';


function RingBuffer(size) {
  this.size = size;
  this.data_start = 0;
  this.data_count = 0;
  this.data = new Array(size);
};


RingBuffer.prototype.capacity = function() {
  return this.size;
};

RingBuffer.prototype.count = function() {
  return this.data_count;
};

RingBuffer.prototype.isEmpty = function() {
  return this.data_count == 0;
};

RingBuffer.prototype.isFull = function() {
  return this.data_count == this.size;
};

RingBuffer.prototype.write = function(val) {
  var pos = (this.data_start + this.data_count) % this.size;
  this.data[pos] = val;
  if (this.data_count < this.size)
    this.data_count += 1;
  else
    this.data_start = (this.data_start + 1) % this.size;
};

RingBuffer.prototype.read = function() {
  var val = this.data[this.data_start];
  this.data_start = (this.data_start + 1) % this.size;
  this.data_count = Math.max(this.data_count - 1, 0);
  return val;
};

RingBuffer.prototype.resize = function(n) {
  var new_data = new Array(n);
  for (var i = 0; i < this.data_count; ++i)
    new_data[i % n] = this.data[(this.data_start + i) % this.size];
  this.size = n;
  this.data_start = 0;
  this.data_count = Math.min(this.data_count, this.size);
  this.data = new_data;
};


var pull = function() {
  return this.buffer.isEmpty() ? [] : [this.buffer.read()];
};


function Buffer(size) {
  this.buffer = new RingBuffer(size || 1);
};

Buffer.prototype.canFail = function() {
  return true;
};

Buffer.prototype.push = function(val) {
  if (this.buffer.isFull())
    return false;<commit_msg>define saner behaviour for Ringbuffer read and resize<commit_after>'use strict';


function RingBuffer(size) {
  this.size = size;
  this.data_start = 0;
  this.data_count = 0;
  this.data = new Array(size);
};


RingBuffer.prototype.capacity = function() {
  return this.size;
};

RingBuffer.prototype.count = function() {
  return this.data_count;
};

RingBuffer.prototype.isEmpty = function() {
  return this.data_count == 0;
};

RingBuffer.prototype.isFull = function() {
  return this.data_count == this.size;
};

RingBuffer.prototype.write = function(val) {
  var pos = (this.data_start + this.data_count) % this.size;
  this.data[pos] = val;
  if (this.data_count < this.size)
    this.data_count += 1;
  else
    this.data_start = (this.data_start + 1) % this.size;
};

RingBuffer.prototype.read = function() {
  if (this.data_count > 0) {
    var val = this.data[this.data_start];
    this.data_start = (this.data_start + 1) % this.size;
    this.data_count = Math.max(this.data_count - 1, 0);
    return val;
  }
};

RingBuffer.prototype.resize = function(n) {
  var new_data = new Array(n);
  if (n < this.data_count) {
    var base = this.data_start + this.data_count - n;
    for (var i = 0; i < n; ++i)
      new_data[i] = this.data[(base + i) % this.size];
  }
  else
    for (var i = 0; i < this.data_count; ++i)
      new_data[i] = this.data[(this.data_start + i) % this.size];
  this.size = n;
  this.data_start = 0;
  this.data_count = Math.min(this.data_count, this.size);
  this.data = new_data;
};


var pull = function() {
  return this.buffer.isEmpty() ? [] : [this.buffer.read()];
};


function Buffer(size) {
  this.buffer = new RingBuffer(size || 1);
};

Buffer.prototype.canFail = function() {
  return true;
};

Buffer.prototype.push = function(val) {
  if (this.buffer.isFull())
    return false;
{'fraction_non_alphanumeric': 0.15899705014749263, 'fraction_numerical': 0.007079646017699115, 'mean_word_length': 3.533422459893048, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3556356', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1224, 'n_words': 256}