Class ReadableStreamDefaultReader
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The ReadableStreamDefaultReader interface of the Streams API represents a default reader that can be used to read stream data supplied from a network (such as a fetch request).
[Value("ReadableStreamDefaultReader")]
public class ReadableStreamDefaultReader
- Inheritance
-
ReadableStreamDefaultReader
- Inherited Members
Remarks
A ReadableStreamDefaultReader can be used to read from a ReadableStream that has an underlying source of any type (unlike a ReadableStreamBYOBReader, which can only be used with readable streams that have an underlying byte source).
Note however that zero-copy transfer from an underlying source is only supported for underlying byte sources that autoallocate buffers.
In other words, the stream must have been constructed specifying both type="bytes" and autoAllocateChunkSize.
For any other underlying source, the stream will always satisfy read requests with data from internal queues.
-Streams API concepts
-Using readable streams
-ReadableStream
-Web-streams-polyfill
Constructors
ReadableStreamDefaultReader()
public ReadableStreamDefaultReader()
ReadableStreamDefaultReader(ReadableStream)
The ReadableStreamDefaultReader()
constructor creates and returns a ReadableStreamDefaultReader object
instance.
public ReadableStreamDefaultReader(ReadableStream stream)
Parameters
streamReadableStream
Remarks
NOTE
You generally wouldn't use this constructor manually; instead,
you'd use the GetReader(ReadableStreamGetReaderOptions) method.
-Streams API concepts
-Using readable streams
-ReadableStream
-ReadableStreamDefaultController
Methods
Read()
The read() method of the ReadableStreamDefaultReader interface returns a {{jsxref("Promise")}} providing access to the next chunk in the stream's internal queue.
[Value("read")]
public Task<ReadableStreamReadResult> Read()
Returns
- Task<ReadableStreamReadResult>
A Promise, which fulfills/rejects with a result depending on the state of the stream.
The different possibilities are as follows:
Remarks
ReleaseLock()
The releaseLock() method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.
[Value("releaseLock")]
public GlobalObject.Undefined ReleaseLock()
Returns
Remarks
If the associated stream is errored when the lock is released, the reader will appear errored in that same way subsequently; otherwise, the reader will appear closed.
If the reader's lock is released while it still has pending read requests then the promises returned by the reader's Read() method are immediately rejected with a TypeError.
Unread chunks remain in the stream's internal queue and can be read later by acquiring a new reader.
-ReadableStreamDefaultReader(ReadableStream) constructor
-Using readable streams