<commit_before>'use strict';

/**
 * A small handful of number formatting utilities I've been using in my work
 */

// String.prototype.trim polyfill for numberFormat.unformatMoney in IE < 9
if (!String.prototype.trim) {
  (function() {
    // Make sure we trim BOM and NBSP
    var rgx_trim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;

    String.prototype.trim = function() {
      return this.replace(rgx_trim, '');
    };
  })();
}

var numberFormat = {
  // currency formatter taken from http://www.josscrowcroft.com/2011/code/format-unformat-money-currency-javascript/
  // default args: 0, 2, "$", ",", "."
  formatMoney: function(number, decimal_places, currency_symbol, thousands_separator, decimal_separator) {
    number = number || 0;
    decimal_places = !isNaN(decimal_places = Math.abs(decimal_places)) ? decimal_places : 2;
    currency_symbol = currency_symbol !== undefined ? currency_symbol : '$';
    thousands_separator = thousands_separator || ',';
    decimal_separator = decimal_separator || '.';

    var negative = number < 0 ? '-' : '';
    var i = parseInt(number = Math.abs(+number || 0).toFixed(decimal_places), 10) + '';
    var j = i.length > 3 ? i.length % 3 : 0;

    return negative + currency_symbol
      + (j ? i.substr(0, j) + thousands_separator : '')
      + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousands_separator)
      + (decimal_places
        ? decimal_separator + Math.abs(number - i).toFixed(decimal_places).slice(2)
        : "");
  },

  // Remove non-numeric chars from a string (except decimal point & leading minus)
  // and return a numeric value. Only a leading minus sign (or hyphen-minus
  // character) is interpreted as indicating the number is negative. Any falsey
  // argument returns zero. Anything that makes parseFloat return NaN after the
  // character replacement also returns 0.
  // default options: {
  //   currency_symbol: '$',
  //   thousands_separator: ',',
  //   decimal_separator: '.'
  // }
  unformatMoney: function(value, options) {<commit_msg>Better variable names in formatMoney.<commit_after>'use strict';

/**
 * A small handful of number formatting utilities I've been using in my work
 */

// String.prototype.trim polyfill for numberFormat.unformatMoney in IE < 9
if (!String.prototype.trim) {
  (function() {
    // Make sure we trim BOM and NBSP
    var rgx_trim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;

    String.prototype.trim = function() {
      return this.replace(rgx_trim, '');
    };
  })();
}

var numberFormat = {
  // currency formatter taken from http://www.josscrowcroft.com/2011/code/format-unformat-money-currency-javascript/
  // default args: 0, 2, "$", ",", "."
  formatMoney: function(number, decimal_places, currency_symbol, thousands_separator, decimal_separator) {
    number = number || 0;
    decimal_places = !isNaN(decimal_places = Math.abs(decimal_places)) ? decimal_places : 2;
    currency_symbol = currency_symbol !== undefined ? currency_symbol : '$';
    thousands_separator = thousands_separator || ',';
    decimal_separator = decimal_separator || '.';

    var negative = number < 0 ? '-' : '';
    var integer_str = parseInt(number = Math.abs(+number || 0).toFixed(decimal_places), 10) + '';
    var thou_sep_no1 = integer_str.length > 3 ? integer_str.length % 3 : 0;

    return negative + currency_symbol
      + (thou_sep_no1 ? integer_str.substr(0, thou_sep_no1) + thousands_separator : '')
      + integer_str.substr(thou_sep_no1).replace(/(\d{3})(?=\d)/g, '$1' + thousands_separator)
      + (decimal_places
        ? decimal_separator + Math.abs(number - integer_str).toFixed(decimal_places).slice(2)
        : "");
  },

  // Remove non-numeric chars from a string (except decimal point & leading minus)
  // and return a numeric value. Only a leading minus sign (or hyphen-minus
  // character) is interpreted as indicating the number is negative. Any falsey
  // argument returns zero. Anything that makes parseFloat return NaN after the
  // character replacement also returns 0.
  // default options: {
  //   currency_symbol: '$',
  //   thousands_separator: ',',
  //   decimal_separator: '.'
  // }
  unformatMoney: function(value, options) {
{'fraction_non_alphanumeric': 0.14248210023866348, 'fraction_numerical': 0.011933174224343675, 'mean_word_length': 3.402310924369748, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1151847', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1273, 'n_words': 326}