fl-assert
v1.0.10
Published
Simple assert function for throwing errors
Downloads
11
Readme
fl-assert
Simple assertion functions to throw errors in the code.
Read the DOCS
Usage
Use it like this:
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 message
assert.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, so you can just write this line below start rocking.
import assert from 'fl-assert'
Install
Bower
npm install --save-dev fl-assert