assertStrictEquals

import { assertStrictEquals } from "jsr:@ende/assert/unstable-strict-equals";

function ยท experimental

function assertStrictEquals<T>(actual: unknown, expected: T, msg?: string): asserts actual is T

Make an assertion that actual and expected are strictly equal, using Object.is for equality comparison. If not, then throw.

actual: unknown

The actual value to compare.

expected: T

The expected value to compare.

msg?: string

The optional message to display if the assertion fails.

Example: Usage

import { assertStrictEquals } from "@ende/assert";

const a = {};
const b = a;
assertStrictEquals(a, b); // Doesn't throw

const c = {};
const d = {};
assertStrictEquals(c, d); // Throws

Source