运行时包管理器打包器测试运行器代码检查格式化指南参考博客反馈

将 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"

请参阅二进制数据。