<commit_before>import btod from "./btod";

// [[fill]align][sign][symbol][0][width][,][.precision][type]
var formatRe = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,
    systemSymbols = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];

export default function(x, p) {
  var i = (x = p == null ? x.toExponential() : x.toExponential(p - 1)).indexOf("e"); // TODO ternary?
  if (i < 0) return x;

  var coefficient = x.slice(0, i),
      exponent = +x.slice(i + 1),
      offset = exponent % 3;

  if (offset) {
    var j = coefficient.indexOf("."),
        decimal = j < 0 ? coefficient : coefficient.slice(0, j),
        fractional = j < 0 ? "" : coefficient.slice(j + 1);
    if (offset < 0) offset += 3;
    coefficient = decimal + (offset >= fractional.length
        ? fractional + new Array(offset - fractional.length + 1).join("0")
        : fractional.slice(0, offset) + "." + fractional.slice(offset));
  }

  return coefficient + symbols[8 + Math.floor(exponent / 3)];
};

var formatTypes = {
  "b": function(x) { return x.toString(2); },
  "c": function(x) { return String.fromCharCode(x); },
  "o": function(x) { return x.toString(8); },
  "x": function(x) { return x.toString(16); },
  "X": function(x) { return x.toString(16).toUpperCase(); },
  "g": function(x, p) { return x.toPrecision(p); },
  "e": function(x, p) { return x.toExponential(p); },
  "f": function(x, p) { return x.toFixed(p); },
  "%": function(x, p) { return (x * 100).toFixed(p); },
  "p": toRoundedPercentage,
  "r": toRounded,
  "s": toSystem
};

function toRoundedPercentage(x, p) {
  var d = btod(x, p);
  if (!d) return x + "";
  var i = d.exponent + 2;
  return i <= 0
      ? "0." + new Array(1 - i).join("0") + d.coefficient
      : d.coefficient.slice(0, i)
      + (d.coefficient.length > i
      ? "." + d.coefficient.slice(i)
      : new Array(i - d.coefficient.length + 1).join("0"));
}
<commit_msg>Delete dead code.<commit_after>import btod from "./btod";

// [[fill]align][sign][symbol][0][width][,][.precision][type]
var formatRe = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,
    systemSymbols = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];

var formatTypes = {
  "b": function(x) { return x.toString(2); },
  "c": function(x) { return String.fromCharCode(x); },
  "o": function(x) { return x.toString(8); },
  "x": function(x) { return x.toString(16); },
  "X": function(x) { return x.toString(16).toUpperCase(); },
  "g": function(x, p) { return x.toPrecision(p); },
  "e": function(x, p) { return x.toExponential(p); },
  "f": function(x, p) { return x.toFixed(p); },
  "%": function(x, p) { return (x * 100).toFixed(p); },
  "p": toRoundedPercentage,
  "r": toRounded,
  "s": toSystem
};

function toRoundedPercentage(x, p) {
  var d = btod(x, p);
  if (!d) return x + "";
  var i = d.exponent + 2;
  return i <= 0
      ? "0." + new Array(1 - i).join("0") + d.coefficient
      : d.coefficient.slice(0, i)
      + (d.coefficient.length > i
      ? "." + d.coefficient.slice(i)
      : new Array(i - d.coefficient.length + 1).join("0"));
}

{'fraction_non_alphanumeric': 0.2685096917699396, 'fraction_numerical': 0.017159199237368923, 'mean_word_length': 3.471590909090909, 'pattern_counts': {'":': 24, '<': 11, '<?xml version=': 0, '>': 8, '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': '6845167', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1233, 'n_words': 249}