ReadableStreamBYOBRequest extension type
The ReadableStreamBYOBRequest
interface of the
Streams API
represents a "pull request" for data from an underlying source that will
made as a zero-copy transfer to a consumer (bypassing the stream's internal
queues).
ReadableStreamBYOBRequest
objects are created in "BYOB mode" when a
consumer makes a request for data and the stream's internal queue is
empty.
(The stream will resolve the consumer's request directly if it already has
buffered data).
An underlying byte source can access active BYOB requests through its
controller's ReadableByteStreamController.byobRequest property, which will
be set to null
if there is no outstanding request.
An underlying source that supports "BYOB mode" should check for
ReadableByteStreamController.byobRequest and must use it for transferring
data, if present.
If data arrives from the underlying source when
ReadableByteStreamController.byobRequest is null
, it can be queued using
ReadableByteStreamController.enqueue.
This might happen when an underlying push source receives new data when the
stream's internal buffers are not empty.
An underlying source uses the request by writing data to the BYOB request's
view
and then calling
respond()
, or by calling
respondWithNewView()
and
passing a new view as an argument.
Note that the "new view" must actually be a view over the same buffer as
the original view
, starting at the same offset.
This might be used to return a shorter buffer if the underlying source is
unable to fill the entire original view.
Note that a ReadableByteStreamController is only created for underlying
sources when type="bytes"
is specified for the source in the
ReadableStream()
constructor.
"BYOB mode" is enabled when either
autoAllocateChunkSize
is specified in the ReadableController()
constructor
or when using a ReadableStreamBYOBReader (typically constructed by calling
ReadableStream.getReader with the argument { mode: 'byob' }
).
API documentation sourced from MDN Web Docs.
- on
- Implemented types
- Available extensions
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- view → ArrayBufferView?
-
The
view
getter property of the ReadableStreamBYOBRequest interface returns the current view.no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
respond(
int bytesWritten) → void -
The
respond()
method of the ReadableStreamBYOBRequest interface is used to signal to the associated readable byte stream that the specified number of bytes were written into the ReadableStreamBYOBRequest.view. -
respondWithNewView(
ArrayBufferView view) → void -
The
respondWithNewView()
method of the ReadableStreamBYOBRequest interface specifies a new view that the consumer of the associated readable byte stream should write to instead of ReadableStreamBYOBRequest.view. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited