globalThis.Buffer and the Buffer export from node:buffer have the same
identity. Buffers are Uint8Array instances with indexed access and a stable
underlying ArrayBuffer.
import { Buffer } from "node:buffer";
const bytes = Buffer.from("hello", "utf8");
console.log(bytes[0]); // 104
console.log(bytes.toString("hex")); // 68656c6c6f
console.log(bytes instanceof Uint8Array); // trueUse Buffer.alloc, Buffer.allocUnsafe, Buffer.allocUnsafeSlow, and
Buffer.from to create buffers. Calling Buffer() or new Buffer() still
works for compatibility but emits a deprecation warning.
Common Node operations are available, including compare, copy, equals,
fill, includes, indexOf, slice, subarray, write, fixed- and
variable-width numeric reads/writes, BigInt reads/writes, and byte swaps.
Supported encodings include utf8, utf16le, latin1, ascii, base64,
base64url, and hex. utf16be is not accepted.
node:buffer also exports Blob, File, SlowBuffer, atob, btoa,
isAscii, isUtf8, transcode, size constants, and related helpers.
Unlike Node, Elide 1.5.0’s allocUnsafe implementations return zero-filled
memory rather than exposing previously used bytes.