diff --git a/lib/common/api/deprecate.js b/lib/common/api/deprecate.js index 16bf71b3f807..f272915167fe 100644 --- a/lib/common/api/deprecate.js +++ b/lib/common/api/deprecate.js @@ -1,108 +1,108 @@ // Deprecate a method. -const deprecate = function(oldName, newName, fn) { - var warned; - warned = false; - return function() { +const deprecate = function (oldName, newName, fn) { + var warned + warned = false + return function () { if (!(warned || process.noDeprecation)) { - warned = true; - deprecate.warn(oldName, newName); + warned = true + deprecate.warn(oldName, newName) } - return fn.apply(this, arguments); - }; -}; + return fn.apply(this, arguments) + } +} // The method is renamed. -deprecate.rename = function(object, oldName, newName) { - var newMethod, warned; - warned = false; - newMethod = function() { +deprecate.rename = function (object, oldName, newName) { + var newMethod, warned + warned = false + newMethod = function () { if (!(warned || process.noDeprecation)) { - warned = true; - deprecate.warn(oldName, newName); + warned = true + deprecate.warn(oldName, newName) } - return this[newName].apply(this, arguments); - }; - if (typeof object === 'function') { - return object.prototype[oldName] = newMethod; - } else { - return object[oldName] = newMethod; + return this[newName].apply(this, arguments) } -}; + if (typeof object === 'function') { + return object.prototype[oldName] = newMethod + } else { + return object[oldName] = newMethod + } +} // Forward the method to member. -deprecate.member = function(object, method, member) { - var warned; - warned = false; - return object.prototype[method] = function() { +deprecate.member = function (object, method, member) { + var warned + warned = false + return object.prototype[method] = function () { if (!(warned || process.noDeprecation)) { - warned = true; - deprecate.warn(method, member + "." + method); + warned = true + deprecate.warn(method, member + '.' + method) } - return this[member][method].apply(this[member], arguments); - }; -}; + return this[member][method].apply(this[member], arguments) + } +} // Deprecate a property. -deprecate.property = function(object, property, method) { +deprecate.property = function (object, property, method) { return Object.defineProperty(object, property, { - get: function() { - var warned; - warned = false; + get: function () { + var warned + warned = false if (!(warned || process.noDeprecation)) { - warned = true; - deprecate.warn(property + " property", method + " method"); + warned = true + deprecate.warn(property + ' property', method + ' method') } - return this[method](); + return this[method]() } - }); -}; + }) +} // Deprecate an event. -deprecate.event = function(emitter, oldName, newName, fn) { - var warned; - warned = false; - return emitter.on(newName, function(...args) { +deprecate.event = function (emitter, oldName, newName, fn) { + var warned + warned = false + return emitter.on(newName, function (...args) { // there is listeners for old API. if (this.listenerCount(oldName) > 0) { if (!(warned || process.noDeprecation)) { - warned = true; - deprecate.warn("'" + oldName + "' event", "'" + newName + "' event"); + warned = true + deprecate.warn("'" + oldName + "' event", "'" + newName + "' event") } if (fn != null) { - return fn.apply(this, arguments); + return fn.apply(this, arguments) } else { - return this.emit.apply(this, [oldName].concat(args)); + return this.emit.apply(this, [oldName].concat(args)) } } - }); -}; + }) +} // Print deprecation warning. -deprecate.warn = function(oldName, newName) { - return deprecate.log(oldName + " is deprecated. Use " + newName + " instead."); -}; +deprecate.warn = function (oldName, newName) { + return deprecate.log(oldName + ' is deprecated. Use ' + newName + ' instead.') +} -var deprecationHandler = null; +var deprecationHandler = null // Print deprecation message. -deprecate.log = function(message) { +deprecate.log = function (message) { if (typeof deprecationHandler === 'function') { - deprecationHandler(message); + deprecationHandler(message) } else if (process.throwDeprecation) { - throw new Error(message); + throw new Error(message) } else if (process.traceDeprecation) { - return console.trace(message); + return console.trace(message) } else { - return console.warn("(electron) " + message); + return console.warn('(electron) ' + message) } -}; +} -deprecate.setHandler = function(handler) { - deprecationHandler = handler; -}; +deprecate.setHandler = function (handler) { + deprecationHandler = handler +} -deprecate.getHandler = function() { - return deprecationHandler; -}; +deprecate.getHandler = function () { + return deprecationHandler +} -module.exports = deprecate; +module.exports = deprecate diff --git a/lib/common/api/deprecations.js b/lib/common/api/deprecations.js index e4290c749474..f4c4d74d6b92 100644 --- a/lib/common/api/deprecations.js +++ b/lib/common/api/deprecations.js @@ -1,11 +1,11 @@ -'use strict'; +'use strict' -const deprecate = require('electron').deprecate; +const deprecate = require('electron').deprecate exports.setHandler = function (deprecationHandler) { - deprecate.setHandler(deprecationHandler); -}; + deprecate.setHandler(deprecationHandler) +} exports.getHandler = function () { - return deprecate.getHandler(); -}; + return deprecate.getHandler() +} diff --git a/lib/common/api/exports/electron.js b/lib/common/api/exports/electron.js index 51ab48ded833..3bef1f0c50f6 100644 --- a/lib/common/api/exports/electron.js +++ b/lib/common/api/exports/electron.js @@ -1,15 +1,14 @@ // Do not expose the internal modules to `require`. -const hideInternalModules = function() { - var globalPaths = require('module').globalPaths; +const hideInternalModules = function () { + var globalPaths = require('module').globalPaths if (globalPaths.length === 3) { - // Remove the "common/api/lib" and "browser-or-renderer/api/lib". - return globalPaths.splice(0, 2); + return globalPaths.splice(0, 2) } -}; +} // Attaches properties to |exports|. -exports.defineProperties = function(exports) { +exports.defineProperties = function (exports) { return Object.defineProperties(exports, { hideInternalModules: { enumerable: true, @@ -18,48 +17,47 @@ exports.defineProperties = function(exports) { // Common modules, please sort with alphabet order. clipboard: { - // Must be enumerable, otherwise it woulde be invisible to remote module. enumerable: true, - get: function() { - return require('../clipboard'); + get: function () { + return require('../clipboard') } }, crashReporter: { enumerable: true, - get: function() { - return require('../crash-reporter'); + get: function () { + return require('../crash-reporter') } }, deprecations: { enumerable: true, - get: function() { - return require('../deprecations'); + get: function () { + return require('../deprecations') } }, nativeImage: { enumerable: true, - get: function() { - return require('../native-image'); + get: function () { + return require('../native-image') } }, shell: { enumerable: true, - get: function() { - return require('../shell'); + get: function () { + return require('../shell') } }, // The internal modules, invisible unless you know their names. CallbacksRegistry: { - get: function() { - return require('../callbacks-registry'); + get: function () { + return require('../callbacks-registry') } }, deprecate: { - get: function() { - return require('../deprecate'); + get: function () { + return require('../deprecate') } } - }); -}; + }) +} diff --git a/lib/common/api/native-image.js b/lib/common/api/native-image.js index 6f9a9bd7d542..ebb06138210e 100644 --- a/lib/common/api/native-image.js +++ b/lib/common/api/native-image.js @@ -1,7 +1,7 @@ -const deprecate = require('electron').deprecate; -const nativeImage = process.atomBinding('native_image'); +const deprecate = require('electron').deprecate +const nativeImage = process.atomBinding('native_image') // Deprecated. -deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL'); +deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL') -module.exports = nativeImage; +module.exports = nativeImage diff --git a/lib/common/api/shell.js b/lib/common/api/shell.js index 08cc4e8eb41c..78e2a0938ba0 100644 --- a/lib/common/api/shell.js +++ b/lib/common/api/shell.js @@ -1 +1 @@ -module.exports = process.atomBinding('shell'); +module.exports = process.atomBinding('shell')