Nocturnal Practitioners of Magic

    isnmbr

    1.0.2 • Public • Published

    Check variable on number, integer and float (javascript)

    Methods

    • isNumber - check variable on number
    • isInt - check variable on integer
    • inFloat - check variable on float

    How Install

    npm i isnmbr -S
    

    import

    import {isNumber, isInt, isFloat} from 'isnmbr';

    or

    const {isNumber, isInt, isFloat} = require('isnmbr');

    How to use?

    true

    import {isNumber, isInt, isFloat} from 'isnmbr';
    
    isNumber(5); // true
    isNumber('5'); // true
    isNumber(5.5); // true
    isNumber('5.5'); // true
    isNumber(.5); // true
    isNumber('.5'); // true
    isNumber(0xff); // true
    isNumber(-5); // true
    isNumber('-5'); // true
    
    isInt(5) // true
    isInt('5') // true
    isInt(-5) // true
    isInt('-5') // true
    
    isFloat(5.5) // true
    isFloat('5.5') // true
    isFloat(-5.5) // true
    isFloat('-5.5') // true

    false

    import {isNumber, isInt, isFloat} from 'isnmbr';
    
    isNumber('5.5+1'); // false
    isNumber('5.5+'); // false
    isNumber('abc'); // false
    isNumber('5.5abc'); // false
    isNumber(function(){ return 0; }); // false
    isNumber(true); // false
    isNumber(false); // false
    isNumber(Infinity); // false
    
    isInt(5.5) // false
    isInt('5.5') // false
    isInt(-5.5) // false
    isInt('-5.5') // false
    
    isFloat(5) // false
    isFloat('5') // false
    isFloat(-5) // false
    isFloat('-5') // false

    Testing

    cd ./node_modules/isnmbr && npm i && npm test 

    License

    MIT

    Install

    npm i isnmbr

    DownloadsWeekly Downloads

    6

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    7.12 kB

    Total Files

    7

    Last publish

    Collaborators

    • avatar