<commit_before>var chalk = require("chalk");
var barclis = [];
var currentPosition = 0;
var colors = ["red", "green", "yellow", "blue", "magenta", "cyan", "white"];
var maxLabelLength = 0;
var maxValueLength = 0;

// fmap() and constrain() are lifted from <NAME>'s awesome
// Johnny-Five library https://github.com/rwaldron/johnnny-five
var fmap = function(value, fromLow, fromHigh, toLow, toHigh) {
  return (value - fromLow) * (toHigh - toLow) /
    (fromHigh - fromLow) + toLow;
};

var constrain = function(value, lower, upper) {
  return Math.min(upper, Math.max(lower, value));
};

function Barcli(opts) {

  if (!(this instanceof Barcli)) {
    return new Barcli(opts);
  }

  if (typeof opts === "undefined") {
    opts = {};
  }

  if (!opts.range && opts.inputRange) {
    opts.range = opts.inputRange;
  }

  this.index = barclis.length;
  this.autoRange = opts.autoRange || false;
  this.inputRange = opts.range || [null, null];
  this.color = opts.color || colors[this.index % colors.length];
  this.label = opts.label || "Input " + String(this.index + 1);
  this.percent = opts.percent || false;
  this.constrain = !!opts.constrain || false;
  this.precision = opts.precision || 0;
  this.inline = opts.inline || false;

  if (!opts.range || opts.range[0] === null || opts.range[1] === null) {
    this.autoRange = true;
  }

  // So we can avoid wrapping
  if (this.precision > maxValueLength) {
    maxValueLength = this.precision;
  }

  // So we can left align all the graphs
  if (this.label.length > maxLabelLength) {
    maxLabelLength = this.label.length;
  }

  if (barclis.length === 0 && !this.inline){
    clearScreen();
  }

  barclis.push(this);

  resize(opts.width || process.stdout.columns);

}

Barcli.halt = function() {
  barclis.forEach(function(barcli) {
    barcli.finish();
  });
}

Barcli.prototype.finish = function() {
  process.stdout.write("\n");
};

Barcli.prototype.update = function(data) {
  var prepend = append = bar = postbar = "";

  this.data = data;
  
  if (Array.isArray(data)) {
    data = data[0];
  }

  var type = typeof data;

  if (String(data).length > maxValueLength) {
      maxValueLength = String(data).length;
      resize(process.stdout.columns);
  }

  var raw = data;

  if (type === "number") {
    if (this.autoRange) {
      if (isNaN(this.inputRange[0]) || data < this.inputRange[0]) {
        this.inputRange[0] = data;
      }

      if (isNaN(this.inputRange[1]) || data > this.inputRange[1]) {
        this.inputRange[1] = data;
      }
    }

    // Map and constrain the input values
    data = fmap(data, this.inputRange[0], this.inputRange[1], 0, this.width);
    data = constrain(data, 0, this.width);

    // Make our "bar"
    for (i = 0; i < data; i++) {
      bar = bar + " ";
    }

    // Make the space after our bar
    for (i = data; i <= this.width; i++) {
      postbar += " ";
    }
  }

  if (type === "string") {
    bar = data;
    for (i = bar.length; i <= this.width; i++) {
      postbar += " ";
    }
  }

  // Hide the cursor
  process.stdout.write("\033[?25l");

  // Put cursor on the correct line and clear right
  if (this.inline) {
    process.stdout.write("\r");
  } else {<commit_msg>Fix bug where we never saw a full bar<commit_after>var chalk = require("chalk");
var barclis = [];
var currentPosition = 0;
var colors = ["red", "green", "yellow", "blue", "magenta", "cyan", "white"];
var maxLabelLength = 0;
var maxValueLength = 0;

// fmap() and constrain() are lifted from <NAME>'s awesome
// Johnny-Five library https://github.com/rwaldron/johnnny-five
var fmap = function(value, fromLow, fromHigh, toLow, toHigh) {
  return (value - fromLow) * (toHigh - toLow) /
    (fromHigh - fromLow) + toLow;
};

var constrain = function(value, lower, upper) {
  return Math.min(upper, Math.max(lower, value));
};

function Barcli(opts) {

  if (!(this instanceof Barcli)) {
    return new Barcli(opts);
  }

  if (typeof opts === "undefined") {
    opts = {};
  }

  if (!opts.range && opts.inputRange) {
    opts.range = opts.inputRange;
  }

  this.index = barclis.length;
  this.autoRange = opts.autoRange || false;
  this.inputRange = opts.range || [null, null];
  this.color = opts.color || colors[this.index % colors.length];
  this.label = opts.label || "Input " + String(this.index + 1);
  this.percent = opts.percent || false;
  this.constrain = !!opts.constrain || false;
  this.precision = opts.precision || 0;
  this.inline = opts.inline || false;

  if (!opts.range || opts.range[0] === null || opts.range[1] === null) {
    this.autoRange = true;
  }

  // So we can avoid wrapping
  if (this.precision > maxValueLength) {
    maxValueLength = this.precision;
  }

  // So we can left align all the graphs
  if (this.label.length > maxLabelLength) {
    maxLabelLength = this.label.length;
  }

  if (barclis.length === 0 && !this.inline){
    clearScreen();
  }

  barclis.push(this);

  resize(opts.width || process.stdout.columns);

}

Barcli.halt = function() {
  barclis.forEach(function(barcli) {
    barcli.finish();
  });
}

Barcli.prototype.finish = function() {
  process.stdout.write("\n");
};

Barcli.prototype.update = function(data) {
  var prepend = append = bar = postbar = "";

  this.data = data;
  
  if (Array.isArray(data)) {
    data = data[0];
  }

  var type = typeof data;

  if (String(data).length > maxValueLength) {
      maxValueLength = String(data).length;
      resize(process.stdout.columns);
  }

  var raw = data;

  if (type === "number") {
    if (this.autoRange) {
      if (isNaN(this.inputRange[0]) || data < this.inputRange[0]) {
        this.inputRange[0] = data;
      }

      if (isNaN(this.inputRange[1]) || data > this.inputRange[1]) {
        this.inputRange[1] = data;
      }
    }

    // Map and constrain the input values
    data = fmap(data, this.inputRange[0], this.inputRange[1], 0, this.width);
    data = constrain(data, 0, this.width);

    // Make our "bar"
    for (i = 0; i <= data; i++) {
      bar = bar + " ";
    }

    // Make the space after our bar
    for (i = data; i < this.width; i++) {
      postbar += " ";
    }
  }

  if (type === "string") {
    bar = data;
    for (i = bar.length; i <= this.width; i++) {
      postbar += " ";
    }
  }

  // Hide the cursor
  process.stdout.write("\033[?25l");

  // Put cursor on the correct line and clear right
  if (this.inline) {
    process.stdout.write("\r");
  } else {
{'fraction_non_alphanumeric': 0.169369931378665, 'fraction_numerical': 0.007797878976918278, 'mean_word_length': 2.865581675708258, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3029580', 'n_tokens_mistral': 2283, 'n_tokens_neox': 2182, 'n_words': 538}