typeverifier v1.0.3
typeverifier
Small utility to check variable types.
Usage
typeverifier is available as an npm package. Simply run npm install typeverifier command.
To use it in your project:
import typeverifier from 'typeverifier'; // ES6 syntax
var typeverifier = require('typeverifier'); // ES5 syntaxAPI
The following methods are available and return true or false.
defined(val): Whethervalis an defined or not (different fromundefinedornull)null(val): Whethervalisnullstring(val): Whethervalis aStringor notnumber(val): Whethervalis aNumberor notboolean(val): Whethervalis aBooleanor notarray(val): Whethervalis anArrayor notobject(val): Whethervalis anObjectliteral or not (different fromundefinedornull)emptyObject(val): Whethervalis an emptyObjectliteral or notregex(val): Whethervalis aRegExpor notdate(val): Whethervalis aDateor notfunc(val): Whethervalis aFunctionor noterror(val): Whethervalis anErroror notinstanceOf(val, name): Whethervalis an instance of the class whose name is identical to thenameparameter. Do not use this class to check primitives, Arrays, Functions, Dates, RegExps, Objects, etc (rely oninstanceoffor those cases). Use it only for developer authored classes.
License
This software is released under the terms of WTFPL v2.0 license.