peers/peerjs ? reverse-engineered prompt

Reverse engineered prompt

Build me a small TypeScript library for browser peer to peer connections using WebRTC, something like PeerJS.

I want a simple API where I can create a peer with an id or let it get one automatically, connect to another peer, send messages over a data channel, and make or answer audio and video calls with media streams. It should feel easy to use in a normal web app, with clean event based callbacks for things like connection open, incoming data, and remote streams.

Please include a basic README with example usage, and make it work well in modern browsers like Chrome, Firefox, Edge, and Safari. If you need to look up current docs online for WebRTC details, go ahead. Also add tests so I can verify the main connection behavior still works.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab