From 7904be8763a8bd576a021b0571e34ece3923aa49 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 20 Nov 2017 15:12:34 +0100 Subject: [PATCH] comment out unused methods --- lib/common/api/deprecate.js | 95 ++++++++++++++++++----------------- spec/api-deprecations-spec.js | 14 +----- 2 files changed, 49 insertions(+), 60 deletions(-) diff --git a/lib/common/api/deprecate.js b/lib/common/api/deprecate.js index 9c0e39c3a421..fb156c65c1b0 100644 --- a/lib/common/api/deprecate.js +++ b/lib/common/api/deprecate.js @@ -10,9 +10,7 @@ const deprecate = function (oldName, newName, fn) { } } -// The method is renamed. -// nota bene: newName should already exist and -// oldName is being injected for compatibility with old code +// The method is aliases and the old method is retained for backwards compat deprecate.alias = function (object, deprecatedName, existingName) { let warned = false 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) => { return deprecate.log(`'${oldName}' is deprecated. Use '${newName}' instead.`) } @@ -98,4 +52,51 @@ deprecate.setHandler = (handler) => { 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 diff --git a/spec/api-deprecations-spec.js b/spec/api-deprecations-spec.js index 7a32c7a89459..9f30efed3dca 100644 --- a/spec/api-deprecations-spec.js +++ b/spec/api-deprecations-spec.js @@ -1,7 +1,7 @@ const assert = require('assert') const {deprecations, deprecate, nativeImage} = require('electron') -describe.only('deprecations', () => { +describe('deprecations', () => { beforeEach(() => { deprecations.setHandler(null) process.throwDeprecation = true @@ -54,16 +54,4 @@ describe.only('deprecations', () => { deprecate.log('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) - // }) })