use decorate on gt and lt

This commit is contained in:
Ryan X. Charles 2014-07-10 18:45:27 -07:00
parent 9c23256a16
commit 3cbf2e07c4
1 changed files with 10 additions and 16 deletions

View File

@ -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);