Rename toFiat() to atRate()
This commit is contained in:
parent
168d87185c
commit
d922a625b9
|
@ -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);
|
||||
```
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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…
Reference in New Issue