Bun 實作 Web 標準 TextDecoder
類別,用於將二進制資料類型(例如 Uint8Array
和字串)轉換為字串。
const arr = new Uint8Array([104, 101, 108, 108, 111]);
const decoder = new TextDecoder();
const str = decoder.decode(arr);
// => "hello"
請參閱 文件 > API > 二進制資料,以取得使用 Bun 處理二進制資料的完整文件。