# 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.

## Constructor

[ReadableStream()](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)
Creates and returns a readable stream object from the given handlers.

## Instance properties

[ReadableStream.locked](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/locked)
Returns a boolean indicating whether or not the readable stream is locked to a reader.

## Instance methods

[ReadableStream.cancel()](https://developer.mozilla.org/en-US/docs/Web/API/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()](https://developer.mozilla.org/en-US/docs/Web/API/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()](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeThrough)
Provides a chainable way of piping the current stream through a transform stream or any other writable/readable pair.

[ReadableStream.pipeTo()](https://developer.mozilla.org/en-US/docs/Web/API/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()](https://developer.mozilla.org/en-US/docs/Web/API/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.

## Async iteration

ReadableStream implements the [async iterable protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols). This enables asynchronous iteration over the chunks in a stream using the [for await...of](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) syntax.

For more information on [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) visit MDN Web Docs.