All files / src/utils areEqual.ts

47.37% Statements 9/19
25% Branches 4/16
100% Functions 1/1
47.37% Lines 9/19

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 46 47 48 49 50 51 52 53 54 554x   97x   97x   97x         97x   14x         14x                                                       14x         83x      
export default function areEqual(o1: any, o2: any): boolean {
 
    const type1 = typeof o1;
 
    const type2 = typeof o2;
 
    Iif (type1 !== type2) {
 
        return false;
    }
 
    if (type1 == 'object') {
 
        Iif (Object.getOwnPropertyNames(o1).length !== Object.getOwnPropertyNames(o2).length) {
 
            return false;
        }
    
        for (var prop in o1) {
    
            if (o1.hasOwnProperty(prop)) {
    
                if (o2.hasOwnProperty(prop)) {
    
                    if (typeof o1[prop] === 'object') {
    
                        if (!areEqual(o1[prop], o2[prop])) {
    
                            return false;
                        }
                    }
                    else {
    
                        if (o1[prop] !== o2[prop]) {
    
                            return false;
                        }
                    }
                }
                else {
    
                    return false;
                }
            }
        }
    
        return true;
 
    }
    else {
 
        return o1 === o2;
    }
    
}