Bun 實現了 Web 標准的 TextDecoder 類,用於在二進制數據類型和字符串之間進行轉換。
ts
const buf = new ArrayBuffer(64);
const decoder = new TextDecoder();
const str = decoder.decode(buf);有關使用 Bun 操作二進制數據的完整文檔,請參閱 文檔 > API > 二進制數據。