# assert-fn

> Simple assert function

Latest version **1.0.2** (published 2026-03-03) · UNLICENSED license · 0 weekly downloads

## Install

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

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2026-03-03 |
| First published | 2024-08-22 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | fox |
| Maintainers | tj-commits |

## Links

- npm: https://www.npmjs.com/package/assert-fn
- Repository: https://github.com/tj-commits/assert
- Issues: https://github.com/tj-commits/assert/issues
- npm.io page: https://npm.io/package/assert-fn

## Dependencies (2)

- [none](https://npm.io/package/none.md) ^1.0.0
- [vanilla-javascript](https://npm.io/package/vanilla-javascript.md) ^1.1.1

## Recent versions

- 1.0.2 (latest) — 2026-03-03
- 1.0.1 — 2024-08-23
- 1.0.0 — 2024-08-22

## README

# assert-fn
A very simple alternative to the built-in `node:assert` module. All `assert-fn` does is check if the condition is not true, and if it is not true, throw an error.
The below code throws no error:
```javascript
const assert = require('assert-fn')
assert(2 + 2 === 4, "no error")
```
But this code throws an error:
```javascript
const assert = require('assert-fn')
assert(2 + 2 === 5, "error") // AssertionError: Assertion failed: error
```

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