2
0

is-copy.js 499 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. var eq = require('./eq')
  3. , value = require('./valid-value')
  4. , keys = Object.keys
  5. , propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
  6. module.exports = function (a, b) {
  7. var k1, k2;
  8. if (eq(value(a), value(b))) return true;
  9. a = Object(a);
  10. b = Object(b);
  11. k1 = keys(a);
  12. k2 = keys(b);
  13. if (k1.length !== k2.length) return false;
  14. return k1.every(function (key) {
  15. if (!propertyIsEnumerable.call(b, key)) return false;
  16. return eq(a[key], b[key]);
  17. });
  18. };