ReadableStream

The ReadableStream interface is a feature of the Streams API that allows the reading of streams of byte data. The Fetch API provides a specific instance of a ReadableStream that can be accessed through the “body” property of a Response object.

ReadableStream() Creates and returns a readable stream object from the given handlers.

ReadableStream.locked Returns a boolean indicating whether or not the readable stream is locked to a reader.

ReadableStream.cancel() Returns a Promise that resolves when the stream is canceled. Calling this method signals a loss of interest in the stream by a consumer. The supplied reason argument will be given to the underlying source, which may or may not use it.

ReadableStream.getReader() Creates a reader and locks the stream to it. While the stream is locked, no other reader can be acquired until this one is released.

ReadableStream.pipeThrough() Provides a chainable way of piping the current stream through a transform stream or any other writable/readable pair.

ReadableStream.pipeTo() Pipes the current ReadableStream to a given WritableStream and returns a Promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.

ReadableStream.tee() The tee method tees this readable stream, returning a two-element array containing the two resulting branches as new ReadableStream instances. Each of those streams receives the same incoming data.

ReadableStream implements the async iterable protocol. This enables asynchronous iteration over the chunks in a stream using the for await…of syntax.

For more information on ReadableStream visit MDN Web Docs.


Contributors