You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Completely removing streamx support (and the .pipe method at the same time)
This will allow easier bundling in both environments (Node + Browser), since streamx is not browser native.
Copy file name to clipboardExpand all lines: README.md
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,9 @@
11
11
12
12
#### Simple WebRTC video, voice, and data channels
13
13
14
-
This package is a more up to date version of feross's simple-peer, it does away with node:streamand 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.
14
+
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.
15
15
16
-
It's fully backwards compatible with feross's version.
16
+
> **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.
@@ -318,7 +318,7 @@ Send text/binary data to the remote peer. `data` can be any of several types: `S
318
318
`Buffer` (see [buffer](https://github.com/feross/buffer)), `ArrayBufferView` (`Uint8Array`,
319
319
etc.), `ArrayBuffer`, or `Blob` (in browsers that support it).
320
320
321
-
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.
321
+
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.
322
322
323
323
### `peer.addStream(stream)`
324
324
@@ -365,11 +365,9 @@ if (Peer.WEBRTC_SUPPORT) {
365
365
}
366
366
```
367
367
368
-
### duplex stream
368
+
### data channel API
369
369
370
-
`Peer` objects are instances of `stream.Duplex`. They behave very similarly to a
371
-
`net.Socket` from the node core `net` module. The duplex stream reads/writes to the data
372
-
channel.
370
+
`Peer` objects extend `EventEmitter` and provide a simple API for sending and receiving data.
373
371
374
372
```js
375
373
var peer =newPeer(opts)
@@ -380,6 +378,8 @@ peer.on('data', function (chunk) {
380
378
})
381
379
```
382
380
381
+
> **Note:** The `pipe()` method is no longer supported. Use `peer.on('data', ...)` to receive data and `peer.send()` / `peer.write()` to send data.
382
+
383
383
## events
384
384
385
385
`Peer` objects are instance of `EventEmitter`. Take a look at the [nodejs events documentation](https://nodejs.org/api/events.html) for more information.
@@ -581,10 +581,9 @@ and sending the buffer at some later point in time. We immediately call
581
581
`channel.send()` on the data channel. So it should be fine to mutate the buffer
582
582
right afterward.
583
583
584
-
However, beware that `peer.write(buf)` (a writable stream method) does not have
585
-
the same contract. It will potentially buffer the data and call
586
-
`channel.send()` at a future point in time, so definitely don't assume it's
587
-
safe to mutate the buffer.
584
+
However, beware that `peer.write(buf)` does not have the same contract. It will
585
+
potentially buffer the data and call `channel.send()` at a future point in time,
586
+
so definitely don't assume it's safe to mutate the buffer.
0 commit comments