rename and fix assoc. test

This commit is contained in:
Shelley Vohr 2017-11-14 14:56:16 -05:00
parent 99d35f7786
commit dc410efa36
No known key found for this signature in database
GPG key ID: F13993A75599653C
2 changed files with 54 additions and 51 deletions

View file

@ -11,20 +11,21 @@ const deprecate = function (oldName, newName, fn) {
}
// The method is renamed.
deprecate.rename = (object, oldName, newName) => {
console.log('we are here')
// nota bene: newName should already exist and
// oldName is being injected for compatibility with old code
deprecate.alias = function (object, deprecatedName, existingName) {
let warned = false
const newMethod = function () {
if (!(warned || process.noDeprecation)) {
warned = true
deprecate.warn(oldName, newName)
deprecate.warn(deprecatedName, existingName)
}
return this[newName].apply(this, arguments)
return this[existingName].apply(this, arguments)
}
if (typeof object === 'function') {
object.prototype[oldName] = newMethod
object.prototype[deprecatedName] = newMethod
} else {
object[oldName] = newMethod
object[deprecatedName] = newMethod
}
}