https://github.com/fourlabsldn/fl-assert
A simple assertion library for throwing errors
https://github.com/fourlabsldn/fl-assert
Last synced: 4 months ago
JSON representation
A simple assertion library for throwing errors
- Host: GitHub
- URL: https://github.com/fourlabsldn/fl-assert
- Owner: fourlabsldn
- Created: 2016-05-04T14:40:21.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-24T15:23:10.000Z (about 9 years ago)
- Last Synced: 2025-02-11T07:03:45.161Z (5 months ago)
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fl-assert
Simple assertion functions to throw errors in the code.
Read the [DOCS](http://fourlabsldn.github.io/fl-assert/index.html)
[Check out the repo](https://github.com/fourlabsldn/fl-assert/)
## Usage
Use it like this:
``` javascript
const myCollection = [1, 2];assert(myCollection.length > 0, 'myCollection must have at least one element'); // Nothing happens
assert(myCollection.length > 5, 'myCollection must have at least one element'); // Throws the string passed as an error messageassert.warn(typeof myCollection[0] === 'number', 'First element of collection is not a number'); // Nothing happens
assert.warn(typeof myCollection[0] === 'string', 'First element of collection is not a string'); // Logs a warning with the string passed as the warning message
```## ES6
The main file in the dist folder is an ES6 module, and [it is specified as such](https://github.com/rollup/rollup/wiki/jsnext:main), so you can just write
this line below start rocking.
``` javascript
import assert from 'fl-assert'
```## Install
### Bower
```
npm install --save-dev fl-assert
```