fl-assert

1.0.10 • Public • Published

fl-assert

Simple assertion functions to throw errors in the code.

Read the DOCS

Check out the repo

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

Readme

Keywords

none

Package Sidebar

Install

npm i fl-assert

Weekly Downloads

1

Version

1.0.10

License

ISC

Last publish

Collaborators

  • fourlabsldn