Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
for (const listener of listeners) {
if (listener.name !== name) {
continue;
}
if (win && listener.options.window && listener.options.window !== win) {
continue;
}
if (domain && listener.options.domain && listener.options.domain !== domain) {
continue;
}
return ZalgoPromise.try(() => listener.handler({ source: win, origin: domain, data }))
.then(res => {
if (listener.promise) {
listener.promise.resolve(res || data);
}
return res;
}, err => {
if (listener.promise) {
listener.promise.reject(err);
}
throw err;
});
}
throw new Error(`No postRobot handler found for message name: ${ name }`);
};