將 ReadableStream 轉換為字串
Bun 提供了多種便利方法,用於將 ReadableStream 的內容讀取為其他格式。要將流讀取為字串,請呼叫其 text() 方法。
TypeScript
const stream = new ReadableStream();
const str = await stream.text();
Bun.readableStreamToText(stream) 具有相同的功能,但已棄用,推薦使用 stream.text()。
Bun 提供了多種便利方法,用於將 ReadableStream 的內容讀取為其他格式。要將流讀取為字串,請呼叫其 text() 方法。
const stream = new ReadableStream();
const str = await stream.text();
Bun.readableStreamToText(stream) 具有相同的功能,但已棄用,推薦使用 stream.text()。