comment out unused methods
This commit is contained in:
parent
dc410efa36
commit
7904be8763
2 changed files with 49 additions and 60 deletions
|
@ -10,9 +10,7 @@ const deprecate = function (oldName, newName, fn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The method is renamed.
|
// The method is aliases and the old method is retained for backwards compat
|
||||||
// nota bene: newName should already exist and
|
|
||||||
// oldName is being injected for compatibility with old code
|
|
||||||
deprecate.alias = function (object, deprecatedName, existingName) {
|
deprecate.alias = function (object, deprecatedName, existingName) {
|
||||||
let warned = false
|
let warned = false
|
||||||
const newMethod = function () {
|
const newMethod = function () {
|
||||||
|
@ -29,50 +27,6 @@ deprecate.alias = function (object, deprecatedName, existingName) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forward the method to member.
|
|
||||||
deprecate.member = (object, method, member) => {
|
|
||||||
let warned = false
|
|
||||||
object.prototype[method] = function () {
|
|
||||||
if (!(warned || process.noDeprecation)) {
|
|
||||||
warned = true
|
|
||||||
deprecate.warn(method, `${member}.${method}`)
|
|
||||||
}
|
|
||||||
return this[member][method].apply(this[member], arguments)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecate a property.
|
|
||||||
deprecate.property = (object, property, method) => {
|
|
||||||
return Object.defineProperty(object, property, {
|
|
||||||
get: function () {
|
|
||||||
let warned = false
|
|
||||||
if (!(warned || process.noDeprecation)) {
|
|
||||||
warned = true
|
|
||||||
deprecate.warn(`${property} property`, `${method} method`)
|
|
||||||
}
|
|
||||||
return this[method]()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deprecate an event.
|
|
||||||
deprecate.event = (emitter, oldName, newName, fn) => {
|
|
||||||
let warned = false
|
|
||||||
return emitter.on(newName, function (...args) {
|
|
||||||
if (this.listenerCount(oldName) > 0) {
|
|
||||||
if (!(warned || process.noDeprecation)) {
|
|
||||||
warned = true
|
|
||||||
deprecate.warn(`'${oldName}' event`, `'${newName}' event`)
|
|
||||||
}
|
|
||||||
if (fn != null) {
|
|
||||||
fn.apply(this, arguments)
|
|
||||||
} else {
|
|
||||||
this.emit.apply(this, [oldName].concat(args))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
deprecate.warn = (oldName, newName) => {
|
deprecate.warn = (oldName, newName) => {
|
||||||
return deprecate.log(`'${oldName}' is deprecated. Use '${newName}' instead.`)
|
return deprecate.log(`'${oldName}' is deprecated. Use '${newName}' instead.`)
|
||||||
}
|
}
|
||||||
|
@ -98,4 +52,51 @@ deprecate.setHandler = (handler) => {
|
||||||
|
|
||||||
deprecate.getHandler = () => deprecationHandler
|
deprecate.getHandler = () => deprecationHandler
|
||||||
|
|
||||||
|
// None of the below methods are used, and so will be commented
|
||||||
|
// out until such time that they are needed to be used and tested.
|
||||||
|
|
||||||
|
// // Forward the method to member.
|
||||||
|
// deprecate.member = (object, method, member) => {
|
||||||
|
// let warned = false
|
||||||
|
// object.prototype[method] = function () {
|
||||||
|
// if (!(warned || process.noDeprecation)) {
|
||||||
|
// warned = true
|
||||||
|
// deprecate.warn(method, `${member}.${method}`)
|
||||||
|
// }
|
||||||
|
// return this[member][method].apply(this[member], arguments)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Deprecate a property.
|
||||||
|
// deprecate.property = (object, property, method) => {
|
||||||
|
// return Object.defineProperty(object, property, {
|
||||||
|
// get: function () {
|
||||||
|
// let warned = false
|
||||||
|
// if (!(warned || process.noDeprecation)) {
|
||||||
|
// warned = true
|
||||||
|
// deprecate.warn(`${property} property`, `${method} method`)
|
||||||
|
// }
|
||||||
|
// return this[method]()
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Deprecate an event.
|
||||||
|
// deprecate.event = (emitter, oldName, newName, fn) => {
|
||||||
|
// let warned = false
|
||||||
|
// return emitter.on(newName, function (...args) {
|
||||||
|
// if (this.listenerCount(oldName) > 0) {
|
||||||
|
// if (!(warned || process.noDeprecation)) {
|
||||||
|
// warned = true
|
||||||
|
// deprecate.warn(`'${oldName}' event`, `'${newName}' event`)
|
||||||
|
// }
|
||||||
|
// if (fn != null) {
|
||||||
|
// fn.apply(this, arguments)
|
||||||
|
// } else {
|
||||||
|
// this.emit.apply(this, [oldName].concat(args))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
||||||
module.exports = deprecate
|
module.exports = deprecate
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const {deprecations, deprecate, nativeImage} = require('electron')
|
const {deprecations, deprecate, nativeImage} = require('electron')
|
||||||
|
|
||||||
describe.only('deprecations', () => {
|
describe('deprecations', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
deprecations.setHandler(null)
|
deprecations.setHandler(null)
|
||||||
process.throwDeprecation = true
|
process.throwDeprecation = true
|
||||||
|
@ -54,16 +54,4 @@ describe.only('deprecations', () => {
|
||||||
deprecate.log('this is deprecated')
|
deprecate.log('this is deprecated')
|
||||||
}, /this is deprecated/)
|
}, /this is deprecated/)
|
||||||
})
|
})
|
||||||
|
|
||||||
// it('deprecates a property', () => {
|
|
||||||
// deprecate.property(object, property, method)
|
|
||||||
// })
|
|
||||||
//
|
|
||||||
// it('deprecates an event', () => {
|
|
||||||
// deprecate.event(emitter, oldName, newName, fn)
|
|
||||||
// })
|
|
||||||
//
|
|
||||||
// it('forwards a method to member', () => {
|
|
||||||
// deprecate.member(object, method, member)
|
|
||||||
// })
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue