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

71.25% Statements 57/80
45.1% Branches 23/51
72.22% Functions 13/18
71.79% Lines 56/78

    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

    1×
    1×
    1×

    1×
    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    11×

    1×
    11×
    11×

    1×
    1×
    1×
    1×

    1×
    1×

    1×
    1×

    1×
    1×
    1×
    1×

    1×

    1×
    2×
    2×

    1×
    1×
    1×
    508×

    1×
    1×
    13×

    1×
    1×
    493×
    493×
    3×
    490×

    1×
    1×
    118×
    116×
    3×
    113×

    1×
    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", "./Exceptions/ArgumentException", "./Exceptions/ArgumentOutOfRangeException"], factory);
        }
    })(function (require, exports) {
        "use strict";
        var ArgumentException_1 = require("./Exceptions/ArgumentException");
        var ArgumentOutOfRangeException_1 = require("./Exceptions/ArgumentOutOfRangeException");
        function Integer(n) {
            return Math.floor(n);
        }
        exports.Integer = Integer;
        var Integer;
        (function (Integer) {
            Integer.MAX_32_BIT = 2147483647;
            function r(maxExclusive) {
                return (Math.random() * maxExclusive) | 0;
            }
            function random(maxExclusive) {
                assert(maxExclusive, 'maxExclusive');
                return r(maxExclusive);
            }
            Integer.random = random;
            var random;
            (function (random) {
                function next(boundary, inclusive) {
                    assert(boundary, 'max');
                    if (boundary === 0)
                        return 0;
                    if (inclusive)
                        boundary += boundary / Math.abs(boundary);
                    return r(boundary);
                }
                random.next = next;
                function nextInRange(min, max, inclusive) {
                    assert(min, 'min');
                    assert(max, 'max');
                    var range = max - min;
                    if (range === 0)
                        return min;
                    if (inclusive)
                        range += range / Math.abs(range);
                    return min + next(range);
                }
                random.nextInRange = nextInRange;
                function select(source) {
                    return source && source.length
                        ? source[r(source.length)]
                        : void (0);
                }
                random.select = select;
                var select;
                (function (select) {
                    function one(source) {
                        return random.select(source);
                    }
                    select.one = one;
                })(select = random.select || (random.select = {}));
            })(random = Integer.random || (Integer.random = {}));
            function as32Bit(n) {
                var result = n | 0;
                return (n === -1 || result !== -1) ? result : null;
            }
            Integer.as32Bit = as32Bit;
            var NUMBER = "number";
            function is(n) {
                return typeof n === NUMBER && isFinite(n) && n === Math.floor(n);
            }
            Integer.is = is;
            function is32Bit(n) {
                return n === (n | 0);
            }
            Integer.is32Bit = is32Bit;
            function assert(n, argumentName) {
                var i = is(n);
                if (!i)
                    throw new ArgumentException_1.ArgumentException(argumentName || 'n', "Must be a integer.");
                return i;
            }
            Integer.assert = assert;
            function assertZeroOrGreater(n, argumentName) {
                var i = assert(n, argumentName) && n >= 0;
                if (!i)
                    throw new ArgumentOutOfRangeException_1.ArgumentOutOfRangeException(argumentName || 'n', n, "Must be a valid integer greater than or equal to zero.");
                return i;
            }
            Integer.assertZeroOrGreater = assertZeroOrGreater;
            function assertPositive(n, argumentName) {
                var i = assert(n, argumentName) && n > 0;
                if (!i)
                    throw new ArgumentOutOfRangeException_1.ArgumentOutOfRangeException(argumentName || 'n', n, "Must be greater than zero.");
                return i;
            }
            Integer.assertPositive = assertPositive;
        })(Integer = exports.Integer || (exports.Integer = {}));
        Object.defineProperty(exports, "__esModule", { value: true });
        exports.default = Integer;
    });
    //# sourceMappingURL=Integer.js.map