BYOB is an abbreviation of bring your own buffer. A ReadableStreamBYOBReader object allows to read data from streams and write the read data to the buffer, thereby reducing replicas.ReadableStreamBYOBReader object cannot be constructed directly. You can use the ReadableStream.getReader method to construct a ReadableStreamBYOBReader object.// Use TransformStream to construct a ReadableStream object.const { readable } = new TransformStream();// Use the ReadableStream object to obtain the reader.const reader = readable.getReader({mode: 'byob',});
// readable.lockedreadonly locked: boolean;
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(bufferView: ArrayBufferView): Promise<{value: ArrayBufferView, done: boolean}>;
bufferView on the buffer.reader.read method returns a Promise object that contains the read data and the reading status.fulfilled status and contains an object in the { value: theChunk, done: false } format.fulfilled, and an object in the { value: theChunk, done: true } format is contained.rejected status, and the relevant error information is included.reader.cancel(reason?: string): Promise<string>;
reader.releaseLock(): void;
Feedback