nanoassert
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/nanoassert package

2.0.0 • Public • Published

nanoassert

Build Status

Nanoscale assertion module

Usage

var assert = require('nanoassert')
 
assert(!== b, `${a} !== ${b}`)

API

assert(declaration, [message])

Assert that declaration is truthy otherwise throw AssertionError with optional message. In Javascript runtimes that use v8, you will get a nicer stack trace with this error. If you want friendlier messages you can use template strings to show the assertion made like in the example above.

Why

I like to write public facing code very defensively, but have reservations about the size incurred by the assert module. I only use the top-level assert method anyway.

nanoassert@^1.1.0

Docs for the previous version, which is used by many modules on npm, can be found here

Install

npm install nanoassert

License

ISC

Package Sidebar

Install

npm i nanoassert

Weekly Downloads

190,759

Version

2.0.0

License

ISC

Unpacked Size

5.13 kB

Total Files

7

Last publish

Collaborators

  • emilbayes