ReadableStreamBYOBReader extension type

The ReadableStreamBYOBReader interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source. It is used for efficient copying from underlying sources where the data is delivered as an "anonymous" sequence of bytes, such as files.

An instance of this reader type should usually be obtained by calling ReadableStream.getReader on the stream, specifying mode: "byob" in the options parameter. The readable stream must have an underlying byte source. In other words, it must have been constructed specifying an underlying source with type: "bytes").

Using this kind of reader, a read() request when the readable stream's internal queues are empty will result in a zero copy transfer from the underlying source (bypassing the stream's internal queues). If the internal queues are not empty, a read() will satisfy the request from the buffered data.

Note that the methods and properties are similar to those for the default reader (ReadableStreamDefaultReader). The read() method differs in that it provide a view into which data should be written.

on
Implemented types

Constructors

ReadableStreamBYOBReader(ReadableStream stream)
factory

Properties

closed JSPromise<JSAny?>
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancel([JSAny? reason]) JSPromise<JSAny?>
The cancel() method of the ReadableStreamBYOBReader interface returns a Promise that resolves when the stream is canceled. Calling this method signals a loss of interest in the stream by a consumer.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(ArrayBufferView view, [ReadableStreamBYOBReaderReadOptions options]) JSPromise<ReadableStreamReadResult>
The read() method of the ReadableStreamBYOBReader interface is used to read data into a view on a user-supplied buffer from an associated readable byte stream. A request for data will be satisfied from the stream's internal queues if there is any data present. If the stream queues are empty, the request may be supplied as a zero-copy transfer from the underlying byte source.
releaseLock() → void
The releaseLock() method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream. After the lock is released, the reader is no longer active.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited