is-copy.js 552 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. , hasOwnProperty = Object.prototype.hasOwnProperty;
  6. module.exports = function (other) {
  7. var i, l;
  8. (value(this) && value(other));
  9. l = toPosInt(this.length);
  10. if (l !== toPosInt(other.length)) return false;
  11. for (i = 0; i < l; ++i) {
  12. if (hasOwnProperty.call(this, i) !== hasOwnProperty.call(other, i)) {
  13. return false;
  14. }
  15. if (!eq(this[i], other[i])) return false;
  16. }
  17. return true;
  18. };