This is not a polyfill. Do not set this module to window.BroadcastChannel. This implementation behaves similiar to the BroadcastChannel-Standard with these limitations: You can only send data that can be JSON.stringify-ed, While the offical API emits onmessage-events, this module directly emit...
And this is not the only polyfill I have to define. I have this file with me: // jest.polyfills.js const { TextDecoder, TextEncoder } = require("node:util"); const { BroadcastChannel } = require("node:worker_threads"); Object.defineProperties(globalThis, { TextDecoder: { value: ...
To my knowledge, the most popular polyfill is this one. You can use it almost exactly like the BroadcastChannel API. If it detects that the BroadcastChannel API is available it will use it automatically for faster results. Otherwise, it will use IndexedDB or LocalStorage....