bun-types
Version:
Type definitions and documentation for Bun, an incredibly fast JavaScript runtime
17 lines (12 loc) • 598 B
text/mdx
title: Convert a Buffer to a Uint8Array
sidebarTitle: "Buffer to Uint8Array"
mode: center
The Node.js [`Buffer`](https://nodejs.org/api/buffer.html) class extends [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), so no conversion is needed. All properties and methods on `Uint8Array` are available on `Buffer`.
```ts
const buf = Buffer.alloc(64);
buf instanceof Uint8Array; // => true
```
See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.