Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#### Simple WebRTC video, voice, and data channels

This package is a more up to date version of feross's simple-peer, it does away with node:stream and node:buffer in favor of streamx and Uint8Array, making the module a lot smaller, additionally it provides `@thaunknown/simple-peer/lite.js` which is the same peer implementation, but without MediaTrack and MediaStream handling, just pure Uint8/String data.
This package is a more up to date version of feross's simple-peer, it uses `EventEmitter` and `Uint8Array` instead of node streams and buffers, making the module lighter and fully compatible with browser bundlers like Vite. It provides `@thaunknown/simple-peer/lite.js` which is the same peer implementation, but without MediaTrack and MediaStream handling, just pure Uint8/String data.

It's fully backwards compatible with feross's version.
> **Breaking change:** This version no longer extends `Duplex` stream. The `pipe()` method is not available. Use `peer.on('data', ...)` and `peer.send()` / `peer.write()` instead.
Comment on lines +14 to +16
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation states "It's fully backwards compatible with feross's version" is being replaced, but the new statement doesn't accurately reflect the breaking changes. The note about the breaking change is good, but consider removing or updating the claim about being "more up to date version" since this is a breaking change that removes stream compatibility entirely. Consider being more explicit that this is a major breaking change from the original simple-peer.

Copilot uses AI. Check for mistakes.

## features

Expand All @@ -22,7 +22,7 @@ It's fully backwards compatible with feross's version.
- supports **video/voice streams**
- supports **data channel**
- text and binary data
- node.js [duplex stream](http://nodejs.org/api/stream.html) interface
- event-based API with `on('data')`, `send()`, and `write()`
- supports advanced options like:
- enable/disable [trickle ICE candidates](http://webrtchacks.com/trickle-ice/)
- manually set config options
Expand Down Expand Up @@ -318,7 +318,7 @@ Send text/binary data to the remote peer. `data` can be any of several types: `S
`Buffer` (see [buffer](https://github.com/feross/buffer)), `ArrayBufferView` (`Uint8Array`,
etc.), `ArrayBuffer`, or `Blob` (in browsers that support it).

Note: If this method is called before the `peer.on('connect')` event has fired, then an exception will be thrown. Use `peer.write(data)` (which is inherited from the node.js [duplex stream](http://nodejs.org/api/stream.html) interface) if you want this data to be buffered instead.
Note: If this method is called before the `peer.on('connect')` event has fired, then an exception will be thrown. Use `peer.write(data)` if you want this data to be buffered instead.

### `peer.addStream(stream)`

Expand Down Expand Up @@ -365,11 +365,9 @@ if (Peer.WEBRTC_SUPPORT) {
}
```

### duplex stream
### data channel API

`Peer` objects are instances of `stream.Duplex`. They behave very similarly to a
`net.Socket` from the node core `net` module. The duplex stream reads/writes to the data
channel.
`Peer` objects extend `EventEmitter` and provide a simple API for sending and receiving data.

```js
var peer = new Peer(opts)
Expand All @@ -380,6 +378,8 @@ peer.on('data', function (chunk) {
})
```

> **Note:** The `pipe()` method is no longer supported. Use `peer.on('data', ...)` to receive data and `peer.send()` / `peer.write()` to send data.

## events

`Peer` objects are instance of `EventEmitter`. Take a look at the [nodejs events documentation](https://nodejs.org/api/events.html) for more information.
Expand Down Expand Up @@ -581,10 +581,9 @@ and sending the buffer at some later point in time. We immediately call
`channel.send()` on the data channel. So it should be fine to mutate the buffer
right afterward.

However, beware that `peer.write(buf)` (a writable stream method) does not have
the same contract. It will potentially buffer the data and call
`channel.send()` at a future point in time, so definitely don't assume it's
safe to mutate the buffer.
However, beware that `peer.write(buf)` does not have the same contract. It will
potentially buffer the data and call `channel.send()` at a future point in time,
so definitely don't assume it's safe to mutate the buffer.


## connection does not work on some networks?
Expand Down
2 changes: 0 additions & 2 deletions full.js

This file was deleted.

42 changes: 0 additions & 42 deletions index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion index.d.ts.map

This file was deleted.

1 change: 0 additions & 1 deletion index.js.map

This file was deleted.

156 changes: 0 additions & 156 deletions lite.d.ts

This file was deleted.

Loading