websockets/ws ? reverse-engineered prompt

Reverse engineered prompt

Build me a Node.js WebSocket library that’s easy to use, fast, and reliable for both client and server use.

I want it to connect to a WebSocket URL, send and receive text and binary messages, and let me create a WebSocket server that handles connections, broadcasts messages, and works with an existing HTTP or HTTPS server too. It should support the usual WebSocket protocol versions, include optional compression support, and give me a clean API for common things like errors, open, message, and close events.

Please also make it work nicely with Node streams if possible, and include a few simple examples so I can see how to use it right away. It does not need to run in the browser, just Node.js. If you need to look up any current docs or best practices online while building it, go ahead.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab