src/coins/compress.js
function compressValue(value) {
  if (value === 0)
    return 0;

  let exp = 0;
  while (value % 10 === 0 && exp < 9) {
    value /= 10;
    exp++;
  }

  if (exp < 9) {
    const last = value % 10;
    value = (value - last) / 10;
    return 1 + 10 * (9 * value + last - 1) + exp;
  }

  return 10 + 10 * (value - 1);
}
function compressValue(value) {
  if (value === 0)
    return 0;

  let exp = 0;
  while (value % 10 === 0 && exp < 9) {
    value /= 10;
    exp++;
  }

  if (exp < 9) {
    const last = value % 10;
    value = (value - last) / 10;
    return 1 + 10 * (9 * value + last - 1) + exp;
  }

  return 10 + 10 * (value - 1);
}
function compressValue ( value ) { if ( value === 0 ) return 0 ; let exp = 0 ; while ( value % 10 === 0 && exp < 9 ) { value /= 10 ; exp ++ ; } if ( exp < 9 ) { const last = value % 10 ; value = ( value - last ) / 10 ; return 1 + 10 * ( 9 * value + last - 1 ) + exp ; } return 10 + 10 * ( value - 1 ) ; }
Compress value using an exponent. Takes advantage of
the fact that many bitcoin values are divisible by 10.
@see https://github.com/btcsuite/btcd/blob/master/blockchain/compress.go
@param {Amount} value
@returns {Number}
Compress value using an exponent . Takes advantage of the fact that many bitcoin values are divisible by 10 .