var isArray = exports.isArray = function (ar) {
    return ar instanceof Array || Array.isArray(ar) || (ar && ar !== Object.prototype && isArray(ar.__proto__));
};

var isBoolean = exports.isBoolean = function (bool) {
    return typeof bool == "boolean";
};

var isDate = exports.isDate = function (d) {
    return d instanceof Date || (typeof d === 'object' && Object.prototype.toString.call(d) === '[object Date]');
};

var isFunction = exports.isFunction = function (fn) {
    return typeof fn == "function";
};

var isInstanceOf = exports.isInstanceOf = function (cls1, cls2) {
    return cls1 instanceof cls2;
};

var isNull = exports.isNull = function (val) {
    return val === null;
};

var isNumber = exports.isNumber = function (nr) {
    return typeof nr == "number";
};

var isObject = exports.isObject = function (obj) {
    return obj !== null && typeof obj == "object" && Object.prototype.toString.call(obj) == '[object Object]' && obj.constructor.toString() == 'function Object() { [native code] }';
};

var isRegExp = exports.isRegExp = function (re) {
    return re instanceof RegExp || (typeof re === 'object' && Object.prototype.toString.call(re) === '[object RegExp]');
};

var isString = exports.isString = function (str) {
    return typeof str == "string";
};

var isUndefined = exports.isUndefined = function (val) {
    return typeof val == "undefined";
};

var typeOf = exports.typeOf = function (obj) {
    if (isArray(obj)) {
        return 'array';
    }
    if (isBoolean(obj)) {
        return 'boolean';
    }
    if (isDate(obj)) {
        return 'date';
    }
    if (isFunction(obj)) {
        return 'function';
    }
    if (isNull(obj)) {
        return 'null';
    }
    if (isNumber(obj)) {
        return 'number';
    }
    if (isObject(obj)) {
        return 'object';
    }
    if (isRegExp(obj)) {
        return 'regexp';
    }
    if (isString(obj)) {
        return 'string';
    }
    if (isUndefined(obj)) {
        return 'undefined';
    }

    return 'unknown';
};

