Tiny Javascript assertion library
npm install picoassert[github-index-url]: https://github.com/mgthomas99/picoassert/blob/master/index.js
[github-license-url]: https://github.com/mgthomas99/picoassert/blob/master/LICENSE
[github-repository-url]: https://github.com/mgthomas99/picoassert
[github-license-shield-url]: https://img.shields.io/github/license/mgthomas99/picoassert.svg?style=flat-square
[github-size-shield-url]: https://img.shields.io/github/size/mgthomas99/picoassert/index.js.svg?style=flat-square
[npm-package-url]: https://www.npmjs.com/package/picoassert
[npm-downloads-shield-url]: https://img.shields.io/npm/dt/picoassert.svg?style=flat-square
[npm-version-shield-url]: https://img.shields.io/npm/v/picoassert.svg?style=flat-square
[![npm][npm-version-shield-url]][npm-package-url]
[![npm][npm-downloads-shield-url]][npm-package-url]
[![Github file size][github-size-shield-url]][github-index-url]
[![GitHub][github-license-shield-url]][github-license-url]
> Perhaps the smallest Javascript assertion module
picoassert is a 113-byte Javascript assertion module based on
nanoassert.
``js
var assert = require("picoassert")
assert.eq(a, b, ${a} == ${b}); // Asserts a and b are equal.${a} != ${b}
assert.neq(a, b, ); // Asserts a and b are not equal.(!!${a}) === true
assert.is(a, ); // Asserts a is truthy.`
The nanoassert repository README describes the author's complaint about theassert
excessive size of the module,nanoassert
the standard assertion library. However, even the library waspicoassert
unnecessarily large, which led to the creation of .
This library is also an open golf
challenge. Please feel free to submit pull requests if you're able to shorten
the code!
`sh`
npm install picoassert
The picoassert library can be imported via unpkg as shown
below:
`html`
Be aware that picoassert is a CommonJS module and therefore uses
module.exports; before importing the script, you will need to define module
or use a CommonJS-compatible module loader.
Please see the LICENSE` file for license information.