SerovMihail
8/14/2017 - 8:25 AM

type.js extension

type.js extension

(function () {
    'use strict';

    var type = {
        Get: function (obj) {
            return {}.toString.call(obj);
        },
        /**
         * @return {boolean}
         */
        IsNullOrWhiteSpace: function (str) {
            if (!this.IsType(str, ""))
                return true;

            if (this.IsNull(str))
                return true;

            str = str.replace(/\s/g, "");

            return str.length == 0;
        },
        /**
         * @return {boolean}
         */
        IsType: function (value, obj) {
            return this.Get(value) == this.Get(obj);
        },
        /**
         * @return {boolean}
         */
        IsNull: function (val) {
            return this.IsType(val, null) || this.IsType(val, undefined);
        },
        /**
         * @return {boolean}
         */
        IsFunction: function (val) {
            return this.IsType(val, function () {
            });
        }
    };

    window.Type = type;

})();