<commit_before>var _ = require('underscore');
var chalk = require('chalk');
var through = require('through2');

function indent(level) {
  return (new Array(level + 1)).join('  ');
}

function roundPlaces(val, places) {
  var multiplier = Math.pow(10, places);
  return Math.round(val * multiplier) / multiplier;
}

function colorize(val, colors) {
  var i = Math.floor(val * colors.length);
  return colors[i](val);
}

/**
 * opts: {
 *   colors: [color] - The colors used to represent different coverage percentages.
 * }
 */
function coverReporter(opts) {
  var colors = opts.colors || [];
  //@TODO: convert from thresholds to colors array.<commit_msg>Updates to use string-based styles Passing chalk objects across module boundaries was bad news.<commit_after>var _ = require('underscore');
var chalk = require('chalk');
var through = require('through2');

function indent(level) {
  return (new Array(level + 1)).join('  ');
}

function roundPlaces(val, places) {
  var multiplier = Math.pow(10, places);
  return Math.round(val * multiplier) / multiplier;
}

function colorize(val, colors) {
  var i = Math.floor(val / 100 * colors.length);
  i = Math.min(i, colors.length - 1);
  return colors[i](val);
}

/**
 * opts: {
 *   colors: [color] - The colors used to represent different coverage percentages.
 * }
 */
function coverReporter(opts) {
  var colors = opts.colors;
  if(!colors || !colors.length) {
    throw new Error('Must supply at least one color.');
  }

  colors = _.map(colors, function(color) {
    var components = color.split('.');
    return _.reduce(components, function(memo, component) {
      memo = memo[component];
      if(!memo) {
        throw new Error('Invalid chalk style!');
      }
      return memo;
    }, chalk);
  });
{'fraction_non_alphanumeric': 0.14982973893303064, 'fraction_numerical': 0.00681044267877412, 'mean_word_length': 3.764864864864865, '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': '1927828', 'n_tokens_mistral': 561, 'n_tokens_neox': 535, 'n_words': 155}