<commit_before>'use strict';

const Stats = require('fast-stats').Stats;

function percentileName(percentile) {
  if (percentile === 0) {
    return 'min';
  } else if (percentile === 100) {
    return 'max';
  } else if (percentile === 50) {
    return 'median';
  }
  return `p${String(percentile).replace('.', '_')}`;
}

class Statistics {
  constructor(name) {
    this.name = name;
    this.stats = new Stats();
  }

  add(value) {
    this.stats.push(value);
  }

  summarize(options) {
    options = options || {};
    const percentiles = options.percentiles || [0, 10, 50, 90, 99, 100];
    const decimals = options.decimals || 0;
    const data = {};
    const self = this;

    percentiles.forEach(p => {
      const name = percentileName(p);
      data[name] = self.stats.percentile(p).toFixed(decimals);
    });

    return data;
  }
}

module.exports = {
  Statistics,
};
<commit_msg>Remove unused name in Statistics constructor.<commit_after>'use strict';

const Stats = require('fast-stats').Stats;

function percentileName(percentile) {
  if (percentile === 0) {
    return 'min';
  } else if (percentile === 100) {
    return 'max';
  } else if (percentile === 50) {
    return 'median';
  }
  return `p${String(percentile).replace('.', '_')}`;
}

class Statistics {
  constructor() {
    this.stats = new Stats();
  }

  add(value) {
    this.stats.push(value);
  }

  summarize(options) {
    options = options || {};
    const percentiles = options.percentiles || [0, 10, 50, 90, 99, 100];
    const decimals = options.decimals || 0;
    const data = {};
    const self = this;

    percentiles.forEach(p => {
      const name = percentileName(p);
      data[name] = self.stats.percentile(p).toFixed(decimals);
    });

    return data;
  }
}

module.exports = {
  Statistics,
};

{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.021111111111111112, 'mean_word_length': 3.047191011235955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2529913', 'n_tokens_mistral': 646, 'n_tokens_neox': 589, 'n_words': 137}