@@ -13,7 +13,6 @@ var defaults = require('./defaults');
13
13
var Connection = require ( './connection' ) ;
14
14
var ConnectionParameters = require ( './connection-parameters' ) ;
15
15
var poolFactory = require ( './pool-factory' ) ;
16
- var deprecate = require ( 'deprecate' ) ;
17
16
18
17
var PG = function ( clientConstructor ) {
19
18
EventEmitter . call ( this ) ;
@@ -28,8 +27,7 @@ var PG = function(clientConstructor) {
28
27
29
28
util . inherits ( PG , EventEmitter ) ;
30
29
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 ( ) {
33
31
var self = this ;
34
32
var keys = Object . keys ( this . _pools ) ;
35
33
var count = keys . length ;
@@ -49,10 +47,10 @@ PG.prototype.end = function() {
49
47
} ) ;
50
48
} ) ;
51
49
}
52
- } ;
50
+ } ,
51
+ 'pg.end() is deprecated - please construct pools directly via new pg.Pool()' ) ;
53
52
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 ) {
56
54
if ( typeof config == "function" ) {
57
55
callback = config ;
58
56
config = null ;
@@ -78,11 +76,11 @@ PG.prototype.connect = function(config, callback) {
78
76
} . bind ( this ) ) ;
79
77
}
80
78
return pool . connect ( callback ) ;
81
- } ;
79
+ } ,
80
+ 'pg.connect() is deprecated - please construct pools directly via new pg.Pool()' ) ;
82
81
83
82
// 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 ) {
86
84
if ( client . native ) {
87
85
return client . cancel ( query ) ;
88
86
}
@@ -93,7 +91,7 @@ PG.prototype.cancel = function(config, client, query) {
93
91
}
94
92
var cancellingClient = new this . Client ( c ) ;
95
93
cancellingClient . cancel ( client , query ) ;
96
- } ;
94
+ } , 'pg.cancel() is deprecated - please create your own client instances to cancel queries' ) ;
97
95
98
96
if ( typeof process . env . NODE_PG_FORCE_NATIVE != 'undefined' ) {
99
97
module . exports = new PG ( require ( './native' ) ) ;
0 commit comments