equals

fun equals(otherBuffer: Uint8Array<*>): Boolean(source)

Returns true if both buf and otherBuffer have exactly the same bytes,false otherwise. Equivalent to buf.compare(otherBuffer) === 0.

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

Since

v0.11.13

Parameters

otherBuffer

A Buffer or {@link Uint8Array} with which to compare buf.