Skip to content

Commit bbbd6e9

Browse files
committed
Use built-in util.deprecate
1 parent 272858c commit bbbd6e9

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

lib/index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ var defaults = require('./defaults');
1313
var Connection = require('./connection');
1414
var ConnectionParameters = require('./connection-parameters');
1515
var poolFactory = require('./pool-factory');
16-
var deprecate = require('deprecate');
1716

1817
var PG = function(clientConstructor) {
1918
EventEmitter.call(this);
@@ -28,8 +27,7 @@ var PG = function(clientConstructor) {
2827

2928
util.inherits(PG, EventEmitter);
3029

31-
PG.prototype.end = function() {
32-
deprecate('pg.end() is deprecated - please construct pools directly via new pg.Pool()');
30+
PG.prototype.end = util.deprecate(function() {
3331
var self = this;
3432
var keys = Object.keys(this._pools);
3533
var count = keys.length;
@@ -49,10 +47,10 @@ PG.prototype.end = function() {
4947
});
5048
});
5149
}
52-
};
50+
},
51+
'pg.end() is deprecated - please construct pools directly via new pg.Pool()');
5352

54-
PG.prototype.connect = function(config, callback) {
55-
deprecate('pg.connect() is deprecated - please construct pools directly via new pg.Pool()');
53+
PG.prototype.connect = util.deprecate(function(config, callback) {
5654
if(typeof config == "function") {
5755
callback = config;
5856
config = null;
@@ -78,11 +76,11 @@ PG.prototype.connect = function(config, callback) {
7876
}.bind(this));
7977
}
8078
return pool.connect(callback);
81-
};
79+
},
80+
'pg.connect() is deprecated - please construct pools directly via new pg.Pool()');
8281

8382
// cancel the query running on the given client
84-
PG.prototype.cancel = function(config, client, query) {
85-
deprecate('pg.cancel() is deprecated - please create your own client instances to cancel queries');
83+
PG.prototype.cancel = util.deprecate(function(config, client, query) {
8684
if(client.native) {
8785
return client.cancel(query);
8886
}
@@ -93,7 +91,7 @@ PG.prototype.cancel = function(config, client, query) {
9391
}
9492
var cancellingClient = new this.Client(c);
9593
cancellingClient.cancel(client, query);
96-
};
94+
}, 'pg.cancel() is deprecated - please create your own client instances to cancel queries');
9795

9896
if(typeof process.env.NODE_PG_FORCE_NATIVE != 'undefined') {
9997
module.exports = new PG(require('./native'));

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"main": "./lib",
2020
"dependencies": {
2121
"buffer-writer": "1.0.1",
22-
"deprecate": "1.0.0",
2322
"packet-reader": "0.3.1",
2423
"pg-connection-string": "0.1.3",
2524
"pg-pool": "1.*",

test/test-helper.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//make assert a global...
22
assert = require('assert');
3-
4-
require('deprecate').silence = true;
5-
3+
process.noDeprecation = true;
64
var EventEmitter = require('events').EventEmitter;
75
var sys = require('util');
86
var BufferList = require(__dirname+'/buffer-list')

0 commit comments

Comments
 (0)