feat: re-add deprecate.property()

This commit is contained in:
Charles Kerr 2018-05-29 15:40:19 +02:00
parent 0f1fcc3f4b
commit 0a614217ce

View file

@ -87,20 +87,27 @@ deprecate.getHandler = () => deprecationHandler
// return this[member][method].apply(this[member], arguments) // return this[member][method].apply(this[member], arguments)
// } // }
// } // }
//
// // Deprecate a property. // Deprecate the old name of a property
// deprecate.property = (object, property, method) => { deprecate.property = (object, deprecatedName, newName) => {
// return Object.defineProperty(object, property, { return Object.defineProperty(object, deprecatedName, {
// get: function () { get: function () {
// let warned = false let warned = false
// if (!(warned || process.noDeprecation)) { if (!(warned || process.noDeprecation)) {
// warned = true warned = true
// deprecate.warn(`${property} property`, `${method} method`) deprecate.warn(deprecatedName, newName)
// } }
// return this[method]() return this[newName]
// } },
// }) set: function (value) {
// } let warned = false
// if (!(warned || process.noDeprecation)) {
warned = true
deprecate.warn(deprecatedName, newName)
}
this[newName] = value
}
})
}
module.exports = deprecate module.exports = deprecate