Type Parameters
- TStream extends Duplex | NodeDuplex = Duplex
Constructors
constructor
- new Protomux<TStream>(stream): Protomux<TStream>
Type Parameters
- TStream extends Duplex | Duplex<any, any, any, any, true, true, DuplexEvents<any, any>> = Duplex<any, any, any, any, true, true, DuplexEvents<any, any>>
Properties
isProtomux
isProtomux: true
Methods
[iterator]
- [iterator](): IterableIterator<Channel, any, any>
Returns IterableIterator<Channel, any, any>
createChannel
- createChannel(opts): Channel
Parameters
- opts: {
aliases?: string[];
handshake?: any;
id?: null | Buffer;
messages: Partial<Pick<Message, "onmessage" | "encoding">>[];
protocol: string;
unique?: boolean;
userData?: any;
onclose?(): void | Promise<void>;
ondestroy?(): void | Promise<void>;
onopen?(handshake?: any): void | Promise<void>;
}Optional
aliases?: string[]
Optional
handshake?: any
Optional
id?: null | Buffer
messages: Partial<Pick<Message, "onmessage" | "encoding">>[]
protocol: string
Optional
unique?: boolean
Optional
userData?: any
onclose?:function
- onclose(): void | Promise<void>
Returns void | Promise<void>
ondestroy?:function
- ondestroy(): void | Promise<void>
Returns void | Promise<void>
onopen?:function
- onopen(handshake?): void | Promise<void>
Returns void | Promise<void>
destroy
- destroy(err): void
Returns void
opened
- opened(opts): boolean
Parameters
- opts: {
id?: null | Buffer;
protocol: string;
}Optional
id?: null | Buffer
protocol: string
Returns boolean
pair
- pair(opts, notify): void
Parameters
- opts: {
id?: null | Buffer;
protocol: string;
}Optional
id?: null | Buffer
protocol: string
- notify: ((id: Buffer) => Promise<void>)
- (id): Promise<void>
Returns Promise<void>
Returns void
uncork
- uncork(): void
Returns void
unpair
- unpair(opts): void
Parameters
- opts: {
id?: null | Buffer;
protocol: string;
}Optional
id?: null | Buffer
protocol: string
Returns void
Static
isProtomux
- isProtomux(mux): mux is Protomux<Duplex<any, any, any, any, true, true, DuplexEvents<any, any>>>
Returns mux is Protomux<Duplex<any, any, any, any, true, true, DuplexEvents<any, any>>>