diff --git a/lib/common/api/deprecate.js b/lib/common/api/deprecate.js index f72939b6e9db..2c24a82eef2c 100644 --- a/lib/common/api/deprecate.js +++ b/lib/common/api/deprecate.js @@ -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)