fix jshint errors for lib/index.js

This commit is contained in:
Philipp Borgers 2013-01-21 14:52:00 +01:00
parent 22d8538879
commit ffe2c15a65

View File

@ -13,7 +13,7 @@ var PG = function(clientConstructor) {
EventEmitter.call(this);
this.Client = clientConstructor;
this.Connection = require(__dirname + '/connection');
this.Query = clientConstructor.Query
this.Query = clientConstructor.Query;
this.defaults = defaults;
};
@ -25,8 +25,8 @@ PG.prototype.end = function() {
pool.drain(function() {
pool.destroyAllNow();
});
})
}
});
};
PG.prototype.connect = function(config, callback) {
var self = this;
@ -42,14 +42,14 @@ PG.prototype.connect = function(config, callback) {
var poolName = typeof(c) === 'string' ? c : c.user+c.host+c.port+c.database;
var pool = pools[poolName];
if(pool) return pool.acquire(cb);
if(pool) { return pool.acquire(cb); }
var pool = pools[poolName] = genericPool.Pool({
pool = pools[poolName] = genericPool.Pool({
name: poolName,
create: function(callback) {
var client = new self.Client(c);
client.connect(function(err) {
if(err) return callback(err);
if(err) { return callback(err); }
//handle connected client background errors by emitting event
//via the pg object and then removing errored client from the pool
@ -74,17 +74,18 @@ PG.prototype.connect = function(config, callback) {
log: defaults.poolLog
});
return pool.acquire(cb);
}
};
// cancel the query runned by the given client
PG.prototype.cancel = function(config, client, query) {
var c = config;
//allow for no config to be passed
if(typeof c === 'function')
if(typeof c === 'function') {
c = defaults;
}
var cancellingClient = new this.Client(c);
cancellingClient.cancel(client, query);
}
};
module.exports = new PG(Client);