lib/vendor/sugar.js
function(place, thousands, decimal) {
      var i, str, split, integer, fraction, result = '';
      if(isUndefined(thousands)) {
        thousands = ',';
      }
      if(isUndefined(decimal)) {
        decimal = '.';
      }
      str      = (isNumber(place) ? round(this, place || 0).toFixed(math.max(place, 0)) : this.toString()).replace(/^-/, '');
      split    = str.split('.');
      integer  = split[0];
      fraction = split[1];
      for(i = integer.length; i > 0; i -= 3) {
        if(i < integer.length) {
          result = thousands + result;
        }
        result = integer.slice(math.max(0, i - 3), i) + result;
      }
      if(fraction) {
        result += decimal + repeatString((place || 0) - fraction.length, '0') + fraction;
      }
      return (this < 0 ? '-' : '') + result;
    }
function(place, thousands, decimal) {
      var i, str, split, integer, fraction, result = '';
      if(isUndefined(thousands)) {
        thousands = ',';
      }
      if(isUndefined(decimal)) {
        decimal = '.';
      }
      str      = (isNumber(place) ? round(this, place || 0).toFixed(math.max(place, 0)) : this.toString()).replace(/^-/, '');
      split    = str.split('.');
      integer  = split[0];
      fraction = split[1];
      for(i = integer.length; i > 0; i -= 3) {
        if(i < integer.length) {
          result = thousands + result;
        }
        result = integer.slice(math.max(0, i - 3), i) + result;
      }
      if(fraction) {
        result += decimal + repeatString((place || 0) - fraction.length, '0') + fraction;
      }
      return (this < 0 ? '-' : '') + result;
    }
function ( place , thousands , decimal ) { var i , str , split , integer , fraction , result = '' ; if ( isUndefined ( thousands ) ) { thousands = ',' ; } if ( isUndefined ( decimal ) ) { decimal = '.' ; } str = ( isNumber ( place ) ? round ( this , place || 0 ) . toFixed ( math . max ( place , 0 ) ) : this . toString ( ) ) . replace ( / ^- / , '' ) ; split = str . split ( '.' ) ; integer = split [ 0 ] ; fraction = split [ 1 ] ; for ( i = integer . length ; i > 0 ; i -= 3 ) { if ( i < integer . length ) { result = thousands + result ; } result = integer . slice ( math . max ( 0 , i - 3 ) , i ) + result ; } if ( fraction ) { result += decimal + repeatString ( ( place || 0 ) - fraction . length , '0' ) + fraction ; } return ( this < 0 ? '-' : '' ) + result ; }
*
@method format([place] = 0, [thousands] = ',', [decimal] = '.')
@returns String
@short Formats the number to a readable string.
@extra If [place] is %undefined%, will automatically determine the place. [thousands] is the character used for the thousands separator. [decimal] is the character used for the decimal point.
@example

(56782).format()           -> '56,782'
(56782).format(2)          -> '56,782.00'
(4388.43).format(2, ' ')      -> '4 388.43'
(4388.43).format(2, '.', ',') -> '4.388,43'

*
* @method format ( [ place ] = 0 [ thousands ] = [ decimal ] = . ) @returns String @short Formats the number to a readable string . @extra If [ place ] is %undefined% will automatically determine the place . [ thousands ] is the character used for the thousands separator . [ decimal ] is the character used for the decimal point . @example