*Change userData logic to throw error if set, but try to always set it
This commit is contained in:
parent
e0178e41ed
commit
98bb74d8b1
6
index.js
6
index.js
|
@ -280,7 +280,11 @@ class Channel {
|
||||||
|
|
||||||
module.exports = class Protomux {
|
module.exports = class Protomux {
|
||||||
constructor(stream, { alloc, slave = false } = {}) {
|
constructor(stream, { alloc, slave = false } = {}) {
|
||||||
if (stream.userData === null) stream.userData = this;
|
if (stream.userData) {
|
||||||
|
throw new Error("Mux already set for this stream");
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.userData = this;
|
||||||
|
|
||||||
this.isProtomux = true;
|
this.isProtomux = true;
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
|
|
Reference in New Issue