Browse Source

move static isValid next to instance isValid

...to be easier for developers to parse and distinguish
patch-2
Ryan X. Charles 11 years ago
parent
commit
80625fdbef
  1. 18
      lib/address.js

18
lib/address.js

@ -10,15 +10,6 @@ function Address(obj) {
this.set(obj);
};
Address.isValid = function(addrstr) {
try {
var address = new Address().fromString(addrstr);
} catch (e) {
return false;
}
return address.isValid();
};
Address.prototype.set = function(obj) {
this.hashbuf = obj.hashbuf || this.hashbuf || null;
this.networkstr = obj.networkstr || this.networkstr || 'mainnet';
@ -60,6 +51,15 @@ Address.prototype.fromString = function(str) {
return this;
}
Address.isValid = function(addrstr) {
try {
var address = new Address().fromString(addrstr);
} catch (e) {
return false;
}
return address.isValid();
};
Address.prototype.isValid = function() {
try {
this.validate();

Loading…
Cancel
Save