equals

import { equals } from "jsr:@ende/bytes";

function

function equals(a: Uint8Array, b: Uint8Array): boolean

Check whether byte slices are equal to each other.

a: Uint8Array

First array to check equality.

b: Uint8Array

Second array to check equality.

Returns

true if the arrays are equal, false otherwise.

Example: Basic usage

import { equals } from "@ende/bytes/equals";
import { assertEquals } from "@ende/assert";

const a = new Uint8Array([1, 2, 3]);
const b = new Uint8Array([1, 2, 3]);
const c = new Uint8Array([4, 5, 6]);

assertEquals(equals(a, b), true);
assertEquals(equals(a, c), false);

Source