API Reference
Complete reference for AssertCheck, generated from JSDoc in the source code.
assert.*
50+ assertion methods — existence, types, equality, numerics, arrays, objects, functions, and negation.
Browse all methods
check()Fluent chainable API — wrap a value and declare multiple invariants in a single readable expression.
Read the reference
Errors & formattingAssertionError, buildBlock(), fmtValue() — access structured metadata and build custom assertion output.
Read the reference
Core exports
| Export | Description |
|---|---|
assert | The main assertion namespace — all 50+ methods documented individually. |
check() | Chainable wrapper — check(arr).noNils().uniqueBy("id") |
Assertion categories
| Category | Methods |
|---|---|
| Existence | nil, notNil, empty, notEmpty |
| Types | string, number, integer, finite, boolean, array, object, func, instanceOf |
| Equality | equal, deepEqual |
| Numerics | positive, negative, zero, greater, greaterOrEqual, less, lessOrEqual, withinRange, inDelta |
| Arrays | len, longerThan, shorterThan, includes, all, any, none, one, count, containsAll, containsNone, elementsMatch, subset, unique, uniqueBy, increasing, nonDecreasing, sortedBy, first, last, sumBy, noNils, flat, allInstanceOf, zippedWith, groupedBy, partition |
| Objects | hasKey, hasKeys, hasExactKeys, hasOnlyKeys, hasValue, containsSubset, allValuesMatch, noNilValues, dig |
| Functions | returns, pure, idempotent, arity, mapsDistinct, homomorphic |
| Negation | not |
Classes
| Class | Description |
|---|---|
Checker | Base class for chainable checkers |
ArrayChecker | Returned by check() when the value is an array |
ObjectChecker | Returned by check() when the value is an object |
AssertionError | Error thrown on assertion failure — carries assertion, actual, expected, message |
Formatting primitives
| Export | Description |
|---|---|
buildBlock() | Build a formatted error block string |
fmtValue() | Format any value for display |
color | ANSI colour helpers: color.added, color.removed, color.index |
parseOpts() | Normalise string | AssertOptions | undefined → structured options |
fail() | Output the formatted error and throw AssertionError |
diffObjects() | Generate diff rows between two objects |
Types
| Type | Description |
|---|---|
AssertOptions | Options accepted by every assertion: msg, note, actual |
This reference is generated from JSDoc in the source. To regenerate after editing, run
bun run docs:api.