function Unit(amount, code) {
  if (!(this instanceof Unit)) {
    return new Unit(amount, code);
  }

  // convert fiat to BTC
  if (_.isNumber(code)) {
    if (code <= 0) {
      throw new errors.Unit.InvalidRate(code);
    }
    amount = amount / code;
    code = Unit.BTC;
  }

  this._value = this._from(amount, code);

  var self = this;
  var defineAccesor = function(key) {
    Object.defineProperty(self, key, {
      get: function() { return self.to(key); },
      enumerable: true,
    });
  };

  Object.keys(UNITS).forEach(defineAccesor);
}
Utility for handling and converting bitcoins units. The supported units are
BTC, mBTC, bits (also named uBTC) and satoshis. A unit instance can be created with an
amount and a unit code, or alternatively using static methods like {fromBTC}.
It also allows to be created from a fiat amount and the exchange rate, or
alternatively using the {fromFiat} static method.
You can consult for different representation of a unit instance using it's
{to} method, the fixed unit methods like {toSatoshis} or alternatively using
the unit accessors. It also can be converted to a fiat amount by providing the
corresponding BTC/fiat exchange rate.

@example
```javascript
var sats = Unit.fromBTC(1.3).toSatoshis();
var mili = Unit.fromBits(1.3).to(Unit.mBTC);
var bits = Unit.fromFiat(1.3, 350).bits;
var btc = new Unit(1.3, Unit.bits).BTC;
```

@param {Number} amount - The amount to be represented
@param {String|Number} code - The unit of the amount or the exchange rate
@returns {Unit} A new instance of an Unit
@constructor