开发者社区> 镜像站> NPM> nanoassert
nanoassert
Nanoscale assertion module
Last updated 2 years ago by emilbayes .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install nanoassert 
SYNC missed versions from official npm registry.

nanoassert

Build Status

Nanoscale assertion module

Usage

var assert = require('nanoassert')

assert(a !== 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

Current Tags

  • 2.0.0                                ...           latest (2 years ago)

3 Versions

  • 2.0.0                                ...           2 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 65
This Week 653
This Month 514
Last Day 151
Last Week 867
Last Month 3,220
Dependencies (0)
None
Dev Dependencies (1)
Dependents (154)