# mini-assert

> a mini(malistic) assertion library

Latest version **1.0.7** (published 2015-07-01) · 0 weekly downloads

## Install

```sh
npm install mini-assert
pnpm add mini-assert
yarn add mini-assert
bun add mini-assert
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2015-07-01 |
| First published | 2015-07-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | brillout |
| Keywords | assert |

## Links

- npm: https://www.npmjs.com/package/mini-assert
- Repository: https://github.com/brillout/mini-assert
- Homepage: https://github.com/brillout/mini-assert#readme
- Issues: https://github.com/brillout/mini-assert/issues
- npm.io page: https://npm.io/package/mini-assert

## Recent versions

- 1.0.7 (latest) — 2015-07-01

## README

```
// var assert = require('mini-assert'); // NPM, `npm install mini-assert`
// import assert from "mini-assert"; // JSPM, `jspm install npm:mini-assert`

var bool = Math.random()>0.5;

// use this function to bring to attention
// an unexpected code execution, i.e. a bug
assert(bool, "should not be <=0.5");

// use this function to bring to attention
// a wrong usage of an API
assert.expect(bool, "should be >0.5");

// use this function to bring to attention
// a warning, i.e. something non-critical
assert.warning(bool, "be careful; <= 0.5");

assert.onerror = function(){
    // track errors
};

```

the only differences between `assert`, `assert.expect`, and `assert.warning` are;
  - the error message is prepended with a different name: `ASSERTION-FAIL: /*...*/`, `WRONG-USAGE: /*...*/`, `WARNING: /*...*/`
  - [`assert`, `assert.expect`] throw an error whereas `assert.warning` only does a console.log

If in the browser and if `location.hostname!=='localhost'` then no error is ever thrown and only console.log is used

---
_Source: https://npm.io/package/mini-assert · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
