allow single object passed to bitcoin.Client()

This commit is contained in:
freewil 2011-10-08 11:26:50 -04:00
parent 9b657d67e6
commit 553e220182
2 changed files with 10 additions and 7 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

View File

@ -48,14 +48,16 @@ var bitcoinAPI = {
//===----------------------------------------------------------------------===//
// Client
// Either pass in 4 arguments, or a single object with host, port, user, pass
//===----------------------------------------------------------------------===//
function Client(host, port, user, pass) {
this.host = host;
this.port = port;
this.user = user;
this.pass = pass;
this.rpc = new rpc.Client(port, host, user, pass);
function Client() {
var args = [].slice.call(arguments);
this.host = args[0].host || args[0];
this.port = args[0].port || args[1];
this.user = args[0].user || args[2];
this.pass = args[0].pass || args[3];
this.rpc = new rpc.Client(this.port, this.host, this.user, this.pass);
}