replace isEventEmitter with instanceof EventEmitter (rpc-server) (#12998)

This commit is contained in:
Milan Burda 2018-05-21 03:00:56 +02:00 committed by Cheng Zhao
parent 8b2bffcf9e
commit 7c19ae302e

View file

@ -147,17 +147,11 @@ const throwRPCError = function (message) {
throw error
}
const isEventEmitter = (object) => {
if (!object) return false
const prototype = Object.getPrototypeOf(object)
return prototype === EventEmitter.prototype || isEventEmitter(prototype)
}
const removeRemoteListenersAndLogWarning = (sender, meta, callIntoRenderer) => {
let message = `Attempting to call a function in a renderer window that has been closed or released.` +
`\nFunction provided here: ${meta.location}`
if (isEventEmitter(sender)) {
if (sender instanceof EventEmitter) {
const remoteEvents = sender.eventNames().filter((eventName) => {
return sender.listeners(eventName).includes(callIntoRenderer)
})