use decorate on gt and lt
This commit is contained in:
parent
9c23256a16
commit
3cbf2e07c4
|
@ -85,28 +85,22 @@ function decorate(name) {
|
||||||
bnjs.prototype[name] = f;
|
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('add');
|
||||||
decorate('sub');
|
decorate('sub');
|
||||||
decorate('mul');
|
decorate('mul');
|
||||||
decorate('mod');
|
decorate('mod');
|
||||||
decorate('div');
|
decorate('div');
|
||||||
decorate('cmp');
|
decorate('cmp');
|
||||||
|
decorate('gt');
|
||||||
bnjs.prototype.gt = function(b) {
|
decorate('lt');
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
bnjs.prototype.toNumber = function() {
|
bnjs.prototype.toNumber = function() {
|
||||||
return parseInt(this['toString'](10), 10);
|
return parseInt(this['toString'](10), 10);
|
||||||
|
|
Loading…
Reference in New Issue