iftype

Check types
Installation
$ npm install iftype --save
Usage
"use strict";
const iftype = require('iftype');
function CustomType(){
}
iftype(123).is('string');
iftype(function foo(){}).is('string');
iftype(new CustomType()).is('string');
iftype(["foo", "bar"]).is('string');
iftype("bar").is('string');
iftype(null).is('string');
iftype(undefined).is('string');
iftype(123).is('number');
iftype(function foo(){}).is('number');
iftype(new CustomType()).is('number');
iftype(["foo", "bar"]).is('number');
iftype("bar").is('number');
iftype(null).is('number');
iftype(undefined).is('number');
iftype(123).is('object');
iftype(function foo(){}).is('object');
iftype(new CustomType()).is('object');
iftype(["foo", "bar"]).is('object');
iftype("bar").is('object');
iftype(null).is('object');
iftype(undefined).is('object');
iftype(123).is('array');
iftype(function foo(){}).is('array');
iftype(new CustomType()).is('array');
iftype(["foo", "bar"]).is('array');
iftype("bar").is('array');
iftype(null).is('array');
iftype(undefined).is('array');
iftype(123).is('function');
iftype(function foo(){}).is('function');
iftype(new CustomType()).is('function');
iftype(["foo", "bar"]).is('function');
iftype("bar").is('function');
iftype(null).is('function');
iftype(undefined).is('function');
iftype(123).is(CustomType);
iftype(function foo(){}).is(CustomType);
iftype(new CustomType()).is(CustomType);
iftype(["foo", "bar"]).is(CustomType);
iftype("bar").is(CustomType);
iftype(null).is(CustomType);
iftype(undefined).is(CustomType);
API
iftype(val).is(type) | Check if type match. |
iftype(val).isString() | Check if string. |
iftype(val).isNumber() | Check if number. |
iftype(val).isObject() | Check if object. |
iftype(val).isArray() | Check if array. |
iftype.is(type, val) | Check if type match. |
iftype.isString(val) | Check if string. |
iftype.isNumber(val) | Check if number. |
iftype.isObject(val) | Check if object. |
iftype.isArray(val) | Check if array. |
License
This software is released under the MIT License.
Links