本页还没有译文
本页 5 段还没译成简体中文,下面显示的是英文原文。Convert a ReadableStream to a Uint8Array
还没翻译译自英文(bun.com)本页 5 段都还没译
To convert a ReadableStream to a Uint8Array, read its contents into an ArrayBuffer with Bun.readableStreamToArrayBuffer, then create a Uint8Array that points to the buffer.
const stream = new ReadableStream();
const buf = await Bun.readableStreamToArrayBuffer(stream);
const uint8 = new Uint8Array(buf);The stream's bytes() method converts to a Uint8Array directly.
const stream = new ReadableStream();
const uint8 = await stream.bytes();Bun.readableStreamToBytes(stream) does the same thing, but is deprecated in favor of stream.bytes().
AI 翻译查看英文原文