1 | var hasOwn = require('./hasOwn');
|
2 | var every = require('./every');
|
3 | var isObject = require('../lang/isObject');
|
4 | var is = require('../lang/is');
|
5 |
|
6 |
|
7 |
|
8 | function makeCompare(callback) {
|
9 | return function(value, key) {
|
10 | return hasOwn(this, key) && callback(value, this[key]);
|
11 | };
|
12 | }
|
13 |
|
14 | function checkProperties(value, key) {
|
15 | return hasOwn(this, key);
|
16 | }
|
17 |
|
18 | |
19 |
|
20 |
|
21 | function equals(a, b, callback) {
|
22 | callback = callback || is;
|
23 |
|
24 | if (!isObject(a) || !isObject(b)) {
|
25 | return callback(a, b);
|
26 | }
|
27 |
|
28 | return (every(a, makeCompare(callback), b) &&
|
29 | every(b, checkProperties, a));
|
30 | }
|
31 |
|
32 | module.exports = equals;
|
33 |
|