mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
* First crack at monorepo * Update test command * Update path to script * Remove node 6 from CI
23 lines
537 B
JavaScript
23 lines
537 B
JavaScript
'use strict'
|
||
|
||
const warnDeprecation = require('./warn-deprecation')
|
||
|
||
// Node 4 doesn’t support new.target.
|
||
let hasNewTarget
|
||
|
||
try {
|
||
// eslint-disable-next-line no-eval
|
||
eval('(function () { new.target })')
|
||
hasNewTarget = true
|
||
} catch (error) {
|
||
hasNewTarget = false
|
||
}
|
||
|
||
const checkConstructor = (name, code, getNewTarget) => {
|
||
if (hasNewTarget && getNewTarget() === undefined) {
|
||
warnDeprecation(`Constructing a ${name} without new is deprecated and will stop working in pg 8.`, code)
|
||
}
|
||
}
|
||
|
||
module.exports = checkConstructor
|