ReadableStream.getReader()
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.
Syntax
getReader()
getReader(options)
Parameters
optionsoptional: An object containing the following properties:
modeoptional: A property that specifies the type of reader to create. Values can be:
"byob", which results in aReadableStreamBYOBReaderbeing created that can read readable byte streams (streams that support zero-copy transfer from an underlying byte source to the reader when internal stream buffers are empty).undefined(or not specified at all — this is the default), which results in aReadableStreamDefaultReaderbeing created that can read individual chunks from a stream.
Return value
A ReadableStreamDefaultReader or ReadableStreamBYOBReader object instance, depending on the mode value.
Exceptions
RangeError- : Thrown if the provided mode value is not
"byob"orundefined.
- : Thrown if the provided mode value is not
TypeError- : Thrown if the stream you are trying to create a reader for is already locked, or not a
ReadableStream.
- : Thrown if the stream you are trying to create a reader for is already locked, or not a