shallow-equals ![Flattr this!](https://camo.githubusercontent.com/f0d58d797e61b600bb2f7c88ff44967c2e62291d00873cb1d310ebde4812eede/68747470733a2f2f6170692e666c617474722e636f6d2f627574746f6e2f666c617474722d62616467652d6c617267652e706e67)
![experimental](https://camo.githubusercontent.com/11ce7fd952f2eae4e5467c7f6421660a373d19029c1ca071eb74c16669d2bff1/687474703a2f2f68756768736b2e6769746875622e696f2f73746162696c6974792d6261646765732f646973742f6578706572696d656e74616c2e737667)
Determine if an array or object is equivalent with another, not recursively.
Usage
equals(a, b, [compare])
Check if a
and b
are pretty much the same thing. Note this won't be the case if a
and b
are different types (e.g. Array vs. Object, String vs. Function).
By default, all comparisons between values are using the strict equality (===
) operator. You can also pass in a custom compare
function to override this behavior.
var equals = require('shallow-equals')
// true:
equals([1, 2, 3], [1, 2, 3])
// true:
equals({ hello: 'world' }, { hello: 'world' })
// false:
equals([1, 2, {}], [1, 2, {}])
// true:
equals([1, 2], [
{ value: 1 },
{ value: 2 }
], function(a, b) {
return a === b.value
})
License
MIT. See LICENSE.md for details.