js-deep-equals
testing of array and object deep equality (unsorted and sorted), accounting for nested arrays and nested objects
faster than JSON.stringify(x) === JSON.stringify(y)
and Lodash's isEqual (benchmark code here)
unsorted arrays are compared by creating a Merkle Tree out of the input and comparing the top level hashes. hashing is done using murmur v3.
usage
npm install js-deep-equals
const compare compareUnsorted = const arr1 = 1 2 3 'test' 'test2' 'test3' a: 12 b: 13 c: 14 d: 71 72 73 'sonested': true // order and contents are the same as arr1let arr2 = 1 2 3 'test' 'test2' 'test3' b: 13 a: 12 // different order of objects is ok c: 14 d: 71 72 73 'sonested': true // order of this array is different than arr1, but content is the samelet arr3 = 1 'test' 2 3 'test2' b: 13 a: 12 d: 71 72 'sonested': true 73 c: 14 'test3' // true // false // true
License
MIT