0.0.3 • Published 1 year ago
@prelect/assurt v0.0.3
assurt
assertion without the exertion
Features
- Lean
- Works fine in browser land
- Can work with custom loggers
- Can be globally disabled
Installation
npm i @prelect/assurt
Usage
import Assurt from "@prelect/assurt";
const assurt = new Assurt(process.env.NODE_ENV !== "");
assurt.ok(1 + 1 === 2, "math works");
When false
is passed to Assurt, the program ignores all of the assertions.
When true
is passed to Assurt, the program evaluates all of the expressions, passing them to either console.info
if successful or console.error
if unsuccessful.
If you wish to get fancy, you can pass an object with options to Assurt:
import Assurt from "assurt";
const assurt = new Assurt({
active: true,
emojis: true,
fail: true,
info: myLogger.info,
error: myLogger.error,
});
assurt.ok(1 + 2 === 3);
if fail
is set to true (and it is by default when active unless overriden), then an error is thrown if the assertion fails.