<commit_before>/**
 * numbersjs
 *
 * A tiny number formatting library for easy formatting of numbers.
 *
 * @author <NAME>
 * @license MIT
 */
(function(){

    "use strict";

    var version = '0.0.1',
        defaultSettings = {
            decimalSeparator : '.',  // E.g. 123.45
            thousandSeparator: ',',  // E.g. 12,000 for twelve thousand
            roundTo          : 2,    // Round to this many decimals; negative for rounding to whole numbers; FALSE to disable
            forceDecimals    : false // Add trailing zeroes if less than the number
        };

    function NumberFormatter(settings)
    {
        this.config = settings || defaultSettings;
    }

    NumberFormatter.version = version;

    NumberFormatter.prototype.format = function(value)
    {
        var roundingFactor, characteristic, decimals, formattingHelper,
            formattedValue = parseFloat(value);

        if (isNaN(formattedValue) || !isFinite(formattedValue)) {
            throw new Error('Could not interpret given value as float.');
        }

        // Round.
        if (!isNaN(this.config.roundTo) || isFinite(this.config.roundTo)) {
            roundingFactor = Math.pow(10, this.config.roundTo);

            formattedValue = formattedValue * roundingFactor;
            formattedValue = Math.round(formattedValue);
            formattedValue = formattedValue / roundingFactor;
        }

        formattingHelper = formattedValue.toString().split('.');
        characteristic   = formattingHelper[0];
        decimals         = formattingHelper[1] || '';

        // Format thousand separator.
        if (this.config.thousandSeparator) {
            formattingHelper = '';

            if (characteristic.length > 3) {
                while (characteristic.length > 3) {
                    formattingHelper = characteristic.substr(-3) + (formattingHelper.length ? this.config.thousandSeparator + formattingHelper : '');
                    characteristic   = characteristic.substr(0, characteristic.length - 3);
                }

                if (characteristic.length) {
                    characteristic = characteristic + this.config.thousandSeparator + formattingHelper;
                } else {
                    characteristic = formattingHelper;
                }
            }
        }

        // Add trailing zeroes if required.
        if (this.config.forceDecimals) {
            while (decimals.length < this.config.roundTo) {
                decimals += '0';
            }<commit_msg>Fixes roundTo:false not being applied correctly.<commit_after>/**
 * numbersjs
 *
 * A tiny number formatting library for easy formatting of numbers.
 *
 * @author <NAME>
 * @license MIT
 */
(function(){

    "use strict";

    var version = '0.0.1',
        defaultSettings = {
            decimalSeparator : '.',  // E.g. 123.45
            thousandSeparator: ',',  // E.g. 12,000 for twelve thousand
            roundTo          : 2,    // Round to this many decimals; negative for rounding to whole numbers; FALSE to disable
            forceDecimals    : false // Add trailing zeroes if less than the number
        };

    function NumberFormatter(settings)
    {
        this.config = settings || defaultSettings;
    }

    NumberFormatter.version = version;

    NumberFormatter.prototype.format = function(value)
    {
        var roundingFactor, characteristic, decimals, formattingHelper,
            formattedValue = parseFloat(value);

        if (isNaN(formattedValue) || !isFinite(formattedValue)) {
            throw new Error('Could not interpret given value as float.');
        }

        // Round.
        if (!isNaN(this.config.roundTo) && isFinite(this.config.roundTo) && this.config.roundTo !== false) {
            roundingFactor = Math.pow(10, this.config.roundTo);

            formattedValue = formattedValue * roundingFactor;
            formattedValue = Math.round(formattedValue);
            formattedValue = formattedValue / roundingFactor;
        }

        formattingHelper = formattedValue.toString().split('.');
        characteristic   = formattingHelper[0];
        decimals         = formattingHelper[1] || '';

        // Format thousand separator.
        if (this.config.thousandSeparator) {
            formattingHelper = '';

            if (characteristic.length > 3) {
                while (characteristic.length > 3) {
                    formattingHelper = characteristic.substr(-3) + (formattingHelper.length ? this.config.thousandSeparator + formattingHelper : '');
                    characteristic   = characteristic.substr(0, characteristic.length - 3);
                }

                if (characteristic.length) {
                    characteristic = characteristic + this.config.thousandSeparator + formattingHelper;
                } else {
                    characteristic = formattingHelper;
                }
            }
        }

        // Add trailing zeroes if required.
        if (this.config.forceDecimals && !isNaN(this.config.roundTo) && isFinite(this.config.roundTo) && this.config.roundTo !== false) {
            while (decimals.length < this.config.roundTo) {
                decimals += '0';
            }
{'fraction_non_alphanumeric': 0.10297219558964525, 'fraction_numerical': 0.009204218600191754, 'mean_word_length': 1.9686966420034149, 'pattern_counts': {'":': 0, '<': 7, '<?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': '300173', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1279, 'n_words': 309}