> ## Documentation Index
> Fetch the complete documentation index at: https://bun.ll1025.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 将 ArrayBuffer 转换为 Buffer

Node.js 的 [`Buffer`](https://nodejs.org/api/buffer.html) API 在 `ArrayBuffer` 引入 JavaScript 语言之前就已存在。Bun 两者都实现了。

使用静态方法 `Buffer.from()` 从 `ArrayBuffer` 创建 `Buffer`。

```ts theme={null}
const arrBuffer = new ArrayBuffer(64);
const nodeBuffer = Buffer.from(arrBuffer);
```

***

要创建一个仅查看底层缓冲区部分内容的 `Buffer`，可以将偏移量和长度传递给 `Buffer.from()`。

```ts theme={null}
const arrBuffer = new ArrayBuffer(64);
const nodeBuffer = Buffer.from(arrBuffer, 0, 16); // 查看前 16 个字节
```

***

参见 [二进制数据](/runtime/binary-data#conversion)。
