index.js
function formatNumber(value, options) {
    options = options || {};
    value += ''; // must be String Type

    // not a number !!
    if (!__isNumber(value)) {
        return false;
    }

    var valueArr = __splitValue(value),
        integer = valueArr[0],
        negative = integer < 0,
        absInteger = Math.abs(integer) + '',
        formattedValue;

    if (options.reduce) {
        if (absInteger >= 100000 && absInteger <= 999999) {
            options.prefix = 'k' + options.prefix;
            integer = integer.slice(0, -3);
        } else if (absInteger > 999999 && absInteger <= 9999999) {
            options.prefix = 'Mio ' + options.prefix;
            integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
        } else if (absInteger > 9999999 && absInteger <= 999999999) {
            options.prefix = 'Mio ' + options.prefix;
            integer = integer.slice(0, -6);
        } else if (absInteger > 999999999 && absInteger <= 9999999999) {
            options.prefix = 'Mrd ' + options.prefix;
            integer = integer.slice(0, -8);
            integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
        } else if (absInteger > 9999999999) {
            options.prefix = 'Mrd ' + options.prefix;
            integer = integer.slice(0, -9);
        }

        // add spaces
        formattedValue = __addSpacesSeparator(integer);
    } else {
        // add spaces
        valueArr[0] = __addSpacesSeparator(integer);
        formattedValue = valueArr.join(',');
    }

    if (options.prefix) {
        formattedValue += ' ' + options.prefix;
    }

    return formattedValue;
}
function formatNumber(value, options) {
    options = options || {};
    value += ''; // must be String Type

    // not a number !!
    if (!__isNumber(value)) {
        return false;
    }

    var valueArr = __splitValue(value),
        integer = valueArr[0],
        negative = integer < 0,
        absInteger = Math.abs(integer) + '',
        formattedValue;

    if (options.reduce) {
        if (absInteger >= 100000 && absInteger <= 999999) {
            options.prefix = 'k' + options.prefix;
            integer = integer.slice(0, -3);
        } else if (absInteger > 999999 && absInteger <= 9999999) {
            options.prefix = 'Mio ' + options.prefix;
            integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
        } else if (absInteger > 9999999 && absInteger <= 999999999) {
            options.prefix = 'Mio ' + options.prefix;
            integer = integer.slice(0, -6);
        } else if (absInteger > 999999999 && absInteger <= 9999999999) {
            options.prefix = 'Mrd ' + options.prefix;
            integer = integer.slice(0, -8);
            integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1];
        } else if (absInteger > 9999999999) {
            options.prefix = 'Mrd ' + options.prefix;
            integer = integer.slice(0, -9);
        }

        // add spaces
        formattedValue = __addSpacesSeparator(integer);
    } else {
        // add spaces
        valueArr[0] = __addSpacesSeparator(integer);
        formattedValue = valueArr.join(',');
    }

    if (options.prefix) {
        formattedValue += ' ' + options.prefix;
    }

    return formattedValue;
}
function formatNumber ( value , options ) { options = options || { } ; value += '' ; // must be String Type // not a number !! if ( ! __isNumber ( value ) ) { return false ; } var valueArr = __splitValue ( value ) , integer = valueArr [ 0 ] , negative = integer < 0 , absInteger = Math . abs ( integer ) + '' , formattedValue ; if ( options . reduce ) { if ( absInteger >= 100000 && absInteger <= 999999 ) { options . prefix = 'k' + options . prefix ; integer = integer . slice ( 0 , - 3 ) ; } else if ( absInteger > 999999 && absInteger <= 9999999 ) { options . prefix = 'Mio ' + options . prefix ; integer = negative ? '-' + absInteger [ 0 ] + ',' + absInteger [ 1 ] : absInteger [ 0 ] + ',' + absInteger [ 1 ] ; } else if ( absInteger > 9999999 && absInteger <= 999999999 ) { options . prefix = 'Mio ' + options . prefix ; integer = integer . slice ( 0 , - 6 ) ; } else if ( absInteger > 999999999 && absInteger <= 9999999999 ) { options . prefix = 'Mrd ' + options . prefix ; integer = integer . slice ( 0 , - 8 ) ; integer = negative ? '-' + absInteger [ 0 ] + ',' + absInteger [ 1 ] : absInteger [ 0 ] + ',' + absInteger [ 1 ] ; } else if ( absInteger > 9999999999 ) { options . prefix = 'Mrd ' + options . prefix ; integer = integer . slice ( 0 , - 9 ) ; } // add spaces formattedValue = __addSpacesSeparator ( integer ) ; } else { // add spaces valueArr [ 0 ] = __addSpacesSeparator ( integer ) ; formattedValue = valueArr . join ( ',' ) ; } if ( options . prefix ) { formattedValue += ' ' + options . prefix ; } return formattedValue ; }
Return a well formatted number according to french rules
@param value
@param options
Return a well formatted number according to french rules