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

95.65% Statements 66/69
88.24% Branches 45/51
100% Functions 7/7
96.88% Lines 62/64

    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

    1×
    1×
    1×

    1×
    1×
    1×
    33×
    8×
    25×
    3×
    22×
    22×
    1×
    21×
    3×
    18×

    1×
    8×
    8×
    1×
    7×
    2×
    5×
    5×
    12×
    3×

    2×

    1×
    1×
    25×
    25×
    25×
    14×
    11×
    47×
    3×

    8×

    1×
    1×
    14×
    4×
    10×
    10×
    2×

    8×
    8×

    10×
    400024×

    10×
    10×

    1×
    8×
    8×
    8×
    1×
    7×
    7×
    7×
    11×
    4×

    3×

    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", "../../Compare", "../../Types"], factory);
        }
    })(function (require, exports) {
        "use strict";
        var Values = require("../../Compare");
        var Types_1 = require("../../Types");
        function validateSize(a, b) {
            if (a && b && a === b || !a && !b)
                return true;
            if (!a || !b)
                return false;
            var len = a.length;
            if (len !== b.length)
                return false;
            if (len === 0)
                return true;
            return len;
        }
        function areAllEqual(arrays, strict, equalityComparer) {
            if (equalityComparer === void 0) { equalityComparer = Values.areEqual; }
            if (!arrays)
                throw new Error("ArgumentNullException: 'arrays' cannot be null.");
            if (arrays.length < 2)
                throw new Error("Cannot compare a set of arrays less than 2.");
            var first = arrays[0];
            for (var i = 0, l = arrays.length; i < l; i++) {
                if (!areEqual(first, arrays[i], strict, equalityComparer))
                    return false;
            }
            return true;
        }
        exports.areAllEqual = areAllEqual;
        function areEqual(a, b, strict, equalityComparer) {
            if (equalityComparer === void 0) { equalityComparer = Values.areEqual; }
            var len = validateSize(a, b);
            if (Types_1.Type.isBoolean(len))
                return len;
            for (var i = 0; i < len; i++) {
                if (!equalityComparer(a[i], b[i], strict))
                    return false;
            }
            return true;
        }
        exports.areEqual = areEqual;
        function sort(a, comparer) {
            if (!a || a.length < 2)
                return a;
            var len = a.length, b;
            if (len > 65536)
                b = new Array(len);
            else {
                b = [];
                b.length = len;
            }
            for (var i = 0; i < len; i++) {
                b[i] = a[i];
            }
            b.sort(comparer);
            return b;
        }
        function areEquivalent(a, b, comparer) {
            if (comparer === void 0) { comparer = Values.compare; }
            var len = validateSize(a, b);
            if (Types_1.Type.isBoolean(len))
                return len;
            a = sort(a, comparer);
            b = sort(b, comparer);
            for (var i = 0; i < len; i++) {
                if (comparer(a[i], b[i]) !== 0)
                    return false;
            }
            return true;
        }
        exports.areEquivalent = areEquivalent;
    });
    //# sourceMappingURL=Compare.js.map