rename and fix assoc. test
This commit is contained in:
parent
99d35f7786
commit
dc410efa36
2 changed files with 54 additions and 51 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue