# all files / TypeScript.NET/source/System/ Types.js

91.53% Statements 108/118
82.46% Branches 47/57
95% Functions 19/20
92.17% Lines 106/115

    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
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166

    1×
    1×
    1×

    1×
    1×
    1×
    1×
    6649×
    6649×
    6649×
    6649×
    6649×
    6649×
    6649×
    6649×
    6649×
    6649×
    6649×

    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×

    5207×
    5207×

    5207×

    5207×

    1439×
    1439×
    1439×

    1×
    1×
    1×
    1×

    6649×

    1×
    5208×
    5208×

    1×
    10412×
    10412×

    6643×

    3769×
    3769×
    2×
    3769×

    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1283×

    1×
    1×
    57×
    13×
    57×

    1×
    1×
    621×

    1×
    1×
    435×

    1×
    1×
    6078×
    6078×

    2785×

    3290×

    3×

    1×
    1×
    1084×

    1×
    1×
    258×
    258×

    1×
    1×
    164×

    1×
    1×
    5204×

    1×
    1×
    5834×

    1×
    1×
    5550×

    1×
    1×
    295×

    1×

    1×
    1×
    1×

     /*!
     * @author electricessence / https://github.com/electricessence/
     * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
     */
    (function (factory) {
        Eif (typeof module === 'object' && typeof module.exports === 'object') {
            var v = factory(require, exports); Iif (v !== undefined) module.exports = v;
        }
        else if (typeof define === 'function' && define.amd) {
            define(["require", "exports"], factory);
        }
    })(function (require, exports) {
        "use strict";
        var VOID0 = void (0), _BOOLEAN = typeof true, _NUMBER = typeof 0, _STRING = typeof "", _OBJECT = typeof {}, _UNDEFINED = typeof VOID0, _FUNCTION = typeof function () { }, LENGTH = "length";
        var typeInfoRegistry = {};
        var TypeInfo = (function () {
            function TypeInfo(target) {
                var _ = this;
                _.isBoolean = false;
                _.isNumber = false;
                _.isString = false;
                _.isTrueNaN = false;
                _.isObject = false;
                _.isFunction = false;
                _.isUndefined = false;
                _.isNull = false;
                _.isPrimitive = false;
                switch (_.type = typeof target) {
                    case _BOOLEAN:
                        _.isBoolean = true;
                        _.isPrimitive = true;
                        break;
                    case _NUMBER:
                        _.isNumber = true;
                        _.isTrueNaN = isNaN(target);
                        _.isFinite = isFinite(target);
                        _.isValidNumber = !_.isTrueNaN;
                        _.isPrimitive = true;
                        break;
                    case _STRING:
                        _.isString = true;
                        _.isPrimitive = true;
                        break;
                    case _OBJECT:
                        _.target = target;
                        Iif (target === null) {
                            _.isNull = true;
                            _.isNullOrUndefined = true;
                            _.isPrimitive = true;
                        }
                        else {
                            _.isObject = true;
                        }
                        break;
                    case _FUNCTION:
                        _.target = target;
                        _.isFunction = true;
                        break;
                    case _UNDEFINED:
                        _.isUndefined = true;
                        _.isNullOrUndefined = true;
                        _.isPrimitive = true;
                        break;
                    default:
                        throw "Fatal type failure.  Unknown type: " + _.type;
                }
                Object.freeze(_);
            }
            TypeInfo.prototype.member = function (name) {
                var t = this.target;
                return TypeInfo.getFor(t && (name) in (t)
                    ? t[name]
                    : undefined);
            };
            TypeInfo.getFor = function (target) {
                var type = typeof target;
                switch (type) {
                    case _OBJECT:
                    case _FUNCTION:
                        return new TypeInfo(target);
                }
                var info = typeInfoRegistry[type];
                if (!info)
                    typeInfoRegistry[type] = info = new TypeInfo(target);
                return info;
            };
            return TypeInfo;
        }());
        exports.TypeInfo = TypeInfo;
        var Type;
        (function (Type) {
            Type.BOOLEAN = _BOOLEAN;
            Type.NUMBER = _NUMBER;
            Type.STRING = _STRING;
            Type.OBJECT = _OBJECT;
            Type.UNDEFINED = _UNDEFINED;
            Type.FUNCTION = _FUNCTION;
            function isBoolean(value) {
                return typeof value === _BOOLEAN;
            }
            Type.isBoolean = isBoolean;
            function isNumber(value, allowNaN) {
                if (allowNaN === VOID0)
                    allowNaN = true;
                return typeof value === _NUMBER && (allowNaN || !isNaN(value));
            }
            Type.isNumber = isNumber;
            function isTrueNaN(value) {
                return typeof value === _NUMBER && isNaN(value);
            }
            Type.isTrueNaN = isTrueNaN;
            function isString(value) {
                return typeof value === _STRING;
            }
            Type.isString = isString;
            function isPrimitive(value) {
                var t = typeof value;
                switch (t) {
                    case _BOOLEAN:
                    case _STRING:
                    case _NUMBER:
                    case _UNDEFINED:
                        return true;
                    case _OBJECT:
                        return value === null;
                }
                return false;
            }
            Type.isPrimitive = isPrimitive;
            function isFunction(value) {
                return typeof value === _FUNCTION;
            }
            Type.isFunction = isFunction;
            function isObject(value, allowNull) {
                Eif (allowNull === void 0) { allowNull = false; }
                return typeof value === _OBJECT && (allowNull || value !== null);
            }
            Type.isObject = isObject;
            function numberOrNaN(value) {
                return isNaN(value) ? NaN : value;
            }
            Type.numberOrNaN = numberOrNaN;
            function of(target) {
                return TypeInfo.getFor(target);
            }
            Type.of = of;
            function hasMember(value, property) {
                return value && !isPrimitive(value) && (property) in (value);
            }
            Type.hasMember = hasMember;
            function hasMemberOfType(instance, property, type) {
                return hasMember(instance, property) && typeof (instance[property]) === type;
            }
            Type.hasMemberOfType = hasMemberOfType;
            function isArrayLike(instance) {
                return instance instanceof Array
                    || Type.isString(instance)
                    || !Type.isFunction(instance) && hasMember(instance, LENGTH);
            }
            Type.isArrayLike = isArrayLike;
        })(Type = exports.Type || (exports.Type = {}));
        Object.freeze(Type);
        Object.defineProperty(exports, "__esModule", { value: true });
        exports.default = Type;
    });
    //# sourceMappingURL=Types.js.map