From 3cbf2e07c4b27c8a8552defa62b33e422141b909 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Thu, 10 Jul 2014 18:45:27 -0700 Subject: [PATCH] use decorate on gt and lt --- lib/browser/Bignum.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/lib/browser/Bignum.js b/lib/browser/Bignum.js index 7ada158..1109855 100644 --- a/lib/browser/Bignum.js +++ b/lib/browser/Bignum.js @@ -85,28 +85,22 @@ function decorate(name) { bnjs.prototype[name] = f; }; +_bnjs.prototype.gt = function(b) { + return this.cmp(b) > 0; +}; + +_bnjs.prototype.lt = function(b) { + return this.cmp(b) < 0; +}; + decorate('add'); decorate('sub'); decorate('mul'); decorate('mod'); decorate('div'); decorate('cmp'); - -bnjs.prototype.gt = function(b) { - if (typeof b === 'string') - b = new _bnjs(b); - else if (typeof b === 'number') - b = new _bnjs(b.toString()); - return this.cmp(b) > 0; -}; - -bnjs.prototype.lt = function(b) { - if (typeof b === 'string') - b = new _bnjs(b); - else if (typeof b === 'number') - b = new _bnjs(b.toString()); - return this.cmp(b) < 0; -}; +decorate('gt'); +decorate('lt'); bnjs.prototype.toNumber = function() { return parseInt(this['toString'](10), 10);