Permalink
Browse files

Camel case aliases, config as object as well as string

  • Loading branch information...
1 parent 4770b94 commit 27a56c2c37640d40c8ae8d55113ef42367629e32 @pascalopitz committed Feb 26, 2013
Showing with 30 additions and 7 deletions.
  1. +30 −7 lib/beanstalk_client.js
View
@@ -98,15 +98,18 @@ function BeanstalkClient() {
util.inherits(BeanstalkClient, events.EventEmitter);
// Singleton like method that returns an instance
-BeanstalkClient.prototype.Instance = function(server) {
- var p = [];
-
- if(server) {
- p = server.split(':');
+BeanstalkClient.prototype.Instance = function(config) {
+ if (config) {
+ if (typeof config == 'string') {
+ var c = config.split(':');
+ this.address = c[0] || this.address;
+ this.port = c[1] || this.port;
+ } else {
+ this.address = config.address || this.address;
+ this.port = config.port || this.port;
+ }
}
- this.address = (p[0]) ? p[0] : this.address;
- this.port = (p[1]) ? p[1] : this.port;
return this;
};
@@ -257,6 +260,8 @@ BeanstalkClient.prototype.reserve_with_timeout = function(time) {
expected: 'RESERVED'
});
};
+// camel case alias
+BeanstalkClient.prototype.reserveWithTimeout = BeanstalkClient.prototype.reserve_with_timeout;
// ###touch
// tell the server that you're still working on a job
@@ -334,6 +339,8 @@ BeanstalkClient.prototype.peek_ready = function() {
expected: 'FOUND'
});
};
+// camel case alias
+BeanstalkClient.prototype.peekReady = BeanstalkClient.prototype.peek_ready;
// ###peek-delayed
// let's you inspect the next delayed job
@@ -343,6 +350,8 @@ BeanstalkClient.prototype.peek_delayed = function() {
expected: 'FOUND'
});
};
+// camel case alias
+BeanstalkClient.prototype.peekDelayed = BeanstalkClient.prototype.peek_delayed;
// ###peek-buried
// let's you inspect the next buried job
@@ -352,6 +361,8 @@ BeanstalkClient.prototype.peek_buried = function() {
expected: 'FOUND'
});
};
+// camel case alias
+BeanstalkClient.prototype.peekBuried = BeanstalkClient.prototype.peek_buried;
// ###stats
// gives statistical information about the server
@@ -372,6 +383,8 @@ BeanstalkClient.prototype.stats_job = function(id) {
is_yaml: 1
});
};
+// camel case alias
+BeanstalkClient.prototype.statsJob = BeanstalkClient.prototype.stats_job;
// ###stats-tube
// gives statistical information about the specified tube if it exists
@@ -382,6 +395,8 @@ BeanstalkClient.prototype.stats_tube = function(tube) {
is_yaml: 1
});
};
+// camel case alias
+BeanstalkClient.prototype.statsTube = BeanstalkClient.prototype.stats_tube;
// ###list-tubes
// lists all existing tubes
@@ -392,6 +407,8 @@ BeanstalkClient.prototype.list_tubes = function() {
is_yaml: 1
});
};
+// camel case alias
+BeanstalkClient.prototype.listTubes = BeanstalkClient.prototype.list_tubes;
// ###list-tubes-watched
// lists all existing tubes that are currently watched
@@ -402,6 +419,8 @@ BeanstalkClient.prototype.list_tubes_watched = function() {
is_yaml: 1
});
};
+// camel case alias
+BeanstalkClient.prototype.listTubesWatched = BeanstalkClient.prototype.list_tubes_watched;
// ###list-tube-used
// returns the tube currently being used by the client
@@ -411,6 +430,8 @@ BeanstalkClient.prototype.list_tube_used = function() {
expected: 'USING'
});
};
+// camel case alias
+BeanstalkClient.prototype.listTubeUsed = BeanstalkClient.prototype.list_tube_used;
// ###pause-tube
// can delay any new job being reserved for a given time
@@ -420,6 +441,8 @@ BeanstalkClient.prototype.pause_tube = function(tube, delay) {
expected: 'PAUSED'
});
};
+// camel case alias
+BeanstalkClient.prototype.pauseTube = BeanstalkClient.prototype.pause_tube;
// ###quit
// closes connection

0 comments on commit 27a56c2

Please sign in to comment.