Rename toFiat() to atRate()

This commit is contained in:
Yemel Jardi 2014-12-28 17:40:11 -03:00
parent 168d87185c
commit d922a625b9
3 changed files with 5 additions and 5 deletions

View File

@ -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);
```

View File

@ -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);
};

View File

@ -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);
});