diff --git a/lib/index.js b/lib/index.js index 343819cd..a2439711 100644 --- a/lib/index.js +++ b/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')); diff --git a/package.json b/package.json index b7fd9d0c..d52ba05c 100644 --- a/package.json +++ b/package.json @@ -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.*", diff --git a/test/test-helper.js b/test/test-helper.js index ad3e785b..f39cbfef 100644 --- a/test/test-helper.js +++ b/test/test-helper.js @@ -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')