ReadableStreamDefaultReader object cannot be constructed directly. You can use the ReadableStream.getReader method to construct a ReadableStreamDefaultReader object.// Use TransformStream to construct a ReadableStream object.const { readable } = new TransformStream();// Use the ReadableStream object to obtain the reader.const reader = readable.getReader();
// reader.closedreadonly closed: Promise<void>;
fulfilled. If an exception occurs on the stream or the lock on the reader is released, the status of the Promise object is rejected.reader.read(): Promise<{value: Chunk, done: boolean}>;
reader.read method returns a Promise object that contains the read data Chunk and the reading status.fulfilled status and contains an object in the { value: theChunk, done: false } format.fulfilled status and contains an object in the { value: undefined, done: true } format.rejected status, and the relevant error information is included.Chunk parameter indicates the data to be read from the stream.type Chunk = string | ArrayBuffer | ArrayBufferView;
reader.cancel(reason?: string): Promise<string>;
reader.releaseLock(): void;
Feedback