nanoassert

2018-11-09 admin

nanoassert是什么

什么是nanoassert,Nanoscale assertion module

nanoassert使用教程帮助文档

nanoassert

Nanoscale assertion module

Usage

var assert = require('nanoassert')

assert(a !== b, `${a} !== ${b}`)

API

assert(declaration, [message])

assert.ok(declaration, [message])

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.notOk(declaration, [message])

Assert that declaration is not truthy.

assert.equal(a, b, [message])

Assert that a is loosely equal to b. Uses == for the comparison.

assert.notEqual(a, b, [message])

Assert that a is loosely not equal to b. Uses == for the comparison.

Why

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 :)

Install

npm install nanoassert

License

ISC

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-44966.html

文章标题:nanoassert

回到顶部