<commit_before>export const formatCurrency = amount => {
  const formatter = new Intl.NumberFormat('en-US', {
    currency: 'USD',
    maximumFractionDigits: 2,
    minimumFractionDigits: 2,
    style: 'currency',
  });
  return formatter.format(amount);
};

export const centsToDollars = cents => {
  if (!cents) return 0;
  return formatCurrency(parseFloat(cents / 100).toFixed(2));
};

export const dollarsToCents = dollars => {
  dollars = dollars.replace(',', '').replace('$', '');
  dollars = parseFloat(dollars).toFixed(2);

  const result = parseFloat(dollars * 100);

  // TODO: Throw an error instead of 0.
  if (result > 999999999 || result < -999999999) {
    return 0;
  }

  return result;
};

export const stringIsNumber = number => {
  number = number.replace(',', '').replace('$', '');
  number = parseFloat(number);
  return typeof number === 'number' && !Number.isNaN(number);
};
<commit_msg>Numbers are hard.<commit_after>export const formatCurrency = amount => {
  const formatter = new Intl.NumberFormat('en-US', {
    currency: 'USD',
    maximumFractionDigits: 2,
    minimumFractionDigits: 2,
    style: 'currency',
  });
  return formatter.format(amount);
};

export const centsToDollars = cents => {
  if (!cents) return 0;
  return formatCurrency(parseFloat(cents / 100).toFixed(2));
};

export const dollarsToCents = dollars => {
  dollars = dollars.replace(',', '').replace('$', '');
  dollars = parseFloat(dollars).toFixed(2);

  const result = parseFloat(dollars * 100).toFixed(0);

  // TODO: Throw an error instead of 0.
  if (result > 999999999 || result < -999999999) {
    return 0;
  }

  return result;
};

export const stringIsNumber = number => {
  number = number.replace(',', '').replace('$', '');
  number = parseFloat(number);
  return typeof number === 'number' && !Number.isNaN(number);
};

{'fraction_non_alphanumeric': 0.16548720740337508, 'fraction_numerical': 0.03429504627109418, 'mean_word_length': 4.0633608815427, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '3196647', 'n_tokens_mistral': 647, 'n_tokens_neox': 585, 'n_words': 146}