readableStreamBYOBReader.read(view[, options])
view<Buffer> | <TypedArray> | <DataView>options<Object>min<number> 设置后,返回的 promise 只有在min数量的元素可用时才会被兑现。未设置时,当至少有一个元素可用时,promise 就会被兑现。
- 返回值:一个已兑现的对象的 Promise:
value<TypedArray> | <DataView>done<boolean>
从底层 <ReadableStream> 请求下一块数据,并返回一个在数据可用时被完成的 Promise。
【Requests the next chunk of data from the underlying <ReadableStream> and returns a promise that is fulfilled with the data once it is available.】
不要将池化的 <Buffer> 对象实例传入此方法。池化的 Buffer 对象是使用 Buffer.allocUnsafe() 或 Buffer.from() 创建的,或者通常由各种 node:fs 模块回调返回。这些类型的 Buffer 使用共享的底层 <ArrayBuffer> 对象,该对象包含所有池化 Buffer 实例的所有数据。当将 Buffer、<TypedArray> 或 <DataView> 传入 readableStreamBYOBReader.read() 时,该视图的底层 ArrayBuffer 会被_分离_,使其上可能存在的所有现有视图失效。这可能对你的应用造成严重后果。
【Do not pass a pooled <Buffer> object instance in to this method.
Pooled Buffer objects are created using Buffer.allocUnsafe(),
or Buffer.from(), or are often returned by various node:fs module
callbacks. These types of Buffers use a shared underlying
<ArrayBuffer> object that contains all of the data from all of
the pooled Buffer instances. When a Buffer, <TypedArray>,
or <DataView> is passed in to readableStreamBYOBReader.read(),
the view's underlying ArrayBuffer is detached, invalidating
all existing views that may exist on that ArrayBuffer. This
can have disastrous consequences for your application.】