ReadableStream
Background
A ReadableStream is returned by the readable property inside TransformStream. On the Workers ecosystem, ReadableStream cannot be created directly using the ReadableStream constructor.
Properties
lockedboolean- A Boolean value that indicates if the readable stream is locked to a reader.
Methods
pipeTo(destinationWritableStream, optionsPipeToOptions):Promise<void>- Pipes the readable stream to a given writable stream
destinationand returns a promise that is fulfilled when thewriteoperation succeeds or rejects it if the operation fails.
- Pipes the readable stream to a given writable stream
getReader(optionsObject):ReadableStreamDefaultReader- Gets an instance of
ReadableStreamDefaultReaderand locks theReadableStreamto that reader instance. This method accepts an object argument indicating options. The only supported option ismode, which can be set tobyobto create aReadableStreamBYOBReader, as shown here:
- Gets an instance of
let reader = readable.getReader({ mode: 'byob' });
PipeToOptions
preventClosebool- When
true, closure of the sourceReadableStreamwill not cause the destinationWritableStreamto be closed.
- When
preventAbortbool- When
true, errors in the sourceReadableStreamwill no longer abort the destinationWritableStream.pipeTowill return a rejected promise with the error from the source or any error that occurred while aborting the destination.
- When