Skip to content
Browse files

Merge pull request #203 from visionmedia/refactor-getClient

add support for `require("riak-js")()` to initialize a client
  • Loading branch information...
2 parents 539f254 + 7046d35 commit 01ce6e61fdaa3c5dafd68a87fbdce88dd8744d90 @roidrage roidrage committed
Showing with 15 additions and 23 deletions.
  1. +15 −23 lib/index.js
View
38 lib/index.js
@@ -4,30 +4,22 @@
var HttpClient = require('./http-client'),
ProtocolBuffersClient = require('./protocol-buffers-client');
-module.exports = {
-
- protobuf: function(options) {
- return new ProtocolBuffersClient(options);
- },
+module.exports = getClient;
- http: function(options) {
- return new HttpClient(options);
- },
+function getClient(options) {
+ if (options == undefined) options = {};
- /**
- * Obtains an instance of `HttpClient`.
- *
- * @param {Object|Meta} options [optional]
- * @return {HttpClient}
- * @api public
- */
- getClient: function(options) {
- if (options == undefined) options = {};
-
- if (options.api == undefined) {
- options.api = 'http';
- }
-
- return module.exports[options.api](options);
+ if (options.api == undefined) {
+ options.api = 'http';
}
+
+ return getClient[options.api](options);
}
+
+getClient.protobuf = function(options) {
+ return new ProtocolBuffersClient(options);
+};
+
+getClient.http = function(options) {
+ return new HttpClient(options);
+};

0 comments on commit 01ce6e6

Please sign in to comment.
Something went wrong with that request. Please try again.