Bun 實現了 Web 標准的 TextDecoder 類,用於從二進制數據類型(如 Uint8Array)轉換為字符串。
ts
const arr = new Uint8Array([104, 101, 108, 108, 111]);
const decoder = new TextDecoder();
const str = decoder.decode(arr);
// => "hello"有關使用 Bun 操作二進制數據的完整文檔,請參閱 文檔 > API > 二進制數據。