is-copy.js 596 B

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