TypeCo
A javascript micro library which allows you to check javascript data types.
Installation
npm install typeco
Usage
typeco
supports following functions and returns boolean value by checking the corresponding data type.
isArray()
var typeco = ; var arr = 1 2; var noArr = ''; typeco; // true typeco; // false
isObject()
var typeco = ; var obj = name: 'typeco' ; var noObj = ''; typeco; // true typeco; // false
isString()
var typeco = ; var str = 'typeco-string'; var noStr = ; typeco; // true typeco; // false
isDate()
var typeco = ; var date = ; var noDate = ''; typeco; // true typeco; // false
isRegExp()
var typeco = ; var reg = 'ab+c'; var noReg = ''; typeco; // true typeco; // false
isFunction()
var typeco = ; var { // this is a function }; var noFunc = ''; typeco; // true typeco; // false
isBoolean()
var typeco = ; var bool = true; var boolString = 'true'; var noBool = ''; typeco; // true typeco; // true typeco; // false
isNumber()
var typeco = ; var num = 1; var noNum = ''; typeco; // true typeco; // false
isEmpty()
This function return true if an object has no keys or an array has no items or a string is empty or the data is either null or undefined.
var typeco = ; var str = ''; var arr = ; var obj = {}; var empty1 = null; var empty2 = undefined; typeco; // true typeco; // true typeco; // true typeco; // true typeco; // true
isEmptyOrZero()
This functions works exactly same as isEmpty()
but also returns true if the data is number and value is 0.
var typeco = ; var num = 0; typeco; // true
License
MIT Licensed. Copyright (c) Farhad Yasir 2018.