https://github.com/10xengineersqualityprogramming/assert-fn
Assert function for Node.js
https://github.com/10xengineersqualityprogramming/assert-fn
Last synced: 12 months ago
JSON representation
Assert function for Node.js
- Host: GitHub
- URL: https://github.com/10xengineersqualityprogramming/assert-fn
- Owner: 10xEngineersQualityProgramming
- Created: 2024-08-23T18:17:06.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-23T18:19:02.000Z (almost 2 years ago)
- Last Synced: 2025-06-09T17:11:18.882Z (12 months ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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
```