A large collection of generic TypeScript assert functions which can be used in unit tests but also in production code to validate inputs for example.
When an assertion fails an AssertionError is thrown with detailed information about what went wrong.
The assert library works in Node.js and browsers.
Install the library in your project (add -D
parameter when only needed as dev dependency for unit tests):
npm install @kayahr/assert
And the use it like this:
import { assertNotNull } from "@kayahr/assert";
assertNotNull(someValue);
See API Doc for a list of all provided assert functions.