From a44767fd5bc14f0e6b537f705b741c6195d831c8 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Mon, 19 Nov 2012 12:53:37 -0800 Subject: [PATCH] JS: Add a way to convert an amount to a number. --- src/js/amount.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/js/amount.js b/src/js/amount.js index e75f24837..5f5f58e37 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -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)) {