# all files / TypeScript.NET/source/System/Collections/Array/ Procedure.js

97.52% Statements 118/121
93.33% Branches 84/90
100% Functions 20/20
98.2% Lines 109/111

    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

    1×
    1×
    1×

    1×
    4×
    4×
    1×
    3×
    3×
    1×
    7×
    6×

    2×
    18×
    18×

    3×

    1×
    1×
    4×
    4×
    1×
    3×
    3×
    1×
    1×
    7×
    6×
    6×

    2×
    2×
    18×
    18×

    3×

    1×
    1×
    5×
    5×
    1×
    4×
    4×
    2×
    2×
    8×
    6×
    6×
    1×

    2×
    1×

    2×
    18×
    1×
    1×

    17×
    17×

    4×

    1×
    1×
    8×
    8×
    3×
    5×
    5×
    5×
    31×
    26×
    1×
    1×

    25×
    3×
    2×
    2×

    22×
    22×
    4×

    28×

    5×
    1×
    5×

    1×
    1×
    12×
    2×
    10×
    10×
    6×
    6×
    34×
    28×
    11×
    28×
    4×

    6×
    2×

    4×
    22×
    4×
    4×

    18×
    9×
    18×

    10×

    1×
    6×
    23×

    1×
    1×
    6×
    23×

    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";
        function sum(source, ignoreNaN) {
            if (ignoreNaN === void 0) { ignoreNaN = false; }
            if (!source || !source.length)
                return 0;
            var result = 0;
            if (ignoreNaN)
                source.forEach(function (n) {
                    if (!isNaN(n))
                        result += n;
                });
            else
                source.every(function (n) {
                    result += n;
                    return !isNaN(result);
                });
            return result;
        }
        exports.sum = sum;
        function average(source, ignoreNaN) {
            if (ignoreNaN === void 0) { ignoreNaN = false; }
            if (!source || !source.length)
                return NaN;
            var result = 0, count;
            if (ignoreNaN) {
                count = 0;
                source.forEach(function (n) {
                    if (!isNaN(n)) {
                        result += n;
                        count++;
                    }
                });
            }
            else {
                count = source.length;
                source.every(function (n) {
                    result += n;
                    return !isNaN(result);
                });
            }
            return (!count || isNaN(result)) ? NaN : (result / count);
        }
        exports.average = average;
        function product(source, ignoreNaN) {
            if (ignoreNaN === void 0) { ignoreNaN = false; }
            if (!source || !source.length)
                return NaN;
            var result = 1;
            if (ignoreNaN) {
                var found = false;
                source.forEach(function (n) {
                    if (!isNaN(n)) {
                        result *= n;
                        if (!found)
                            found = true;
                    }
                });
                if (!found)
                    result = NaN;
            }
            else {
                source.every(function (n) {
                    if (isNaN(n)) {
                        result = NaN;
                        return false;
                    }
                    result *= n;
                    return true;
                });
            }
            return result;
        }
        exports.product = product;
        function quotient(source, ignoreNaN) {
            if (ignoreNaN === void 0) { ignoreNaN = false; }
            if (!source || source.length < 2)
                return NaN;
            var result = source[0];
            var found = false;
            source.every(function (n, i) {
                if (i) {
                    if (n === 0) {
                        result = NaN;
                        return false;
                    }
                    if (isNaN(n)) {
                        if (!ignoreNaN) {
                            result = NaN;
                            return false;
                        }
                    }
                    else {
                        result /= n;
                        if (!found)
                            found = true;
                    }
                }
                return true;
            });
            if (!found)
                result = NaN;
            return result;
        }
        exports.quotient = quotient;
        function ifSet(source, start, ignoreNaN, predicate) {
            if (!source || !source.length)
                return NaN;
            var result = start;
            if (ignoreNaN) {
                var found = false;
                source.forEach(function (n) {
                    if (!isNaN(n)) {
                        if (predicate(n, result))
                            result = n;
                        if (!found)
                            found = true;
                    }
                });
                if (!found)
                    result = NaN;
            }
            else {
                source.every(function (n) {
                    if (isNaN(n)) {
                        result = NaN;
                        return false;
                    }
                    if (predicate(n, result))
                        result = n;
                    return true;
                });
            }
            return result;
        }
        function min(source, ignoreNaN) {
            if (ignoreNaN === void 0) { ignoreNaN = false; }
            return ifSet(source, +Infinity, ignoreNaN, function (n, result) { return n < result; });
        }
        exports.min = min;
        function max(source, ignoreNaN) {
            if (ignoreNaN === void 0) { ignoreNaN = false; }
            return ifSet(source, -Infinity, ignoreNaN, function (n, result) { return n > result; });
        }
        exports.max = max;
    });
    //# sourceMappingURL=Procedure.js.map