Guides · Binary Data
Convert a Buffer to a Uint8Array
Use a Node.js Buffer directly wherever a Uint8Array is expected, since Buffer extends 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 Binary Data.