npm promulgates marsupials

    assertsjs

    0.0.22 • Public • Published

    ASSERTSJS

    Validate all your Javascript types!

    Install:

    npm i -S assertsjs

    NOTE:

    This code uses ECMA6 modules, if you want ECMA5 support you need to build it with a JS builder like webpack, babelify and so on.

    Example:

    'use strict';
    const Asserts = require('assertsjs');
    
    /**
    * This function will return an array of the same string with custom size
    * @params {string} stringArgument
    * @params {number} numberArgument
    * @return {Array<string>}
    */
    const repeaterFunction = (numberArgument, stringArgument) => {
        Asserts.assertString(stringArgument); //This will throw the default message: 'Assertion fail: string must be provided'
        Asserts.assert(typeof numberArgument === 'number', 'Must be a number'); //But this is throwing the custom given message
        const stringArray = [];
        for(let i = 0; i < numberArgument; i++){
            stringArray.push(stringArgument);
        }
        return stringArray; //You could check output functions too
    };
    

    The code will check the arguments and throw errors if the type is not the correct so you can trust yourself or your team mates they will care about the type of your variables.

    Install

    npm i assertsjs

    DownloadsWeekly Downloads

    2

    Version

    0.0.22

    License

    MIT

    Last publish

    Collaborators

    • luisresco