Skip to main content
Buffer.equals - node__buffer.d.ts - Node documentation
method Buffer.equals

Usage in Deno

```typescript import { type Buffer } from "node:node__buffer.d.ts"; ```
Buffer.equals(otherBuffer: Uint8Array): boolean
Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`. ```js import { Buffer } from 'node:buffer'; const buf1 = Buffer.from('ABC'); const buf2 = Buffer.from('414243', 'hex'); const buf3 = Buffer.from('ABCD'); console.log(buf1.equals(buf2)); // Prints: true console.log(buf1.equals(buf3)); // Prints: false ```

Parameters

otherBuffer: Uint8Array
A `Buffer` or Uint8Array with which to compare `buf`.

Return Type

boolean