@hyperfrontend/immutable-api-utils/built-in-copy/websocketwebsocket
Locked, prototype-pollution-resistant copy of the global WebSocket constructor.
A factory wrapping WebSocket is captured at module-load time and frozen into a tamper-proof namespace, so socket construction stays trustworthy even if the global is later patched. Effective only when imported before any untrusted code has had a chance to mutate the prototype chain.
API Reference
ƒ Functions
(Safe copy) Creates a new WebSocket using the captured WebSocket constructor. Use this instead of
new WebSocket().Parameters
Returns
WebSocketA new WebSocket instance.
Example
Creating WebSocket connection
const socket = createWebSocket('wss://api.example.com/stream')
socket.onmessage = (event) => console.log(event.data)