JS: Add a way to convert an amount to a number.

This commit is contained in:
Arthur Britto
2012-11-19 12:53:37 -08:00
committed by Stefan Thomas
parent d134a283b3
commit 2d6c8ae297

View File

@@ -353,6 +353,12 @@ Amount.prototype.issuer = function() {
return this._issuer;
};
Amount.prototype.to_number = function(allow_nan) {
var s = this.to_text(allow_nan);
return ('string' === typeof s) ? Number(s) : s;
}
// Convert only value to JSON wire format.
Amount.prototype.to_text = function(allow_nan) {
if (isNaN(this._value)) {