Yet another invariant
alternative, albeit much smaller.
An invariant
function takes a value, and if the value is falsy then the invariant
function will throw. If the value is truthy, then the function will not throw.
variante-alta is an utility package that looks to replicate invariant, albeit it is much simpler and has no custom logic beyond its core. It's extremely similar to Solidity's require function and seeks to replicate its (very basic) behavior.
# yarn
yarn add variante-alta
# npm
npm add variante-alta --save
import invariant from 'variante-alta'
invariant(1 === 1, 'One is not equal to one!')