Browse Source

Rename toFiat() to atRate()

patch-2
Yemel Jardi 10 years ago
parent
commit
d922a625b9
  1. 2
      docs/guide/unit.md
  2. 2
      lib/unit.js
  3. 6
      test/unit.js

2
docs/guide/unit.md

@ -74,6 +74,6 @@ var exchangeRate = 350;
unit = new Unit(amount, exchangeRate);
unit = Unit.fromFiat(amount, exchangeRate);
fiat = Unit.fromBits(amount).toFiat(exchangeRate);
fiat = Unit.fromBits(amount).atRate(exchangeRate);
fiat = Unit.fromBits(amount).to(exchangeRate);
```

2
lib/unit.js

@ -203,7 +203,7 @@ Unit.prototype.toSatoshis = function() {
* @param {string} rate - The exchange rate between BTC/currency
* @returns {Number} The value converted to satoshis
*/
Unit.prototype.toFiat = function(rate) {
Unit.prototype.atRate = function(rate) {
return this.to(rate);
};

6
test/unit.js

@ -142,11 +142,11 @@ describe('Unit', function() {
it('can convert to fiat', function() {
var unit = new Unit(1.3, 350);
unit.toFiat(350).should.equal(1.3);
unit.atRate(350).should.equal(1.3);
unit.to(350).should.equal(1.3);
unit = Unit.fromBTC(0.0123);
unit.toFiat(10).should.equal(0.12);
unit.atRate(10).should.equal(0.12);
});
it('toString works as expected', function() {
@ -186,7 +186,7 @@ describe('Unit', function() {
return new Unit(100, -123);
}).to.throw(errors.Unit.InvalidRate);
expect(function() {
return new Unit(100, 'BTC').toFiat(-123);
return new Unit(100, 'BTC').atRate(-123);
}).to.throw(errors.Unit.InvalidRate);
});

Loading…
Cancel
Save