Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

picoassert

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

picoassert

Tiny Javascript assertion library

latest
Source
npmnpm
Version
1.4.3
Version published
Maintainers
1
Created
Source

picoassert

npm npm Github file size GitHub

Perhaps the smallest Javascript assertion module

picoassert is a 113-byte Javascript assertion module 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 type="application/javascript">var module={};</script>
<script src="https://unpkg.com/picoassert/index.js"></script>
<script type="application/javascript">
  var assert = module.exports;
  // Library is imported as `assert`!
</script>

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.

License

Please see the LICENSE file for license information.

Keywords

assert

FAQs

Package last updated on 11 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts