ui/app/util.js
// Its "formatted" property is what we generally use to render values.
Its "formatted" property is what we generally use to render values.
Its " formatted " property is what we generally use to render values .
function formatBalance (balance, decimalsToKeep, needsParse = true) {
  var parsed = needsParse ? parseBalance(balance) : balance.split('.')
  var beforeDecimal = parsed[0]
  var afterDecimal = parsed[1]
  var formatted = 'None'
  if (decimalsToKeep === undefined) {
    if (beforeDecimal === '0') {
      if (afterDecimal !== '0') {
        var sigFigs = afterDecimal.match(/^0*(.{2})/) 
        if (sigFigs) { afterDecimal = sigFigs[0] }
        formatted = '0.' + afterDecimal + ' ETH'
      }
    } else {
      formatted = beforeDecimal + '.' + afterDecimal.slice(0, 3) + ' ETH'
    }
  } else {
    afterDecimal += Array(decimalsToKeep).join('0')
    formatted = beforeDecimal + '.' + afterDecimal.slice(0, decimalsToKeep) + ' ETH'
  }
  return formatted
}
function formatBalance ( balance , decimalsToKeep , needsParse = true ) { var parsed = needsParse ? parseBalance ( balance ) : balance . split ( '.' ) var beforeDecimal = parsed [ 0 ] var afterDecimal = parsed [ 1 ] var formatted = 'None' if ( decimalsToKeep === undefined ) { if ( beforeDecimal === '0' ) { if ( afterDecimal !== '0' ) { var sigFigs = afterDecimal . match ( / ^0*(.{2}) / ) if ( sigFigs ) { afterDecimal = sigFigs [ 0 ] } formatted = '0.' + afterDecimal + ' ETH' } } else { formatted = beforeDecimal + '.' + afterDecimal . slice ( 0 , 3 ) + ' ETH' } } else { afterDecimal += Array ( decimalsToKeep ) . join ( '0' ) formatted = beforeDecimal + '.' + afterDecimal . slice ( 0 , decimalsToKeep ) + ' ETH' } return formatted }
Its "formatted" property is what we generally use to render values.
Its " formatted " property is what we generally use to render values .
// default: grabs 2 most significant digits