All files / src/libs type.js

100% Statements 10/10
100% Branches 0/0
100% Functions 10/10
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46              55x       3x       4x       3x       3x       9x       10x       3x       18x       2x    
/**
 * @description JS Type Checking
 * @author heyli
 * @date 2016.07.30
 */
 
export function isType(type, obj) {
    return Object.prototype.toString.call(obj) === '[object ' + type + ']';
}
 
export function isBoolean(obj) {
    return isType('Boolean', obj);
}
 
export function isNumber(obj) {
    return isType('Number', obj);
}
 
export function isString(obj) {
    return isType('String', obj);
}
 
export function isFunction(obj) {
    return isType('Function', obj);
}
 
export function isArray(obj) {
    return isType('Array', obj);
}
 
export function isDate(obj) {
    return isType('Date', obj);
}
 
export function isRegExp(obj) {
    return isType('RegExp', obj);
}
 
export function isObject(obj) {
    return isType('Object', obj);
}
 
export function isError(obj) {
    return isType('Error', obj);
}