Use spread syntax instead of apply
This commit is contained in:
parent
b61e1fd69f
commit
af555bd879
2 changed files with 9 additions and 7 deletions
|
@ -1,14 +1,16 @@
|
||||||
const EventEmitter = require('events').EventEmitter
|
const EventEmitter = require('events').EventEmitter
|
||||||
|
|
||||||
module.exports = new EventEmitter()
|
const emitter = new EventEmitter()
|
||||||
|
|
||||||
const removeAllListeners = module.exports.removeAllListeners
|
const removeAllListeners = emitter.removeAllListeners.bind(emitter)
|
||||||
module.exports.removeAllListeners = function (...args) {
|
emitter.removeAllListeners = function (...args) {
|
||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
throw new Error('Removing all listeners from ipcMain will make Electron internals stop working. Please specify a event name')
|
throw new Error('Removing all listeners from ipcMain will make Electron internals stop working. Please specify a event name')
|
||||||
}
|
}
|
||||||
removeAllListeners.apply(this, args)
|
removeAllListeners(...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not throw exception when channel name is "error".
|
// Do not throw exception when channel name is "error".
|
||||||
module.exports.on('error', () => {})
|
emitter.on('error', () => {})
|
||||||
|
|
||||||
|
module.exports = emitter
|
||||||
|
|
|
@ -30,11 +30,11 @@ module.exports = function (ipcRenderer, binding) {
|
||||||
ipcRenderer.send('ELECTRON_BROWSER_SEND_TO', true, webContentsId, channel, ...args)
|
ipcRenderer.send('ELECTRON_BROWSER_SEND_TO', true, webContentsId, channel, ...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeAllListeners = ipcRenderer.removeAllListeners
|
const removeAllListeners = ipcRenderer.removeAllListeners.bind(ipcRenderer)
|
||||||
ipcRenderer.removeAllListeners = function (...args) {
|
ipcRenderer.removeAllListeners = function (...args) {
|
||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
throw new Error('Removing all listeners from ipcRenderer will make Electron internals stop working. Please specify a event name')
|
throw new Error('Removing all listeners from ipcRenderer will make Electron internals stop working. Please specify a event name')
|
||||||
}
|
}
|
||||||
removeAllListeners.apply(this, args)
|
removeAllListeners(...args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue