Whether this stream is inbound or outbound
Unique identifier for a stream. Identifiers are not unique across muxers.
If no data is transmitted over the stream in this many ms, the stream will be aborted with an InactivityTimeoutError
A logging implementation that can be used to log stream-specific messages
The maximum number of bytes to store when paused. If receipt of more bytes from the remote end of the stream causes the buffer size to exceed this value the stream will be reset and a 'close' event emitted.
This value can be changed at runtime.
OptionalmaxWhen the .send method returns false it means that the underlying resource
has signalled that it's write buffer is full. If the user continues to call
.send, outgoing bytes are stored in an internal buffer until the
underlying resource signals that it can accept more data.
If the size of that internal buffer exceed this value the stream will be reset and a 'close' event emitted.
This value can be changed at runtime.
The protocol negotiated for this stream
Returns the number of bytes that are queued to be read
The status of the readable end of the stream
The status of the readable end of the remote end of the stream - n.b. this requires the underlying stream transport to support sending STOP_SENDING messages or similar.
The status of the writable end of the remote end of the stream
The current status of the message stream
Timestamps of when stream events occurred
If this property is true, the underlying transport has signalled that its
write buffer is full and that .send should not be called again.
A drain event will be emitted after which is its safe to call .send
again to resume sending.
Returns the number of bytes that are queued to be written
The status of the writable end of the stream
Stop accepting new data to send, discard any unsent/unread data, and emit a 'close' event with the 'error' property set to the passed error.
The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
Optionaloptions: boolean | AddEventListenerOptionsClose stream for writing and return a promise that resolves once any pending data has been passed to the underlying transport.
Note that the stream itself will remain readable until the remote end also closes it's writable end.
To close without waiting for the remote, call .abort instead. If you want
to wait for data to be sent first, ensure if the .writableStatus property
is not 'paused', if it is, wait for a drain event before aborting.
Optionaloptions: AbortOptionsSend a message to the remote end of the stream informing them that any incoming data will be discarded so they should stop sending.
This requires the underlying resource to support this operation - for example the QUIC, WebTransport, WebRTC transports do but anything multiplexed using Yamux or Mplex do not.
Optionaloptions: AbortOptionsThe dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
Returns a promise that resolves when the stream can accept new data or rejects if the stream is closed or reset before this occurs.
Optionaloptions: AbortOptionsStop emitting further 'message' events. Any received data will be stored in
an internal buffer. If the buffer size reaches maxReadBufferLength, the
stream will be reset and a StreamAbortEvent emitted.
If the underlying resource supports it, the remote peer will be instructed to pause transmission of further data.
Queue the passed data to be emitted as a 'message' event either during the next tick or sooner if data is received from the underlying resource.
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
Optionallistener: EventHandler<MessageStreamEvents[K]> | nullOptionaloptions: boolean | EventListenerOptionsThe removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
Optionallistener: EventHandler<Event>Optionaloptions: boolean | EventListenerOptionsResume emitting 'message' events.
If the underlying resource supports it, the remote peer will be informed that it is ok to start sending data again.
Optionaldetail: CustomEventInit<Detail>Write data to the stream. If the method returns false it means the internal buffer is now full and the caller should wait for the 'drain' event before sending more data.
This method may throw if:
Similar to the .push method, except this ensures the passed data is
emitted before any other queued data.
A Stream is a lightweight data channel between two peers that can be written to and read from at both ends.
It is half-closable - that is in order for it to be closed fully and any associated memory reclaimed, both ends must close their writeable end of the stream.
It's also possible to close the readable end of the stream, but this depends on the underlying stream muxer supporting this operation which not all do.