mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Use built-in util.deprecate
This commit is contained in:
parent
272858ca57
commit
bbbd6e99f9
18
lib/index.js
18
lib/index.js
@ -13,7 +13,6 @@ var defaults = require('./defaults');
|
||||
var Connection = require('./connection');
|
||||
var ConnectionParameters = require('./connection-parameters');
|
||||
var poolFactory = require('./pool-factory');
|
||||
var deprecate = require('deprecate');
|
||||
|
||||
var PG = function(clientConstructor) {
|
||||
EventEmitter.call(this);
|
||||
@ -28,8 +27,7 @@ var PG = function(clientConstructor) {
|
||||
|
||||
util.inherits(PG, EventEmitter);
|
||||
|
||||
PG.prototype.end = function() {
|
||||
deprecate('pg.end() is deprecated - please construct pools directly via new pg.Pool()');
|
||||
PG.prototype.end = util.deprecate(function() {
|
||||
var self = this;
|
||||
var keys = Object.keys(this._pools);
|
||||
var count = keys.length;
|
||||
@ -49,10 +47,10 @@ PG.prototype.end = function() {
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
'pg.end() is deprecated - please construct pools directly via new pg.Pool()');
|
||||
|
||||
PG.prototype.connect = function(config, callback) {
|
||||
deprecate('pg.connect() is deprecated - please construct pools directly via new pg.Pool()');
|
||||
PG.prototype.connect = util.deprecate(function(config, callback) {
|
||||
if(typeof config == "function") {
|
||||
callback = config;
|
||||
config = null;
|
||||
@ -78,11 +76,11 @@ PG.prototype.connect = function(config, callback) {
|
||||
}.bind(this));
|
||||
}
|
||||
return pool.connect(callback);
|
||||
};
|
||||
},
|
||||
'pg.connect() is deprecated - please construct pools directly via new pg.Pool()');
|
||||
|
||||
// cancel the query running on the given client
|
||||
PG.prototype.cancel = function(config, client, query) {
|
||||
deprecate('pg.cancel() is deprecated - please create your own client instances to cancel queries');
|
||||
PG.prototype.cancel = util.deprecate(function(config, client, query) {
|
||||
if(client.native) {
|
||||
return client.cancel(query);
|
||||
}
|
||||
@ -93,7 +91,7 @@ PG.prototype.cancel = function(config, client, query) {
|
||||
}
|
||||
var cancellingClient = new this.Client(c);
|
||||
cancellingClient.cancel(client, query);
|
||||
};
|
||||
}, 'pg.cancel() is deprecated - please create your own client instances to cancel queries');
|
||||
|
||||
if(typeof process.env.NODE_PG_FORCE_NATIVE != 'undefined') {
|
||||
module.exports = new PG(require('./native'));
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"buffer-writer": "1.0.1",
|
||||
"deprecate": "1.0.0",
|
||||
"packet-reader": "0.3.1",
|
||||
"pg-connection-string": "0.1.3",
|
||||
"pg-pool": "1.*",
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
//make assert a global...
|
||||
assert = require('assert');
|
||||
|
||||
require('deprecate').silence = true;
|
||||
|
||||
process.noDeprecation = true;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var sys = require('util');
|
||||
var BufferList = require(__dirname+'/buffer-list')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user