Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export
function setExceptionHandler(handler: ExceptionHandler): ExceptionHandler {
let old = exceptionHandler;
exceptionHandler = handler;
return old;
}
/**
* A type alias for a posted message pair.
*/
type PostedMessage = { handler: IMessageHandler | null, msg: Message | null };
/**
* The queue of posted message pairs.
*/
const messageQueue = new LinkedList();
/**
* A mapping of handler to array of installed message hooks.
*/
const messageHooks = new WeakMap>();
/**
* A set of message hook arrays which are pending cleanup.
*/
const dirtySet = new Set>();
/**
* The message loop exception handler.
*/
let exceptionHandler: ExceptionHandler = (err: Error) => {
console.error(err);