src/utils.js
function isDeepEqual(o1, o2, _depth = 0) {
    let diffs = [];

    if (_depth === 0 && o1 === o2) {
        return true;
    }

    if ((isEmptyObject(o1) && !isEmptyObject(o2)) || (!isEmptyObject(o1) && isEmptyObject(o2))) {
        return false;
    }

    const o1Keys = Object.keys(o1);
    const o2Keys = Object.keys(o2);

    if (o1Keys.length !== o2Keys.length) {
        return false;
    }

    for (let k of o1Keys) {
        const nestedO = _isPropertyNestedObject(o1, k) && _isPropertyNestedObject(o2, k);

        if (nestedO && _depth < MAX_DEPTH) {
            diffs.push(isDeepEqual(o1[k], o2[k], _depth + 1));
        } else {
            const r = (isEmptyObject(o1[k]) && isEmptyObject(o2[k])) || (o2.hasOwnProperty(k) && o2[k] === o1[k]);

            diffs.push(r);

            if (!r) {
                break;
            }
        }
    }

    return diffs.indexOf(false) === -1;
}
function isDeepEqual(o1, o2, _depth = 0) {
    let diffs = [];

    if (_depth === 0 && o1 === o2) {
        return true;
    }

    if ((isEmptyObject(o1) && !isEmptyObject(o2)) || (!isEmptyObject(o1) && isEmptyObject(o2))) {
        return false;
    }

    const o1Keys = Object.keys(o1);
    const o2Keys = Object.keys(o2);

    if (o1Keys.length !== o2Keys.length) {
        return false;
    }

    for (let k of o1Keys) {
        const nestedO = _isPropertyNestedObject(o1, k) && _isPropertyNestedObject(o2, k);

        if (nestedO && _depth < MAX_DEPTH) {
            diffs.push(isDeepEqual(o1[k], o2[k], _depth + 1));
        } else {
            const r = (isEmptyObject(o1[k]) && isEmptyObject(o2[k])) || (o2.hasOwnProperty(k) && o2[k] === o1[k]);

            diffs.push(r);

            if (!r) {
                break;
            }
        }
    }

    return diffs.indexOf(false) === -1;
}
function isDeepEqual ( o1 , o2 , _depth = 0 ) { let diffs = [ ] ; if ( _depth === 0 && o1 === o2 ) { return true ; } if ( ( isEmptyObject ( o1 ) && ! isEmptyObject ( o2 ) ) || ( ! isEmptyObject ( o1 ) && isEmptyObject ( o2 ) ) ) { return false ; } const o1Keys = Object . keys ( o1 ) ; const o2Keys = Object . keys ( o2 ) ; if ( o1Keys . length !== o2Keys . length ) { return false ; } for ( let k of o1Keys ) { const nestedO = _isPropertyNestedObject ( o1 , k ) && _isPropertyNestedObject ( o2 , k ) ; if ( nestedO && _depth < MAX_DEPTH ) { diffs . push ( isDeepEqual ( o1 [ k ] , o2 [ k ] , _depth + 1 ) ) ; } else { const r = ( isEmptyObject ( o1 [ k ] ) && isEmptyObject ( o2 [ k ] ) ) || ( o2 . hasOwnProperty ( k ) && o2 [ k ] === o1 [ k ] ) ; diffs . push ( r ) ; if ( ! r ) { break ; } } } return diffs . indexOf ( false ) === - 1 ; }
Generic deep comparison between javascript simple or complex objects.
@param  {Object} o1 - one of the objects to be compared.
@param  {Object} o2 - second object to compare with first.
@param  {number} [_depth=0] - this parameter serves only for internal usage.
@returns {boolean} returns true if o1 and o2 have exactly the same content, or are exactly the same object reference.
@memberof utils
Generic deep comparison between javascript simple or complex objects .