webassert
Nanoscale assertion module
Last updated 7 months ago by bret .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install webassert 
SYNC missed versions from official npm registry.

webassert

Nanoscale assertion esm module

A fork of nanoassert porting it over to real-deal ESM. Directly importable to browsers (also works in node).

Usage

import assert from 'https://unpkg.com/webassert@^3?module'

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.

I liked nanoassert but wanted an ESM version of it.

Install

npm install nanoassert

License

ISC

Current Tags

  • 3.0.2                                ...           latest (7 months ago)

3 Versions

  • 3.0.2                                ...           7 months ago
  • 3.0.1                                ...           7 months ago
  • 3.0.0                                ...           7 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 7
Last Month 30
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |