Bun Convert a Buffer to a Uint8Array

Convert a Buffer to a Uint8Array

jarle Updated

File contents

Convert a Buffer to a Uint8Array

The Node.js Buffer class extends Uint8Array, so no conversion is needed. All properties and methods on Uint8Array are available on Buffer.

const buf = Buffer.alloc(64);
buf instanceof Uint8Array; // => true

See Docs > API > Binary Data for complete documentation on manipulating binary data with Bun.

jarle/bun-skills/tree/main/skills/bun-guides-binary-buffer-to-typedarray commit 1bb005a968

Frequently asked questions

npx skillmds@latest add jarle/bun-convert-a-buffer-to-a-uint8array