docs/reference/compat/predicate/isBuffer.md
::: warning Use es-toolkit's isBuffer instead
This isBuffer function operates slowly due to complex processing for Lodash compatibility.
Use the faster and more modern es-toolkit's isBuffer instead.
:::
Checks if a value is a Buffer instance.
const result = isBuffer(value);
isBuffer(value)Use isBuffer when you want to type-safely check if a value is a Buffer instance. It's useful when working with Buffer objects in Node.js environments. It also works as a type guard in TypeScript.
import { isBuffer } from 'es-toolkit/compat';
// Check Buffer instance
const buffer = Buffer.from('hello');
isBuffer(buffer); // true
// Other types return false
isBuffer('hello'); // false
isBuffer([1, 2, 3]); // false
isBuffer(new Uint8Array([1, 2, 3])); // false
isBuffer({}); // false
isBuffer(null); // false
isBuffer(undefined); // false
value (unknown): The value to check if it's a Buffer instance.(boolean): Returns true if the value is a Buffer instance, false otherwise.