is-copy.js 610 B

123456789101112131415161718192021
  1. "use strict";
  2. var toPosInt = require("../../number/to-pos-integer")
  3. , eq = require("../../object/eq")
  4. , value = require("../../object/valid-value")
  5. , objHasOwnProperty = Object.prototype.hasOwnProperty;
  6. module.exports = function (other) {
  7. var i, length;
  8. value(this);
  9. value(other);
  10. length = toPosInt(this.length);
  11. if (length !== toPosInt(other.length)) return false;
  12. for (i = 0; i < length; ++i) {
  13. if (objHasOwnProperty.call(this, i) !== objHasOwnProperty.call(other, i)) {
  14. return false;
  15. }
  16. if (!eq(this[i], other[i])) return false;
  17. }
  18. return true;
  19. };