@ende/assert
ende add jsr:@ende/assertVersion 2026.10.15 on JSR.
A library of assertion functions.
If the assertion is false an AssertionError will be thrown which will
result in pretty-printed diff of the failing assertion.
This module is browser compatible, but do not rely on good formatting of values for AssertionError messages in browsers.
import { assert } from "@ende/assert";
assert("I am truthy"); // Doesn't throw
assert(false); // Throws `AssertionError`
Modules
@ende/assert/almost-equals@ende/assert/array-includes@ende/assert/assert@ende/assert/assertion-error@ende/assert/equal@ende/assert/equals@ende/assert/exists@ende/assert/fail@ende/assert/false@ende/assert/greater@ende/assert/greater-or-equal@ende/assert/instance-of@ende/assert/is-error@ende/assert/less@ende/assert/less-or-equal@ende/assert/match@ende/assert/not-equals@ende/assert/not-instance-of@ende/assert/not-match@ende/assert/not-strict-equals@ende/assert/object-match@ende/assert/rejects@ende/assert/strict-equals@ende/assert/string-includes@ende/assert/throws@ende/assert/unimplemented@ende/assert/unreachable@ende/assert/unstable-equals@ende/assert/unstable-never@ende/assert/unstable-strict-equals
Exports
AnyConstructor— Any constructorArrayLikeArg— An array-like object (`Array`, `Uint8Array`, `NodeList`, etc.) that is not a stringassert— Make an assertion, an error will be thrown if `expr` does not have a truthy value.assertAlmostEquals— Make an assertion that `actual` and `expected` are almost equal numbers through a given tolerance. It can be used to take into account IEEE-754 double-precision floating-point representation limitations. If the values are not almost equal then throw.assertArrayIncludes— Asserts that `actual` contains all values in `expected`, using deep equality for non-primitive values.assertEquals— Make an assertion that `actual` and `expected` are equal, deeply. If not deeply equal, then throw.assertExists— Make an assertion that actual is not null or undefined. If not then throw.assertFalse— Make an assertion, an error will be thrown if `expr` has a truthy value.assertGreater— Make an assertion that `actual` is greater than `expected`. If not then throw.assertGreaterOrEqual— Make an assertion that `actual` is greater than or equal to `expected`. If not then throw.assertInstanceOf— Make an assertion that `obj` is an instance of `type`. If not then throw.AssertionError— Error thrown when an assertion fails.assertIsError— Make an assertion that `error` is an `Error`. If not then an error will be thrown. An error class and a string that should be included in the error message can also be asserted.assertLess— Make an assertion that `actual` is less than `expected`. If not then throw.assertLessOrEqual— Make an assertion that `actual` is less than or equal to `expected`. If not then throw.assertMatch— Make an assertion that `actual` match RegExp `expected`. If not then throw.assertNotEquals— Make an assertion that `actual` and `expected` are not equal, deeply. If not then throw.assertNotInstanceOf— Make an assertion that `obj` is not an instance of `type`. If so, then throw.assertNotMatch— Make an assertion that `actual` not match RegExp `expected`. If match then throw.assertNotStrictEquals— Make an assertion that `actual` and `expected` are not strictly equal, using Object.is for equality comparison. If the values are strictly equal then throw.assertObjectMatch— Make an assertion that `expected` object is a subset of `actual` object, deeply. If not, then throw a diff of the objects, with mismatching properties highlighted.assertRejects— Executes a function which returns a promise, expecting it to reject.assertStrictEquals— Make an assertion that `actual` and `expected` are strictly equal, using Object.is for equality comparison. If not, then throw.assertStringIncludes— Make an assertion that actual includes expected. If not then throw.assertThrows— Executes a function, expecting it to throw. If it does not, then it throws.equal— Deep equality comparison used in assertions.fail— Forcefully throws a failed assertion.Falsy— Assertion condition for assertFalse.GetConstructorType— Gets constructor typeunimplemented— Use this to stub out methods that will throw when invoked.unreachable— Use this to assert unreachable code.