UNPKG

@darwino/darwino

Version:

A set of Javascript classes and utilities

53 lines (44 loc) 1.54 kB
/*!COPYRIGHT HEADER! - CONFIDENTIAL * * Darwino Inc Confidential. * * (c) Copyright Darwino Inc. 2014-2016. * * Notice: The information contained in the source code for these files is the property * of Darwino Inc. which, with its licensors, if any, owns all the intellectual property * rights, including all copyright rights thereto. Such information may only be used * for debugging, troubleshooting and informational purposes. All other uses of this information, * including any production or commercial uses, are prohibited. */ // // Deep compare 2 JSON objects // Inspired from https://github.com/epoberezkin/fast-deep-equal // MIT license // export default function jsonEquals(a, b) { if (a === b) return true; if (a && b && typeof a === 'object' && typeof b === 'object') { if (Array.isArray(a)) { var _length = a.length; if (_length != b.length) return false; for (var i = _length; i-- !== 0;) { if (!jsonEquals(a[i], b[i])) return false; } return true; } var keys = Object.keys(a); var length = keys.length; if (length !== Object.keys(b).length) return false; for (var _i = length; _i-- !== 0;) { if (!Object.prototype.hasOwnProperty.call(b, keys[_i])) return false; } for (var _i2 = length; _i2-- !== 0;) { var key = keys[_i2]; if (!jsonEquals(a[key], b[key])) return false; } return true; } // true if both NaN, false otherwise return a !== a && b !== b; } ; //# sourceMappingURL=JsonEquals.js.map