From a033980b66ea7f081497052a3739dbb0bf385262 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Thu, 18 Oct 2012 12:23:17 -0700 Subject: [PATCH] JS: Add negate() and parse_issuer() to Amount. --- js/amount.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/amount.js b/js/amount.js index 09991347..c3dfa390 100644 --- a/js/amount.js +++ b/js/amount.js @@ -258,6 +258,15 @@ Amount.prototype.canonicalize = function() { } }; +Amount.prototype.negate = function () { + if (this.is_native) { + this.value.negate(); + } + else { + this.is_negative = !this.is_negative; + } +}; + Amount.prototype.to_json = function() { if (this.is_native) { return this.to_text(); @@ -400,6 +409,12 @@ Amount.prototype.parse_json = function(j) { return this; }; +Amount.prototype.parse_issuer = function (issuer) { + this.issuer.parse_json(issuer); + + return this; +}; + exports.setAccounts = setAccounts; exports.Amount = Amount; exports.Currency = Currency;