readableStream.values([options])


创建并返回可用于使用此 ReadableStream 的数据的异步迭代器。

¥Creates and returns an async iterator usable for consuming this ReadableStream's data.

当异步迭代器处于活动状态时,使 readableStream.locked 成为 true

¥Causes the readableStream.locked to be true while the async iterator is active.

import { Buffer } from 'node:buffer';

const stream = new ReadableStream(getSomeSource());

for await (const chunk of stream.values({ preventCancel: true }))
  console.log(Buffer.from(chunk).toString());