isBuffer
Checks if a value is a Node.js Buffer instance.
Buffer extends Uint8Array and is specific to Node.js, Bun, and Deno.
In browser-only environments where Buffer is not defined, this function
always returns false.
Useful for filtering or type-narrowing in a functional pipeline:
values.filter(isBuffer)
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
Section titled “Returns”value is Buffer<ArrayBufferLike> — True if value is a Buffer
Examples
Section titled “Examples”Detect a Node.js Buffer
Section titled “Detect a Node.js Buffer”Returns true only for Buffer instances. Uint8Array is not a Buffer.
Filter Buffers from a mixed array
Section titled “Filter Buffers from a mixed array”Use as a predicate in .filter() to extract Buffer values.
