執行環境套件管理器打包器測試執行器程式碼檢查格式化指南參考部落格意見回饋

將 Uint8Array 轉換為字串

Bun 實現了符合 Web 標準的 TextDecoder 類,用於將 Uint8Array 等二進位制資料型別轉換為字串。

TypeScript
const arr = new Uint8Array([104, 101, 108, 108, 111]);
const decoder = new TextDecoder();
const str = decoder.decode(arr);
// => "hello"

請參閱二進位制資料。