All files / src/Ice ArrayUtil.js

91.11% Statements 41/45
83.33% Branches 20/24
100% Functions 3/3
91.11% Lines 41/45

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 4641x 41x 41x 26673x 15674x 24691x   10999x   10999x 5x 10999x 27x 27x 10967x 41x 41x 41x 41x 181x   181x   181x 181x 181x 181x 41x 41x 477x 121x 121x 356x 477x 477x 552x 1x 1x 552x 355x 355x 477x 41x 41x 41x  
// Copyright (c) ZeroC, Inc.
 
const eq = function (e1, e2) {
    if (e1 === e2) {
        return true; // If identity compare equals members are equal.
    } else if (e1 === null || e1 === undefined || e2 === null || e2 === undefined) {
        return false;
    } else if (e1.prototype !== e2.prototype) {
        return false;
    } else if (typeof e1.equals == "function") {
        return e1.equals(e2);
    } else if (e1 instanceof Array || e1 instanceof Uint8Array) {
        return ArrayUtil.equals(e1, e2, eq);
    }
    return false;
};
 
export class ArrayUtil {
    static clone(arr) {
        if (arr === undefined) {
            return arr;
        } else if (arr === null) {
            return [];
        } else {
            return arr.slice();
        }
    }
 
    static equals(v1, v2, valuesEqual) {
        if (v1.length != v2.length) {
            return false;
        }
 
        const equalFn = valuesEqual || eq;
        for (let i = 0; i < v1.length; ++i) {
            if (!equalFn.call(equalFn, v1[i], v2[i])) {
                return false;
            }
        }
 
        return true;
    }
}
 
ArrayUtil.eq = eq;