deepEquals.js 569 B

123456789101112131415161718192021222324252627
  1. var isObject = require('../lang/isObject');
  2. var equals = require('./equals');
  3. function defaultCompare(a, b) {
  4. return a === b;
  5. }
  6. /**
  7. * Recursively checks for same properties and values.
  8. */
  9. function deepEquals(a, b, callback){
  10. callback = callback || defaultCompare;
  11. if (!isObject(a) || !isObject(b)) {
  12. return callback(a, b);
  13. }
  14. function compare(a, b){
  15. return deepEquals(a, b, callback);
  16. }
  17. return equals(a, b, compare);
  18. }
  19. module.exports = deepEquals;