diff --git a/lib/index.js b/lib/index.js index 8e000a378..bc84aab05 100644 --- a/lib/index.js +++ b/lib/index.js @@ -13,8 +13,19 @@ var defaults = require('./defaults') var Connection = require('./connection') var Pool = require('pg-pool') +let hasNewTarget = false + +try { + eval('(function () { new.target })') + hasNewTarget = true +} catch (error) {} + const poolFactory = (Client) => { var BoundPool = function (options) { + if (hasNewTarget && eval('new.target') === undefined) { + process.emitWarning('Constructing a pg.Pool without new is deprecated and will stop working in pg 8.', 'DeprecationWarning', 'PG-POOL-NEW') + } + var config = Object.assign({ Client: Client }, options) return new Pool(config) }