JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q33502F
  • License MIT

Tiny Javascript assertion library

Package Exports

  • picoassert

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (picoassert) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

picoassert

[npm][npm-url] [npm][npm-url] Github file size

Perhaps the smallest Javascript assertion module

picoassert is a 114-byte Javascript assertion module. It is based on nanoassert.

Usage

var assert = require("picoassert")

assert.eq(a, b, `${a} == ${b}`);   // Asserts `a` and `b` are equal.
assert.neq(a, b, `${a} != ${b}`);  // Asserts `a` and `b` are not equal.
assert.is(a, `(!!${a}) === true`); // Asserts `a` is truthy.

Why

The nanoassert repository README describes the author's complaint about the excessive size of the assert module, the standard assertion library. However, even the nanoassert library was unnecessarily large, which led to the creation of picoassert.

This library is also an open golf challenge. Please feel free to submit pull requests if you're able to shorten the code!

Install

npm install picoassert

Content Delivery Network (CDN)

The picoassert library can be imported via unpkg as shown below:

<script src="https://unpkg.com/picoassert/index.js"></script>

License

Please see the LICENSE file for license information.