v6.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.deepEqual = void 0;
  4. const isArray = Array.isArray;
  5. const OBJ_PROTO = Object.prototype;
  6. const deepEqual = (a, b) => {
  7. if (a === b)
  8. return true;
  9. let length = 0, i = 0;
  10. if (isArray(a)) {
  11. if (!isArray(b))
  12. return false;
  13. length = a.length;
  14. if (length !== b.length)
  15. return false;
  16. for (i = length; i-- !== 0;)
  17. if (!(0, exports.deepEqual)(a[i], b[i]))
  18. return false;
  19. return true;
  20. }
  21. if (a && b && typeof a === 'object' && typeof b === 'object') {
  22. specific: {
  23. if (a.__proto__ === OBJ_PROTO)
  24. break specific;
  25. if (a instanceof Uint8Array) {
  26. if (!(b instanceof Uint8Array))
  27. return false;
  28. const length = a.length;
  29. if (length !== b.length)
  30. return false;
  31. for (let i = 0; i < length; i++)
  32. if (a[i] !== b[i])
  33. return false;
  34. return true;
  35. }
  36. }
  37. const keys = Object.keys(a);
  38. length = keys.length;
  39. if (length !== Object.keys(b).length)
  40. return false;
  41. if (isArray(b))
  42. return false;
  43. for (i = length; i-- !== 0;) {
  44. const key = keys[i];
  45. if (!(0, exports.deepEqual)(a[key], b[key]))
  46. return false;
  47. }
  48. return true;
  49. }
  50. return false;
  51. };
  52. exports.deepEqual = deepEqual;
  53. //# sourceMappingURL=v6.js.map