node-postgres/packages/pg/lib/compat/check-constructor.js
Brian C 1b5f3e33c4
Monorepo (#2014)
* First crack at monorepo

* Update test command

* Update path to script

* Remove node 6 from CI
2019-12-17 08:32:08 -08:00

23 lines
537 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict'
const warnDeprecation = require('./warn-deprecation')
// Node 4 doesnt 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