chore: allow for callback => promise deprecation (#15758)

* chore: allow for callback => promise deprecation

* cb type check is sufficient

* migrate warn to always trigger
This commit is contained in:
Shelley Vohr 2018-11-19 12:56:26 -05:00 committed by GitHub
parent 51cb36fa9b
commit a45d5960d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,6 +67,25 @@ const deprecate = {
})
},
promisify: (promise, cb) => {
const oldName = `${promise.name} with callbacks`
const newName = `${promise.name} with Promises`
const warn = warnOnce(oldName, newName)
if (typeof cb !== 'function') return promise
warn()
return promise
.then(res => {
process.nextTick(() => {
cb(null, res)
})
}, err => {
process.nextTick(() => {
cb(err)
})
})
},
renameProperty: (o, oldName, newName) => {
const warn = warnOnce(oldName, newName)