Nanoscale assertion module
var assert = require('nanoassert')
assert(a !== b, `${a} !== ${b}`)
Assert that declaration
is truthy otherwise throw Error
with
optional message
, which defaults to AssertionError
.
If you want friendlier messages you can use template strings to show the
assertion made like in the example above.
Assert that declaration
is not truthy.
Assert that a
is loosely equal to b
. Uses ==
for the comparison.
Assert that a
is loosely not equal to b
. Uses ==
for the comparison.
I like to write public facing code very defensively, but have complaints about
the size incurred by the assert
module. I only use the top-level assert
method anyway, so this should make everyone happy :)
npm install nanoassert