aeb874085bb084b5cdb4106a3f90a1c20d278909
[platform/framework/web/crosswalk-tizen.git] /
1 define(['./hasOwn', './every', '../lang/isObject', '../lang/is'], function(hasOwn, every, isObject, is) {
2
3     // Makes a function to compare the object values from the specified compare
4     // operation callback.
5     function makeCompare(callback) {
6         return function(value, key) {
7             return hasOwn(this, key) && callback(value, this[key]);
8         };
9     }
10
11     function checkProperties(value, key) {
12         return hasOwn(this, key);
13     }
14
15     /**
16      * Checks if two objects have the same keys and values.
17      */
18     function equals(a, b, callback) {
19         callback = callback || is;
20
21         if (!isObject(a) || !isObject(b)) {
22             return callback(a, b);
23         }
24
25         return (every(a, makeCompare(callback), b) &&
26                 every(b, checkProperties, a));
27     }
28
29     return equals;
30 });