ReadableStream

open class ReadableStream<R : JsAny?>(underlyingSource: UnderlyingByteSource, strategy: QueuingStrategy<R> = definedExternally) : BodyInit, Transferable, AsyncIterable.Mixin<R> , AsyncCloseableDisposable(source)

The ReadableStream interface of the Streams API represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.

MDN Reference

Inheritors

Constructors

Link copied to clipboard
constructor(underlyingSource: UnderlyingByteSource, strategy: QueuingStrategy<R> = definedExternally)
constructor(underlyingSource: UnderlyingDefaultSource<R>, strategy: QueuingStrategy<R> = definedExternally)
constructor(underlyingSource: UnderlyingSource<R> = definedExternally, strategy: QueuingStrategy<R> = definedExternally)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open external val locked: Boolean

The locked read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.

Functions

Link copied to clipboard
inline suspend fun <R : JsAny?> ReadableStream<R>.cancel()
inline suspend fun <R : JsAny?> ReadableStream<R>.cancel(reason: JsError?)

The cancel() method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.

Link copied to clipboard
open external fun cancelAsync(reason: JsError? = definedExternally): Promise<Void>

The cancel() method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.

Link copied to clipboard

The getReader() method of the ReadableStream interface 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.

open external fun getReader(options: ReadableStreamGetReaderOptions = definedExternally): ReadableStreamReader
Link copied to clipboard
open external fun <T : JsAny?> pipeThrough(transform: ReadableWritablePair<T, R>, options: StreamPipeOptions = definedExternally): ReadableStream<T>

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

Link copied to clipboard
suspend fun <R : JsAny?> ReadableStream<R>.pipeTo(destination: WritableStream<R>)
suspend fun <R : JsAny?> ReadableStream<R>.pipeTo(destination: WritableStream<R>, options: StreamPipeOptions)

The pipeTo() method of the ReadableStream interface 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.

Link copied to clipboard
open external fun pipeToAsync(destination: WritableStream<R>, options: StreamPipeOptions = definedExternally): Promise<Void>

The pipeTo() method of the ReadableStream interface 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.

Link copied to clipboard
open external fun tee(): Tuple2<ReadableStream<R>, ReadableStream<R>>

The tee() method of the ReadableStream interface tees the current readable stream, returning a two-element array containing the two resulting branches as new ReadableStream instances.

Link copied to clipboard
open external fun values(options: ReadableStreamIteratorOptions = definedExternally): AsyncIterator<R>