@lucid-softworks/invariant
v0.1.0
Published
A tiny assertion helper with lazy error messages.
Maintainers
Readme
@lucid-softworks/invariant
A tiny assertion function with TypeScript narrowing and lazy error messages.
import { invariant } from "@lucid-softworks/invariant";
const user = users.get(id);
invariant(user, () => `User ${id} was not found`);
// `user` is narrowed here.Failed assertions throw InvariantError. A message callback is evaluated only
when the assertion fails.
