<commit_before>export const formatNumber = (number = 0, settings) => {
  const x = 3;

  const re = '\\d(?=(\\d{' + x + '})+' + (settings.decimal_number > 0
    ? '\\D'
    : '$') + ')';

  let num = number.toFixed(Math.max(0, ~~ settings.decimal_number));

  return (settings.decimal_separator
    ? num.replace('.', settings.decimal_separator)
    : num).replace(new RegExp(re, 'g'), '$&' + (settings.thousand_separator));
};

const amountPattern = '{amount}';
export const formatCurrency = (number = 0, settings) => {
  return settings.currency_format.replace(amountPattern, formatNumber(number, settings));
}
<commit_msg>Fix bug if number is null<commit_after>export const formatNumber = (number = 0, settings) => {
  const x = 3;

  const re = '\\d(?=(\\d{' + x + '})+' + (settings.decimal_number > 0
    ? '\\D'
    : '$') + ')';

  let num = (number || 0).toFixed(Math.max(0, ~~ settings.decimal_number));

  return (settings.decimal_separator
    ? num.replace('.', settings.decimal_separator)
    : num).replace(new RegExp(re, 'g'), '$&' + (settings.thousand_separator));
};

const amountPattern = '{amount}';
export const formatCurrency = (number = 0, settings) => {
  return settings.currency_format.replace(amountPattern, formatNumber(number, settings));
}

{'fraction_non_alphanumeric': 0.19227738376674547, 'fraction_numerical': 0.008668242710795903, 'mean_word_length': 4.204918032786885, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6624703', 'n_tokens_mistral': 438, 'n_tokens_neox': 414, 'n_words': 88}